Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
454 views
in Technique[技术] by (71.8m points)

jframe - setMaximumSize not working in java

I hava a java program with a JFrame

I am using absolute positioning

here is my main function

public static void main(String[] args) {
    ape Ape = new ape();
    Ape.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Ape.setSize(1000,1000);
    Ape.setMinimumSize(new Dimension(1000,1000));
    Ape.setMaximumSize(new Dimension(1000,1000));
    Ape.setVisible(true);
}

When I run the program I try to resize it and make the window smaller but I can't

when I try to make the window bigger it works fine I basicly skips the setMaximumSize() function

I have read around and aparently this has happened before

is this a known bug?

if so I heard I could make a Window Listener, when I tried it I implemented the functions that WindowListener needed but could not find anything to solve my problem

please try this yourself and see what happens...

thanks in advance

PS... please don't laugh about the names I give my classes... :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

see http://forums.sun.com/thread.jspa?threadID=5342801:

It's a known bug:

Maybe you could use

Ape.setResizable(false)

instead?

PS: It's a convention to give classes names that start with a capital letter and variables ones with a small letter, not vice versa.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...