• Post Reply Bookmark Topic Watch Topic
  • New Topic

method working, but not vice versa  RSS feed

 
emilio rossi
Ranch Hand
Posts: 47
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hallo everyone,
i have two methods into a class wich extends JFrame, one makes the Frame getting smaller and smaller and then disappear (and it works fine),
the other one is supposed to make the frame bigger and bigger to the wished size, but does not work... the frame becomes visible after a while already at the maximum size.
dont know why since the pop() method is the exact vice versa of the flop() method, looks like pop is unable to update quickly the Frame while flop is, how comes?

 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I modified your code slightly and it works perfectly for me in both cases. Your original code has some problems:

1. In the 'flop' method, while loop, both conditions use height - I guess one should be width...
2. The condition of >2 doesn't work. On a Windows Vista machine, the minimum height for a frame shows as 34. So, usage of > 2 ends in a indefinite loop. So, I changed the condition to > 34.
3. In the call to 'setSize', in the 'flop' method, you have used 'fthis' for width and 'this' for height. I am unable to understand why 2 different things are used here. I changed it to 'this' in both cases.
4. I have removed the call to setLocation as I don't know what the ScrDim is.
 
emilio rossi
Ranch Hand
Posts: 47
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for the bad code, i retyped it quickly and made some mistakes, in the original one:
1 - it is width
2 - >2 works since the class constructor set the frame undecorated
3 - fthis is a typing error
4 - Scrdim is a static dimension whic gets the screen dimension

sorry again i typed it in a hurry.

cannot figure out why this dont work for me, i read something about EDT and put the repaint() call into a invokelater(), but it still doesnt work
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also works OK for me.

create a small program that demonstrates the problem, and post that code here.

just a JFrame with 2 buttons (1 x flop, 1 x pop), the flop/pop codes, and make the
'pop' button the default button, so that we can click 'flop' to decrease size, then
press 'enter' to increase size (and see it not working).

don't include anything not related to the problem e.g. setLocation is probably
unrelated, but test it with/without before posting.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!