Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAVA SWING: HOW TO RE-VALIDATE OR REPAINT JFRAME

 
Lalit Sahu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i press on "compare" button, i don't able to see message display by Label(lbresult) until i reset the Frame size.So how to resize the frame automatically.In below code where should i add re-validate code to resize the frame.(Beginner and keen to learn. Thk in ADV)





Screenshot-(15).png
[Thumbnail for Screenshot-(15).png]
 
Lalit Sahu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
image added http://share.pho.to/ASB13
 
Campbell Ritchie
Sheriff
Posts: 51415
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add something like
myFrame.repaint();
at the end of the action performed method. Make sure to write it last.
Don't write ALL UPPER CASE, which is not permissible on any website.
 
Lalit Sahu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now onward will remember not to write in uppercase
 
Lalit Sahu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not working
 
Campbell Ritchie
Sheriff
Posts: 51415
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lalit Sahu wrote:. . . will remember not to write in uppercase
Thank you
 
Lalit Sahu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

added frame.repaint just below catch statement at line 44.Still not working
 
Campbell Ritchie
Sheriff
Posts: 51415
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lalit Sahu wrote:not working
Please explain what is going wrong.
Please also explain what you are trying to do. Why are you using that dreadful method read()? Are you trying to find differences between the two files? What will happen when file A reads
Lalit
...and file B reads
Lalit Sahu
?
 
Lalit Sahu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Please also explain what you are trying to do. Why are you using that dreadful method read()? Are you trying to find differences between the two files? What will happen when file A reads
Lalit
...and file B reads

i created a File Comparing program which  comparing File A and File B .It working as aspected.

Problem : Used 3 JLabel  .1st one display"First File" ,2nd label display "Second File:".u can see in Image which shared by me.Now 3rd Jlabel display the status like "File are Same or differ or forget to enter file name".
When i click on Compare button ,3rd JLabel message displayed only if i readjust the frame size manually(manually mean Stretching frame using Mouse or increasing frame size using mouse.

What i want: 3rd JLabel message  display without manually adjusting Frame size
 
Piet Souris
Rancher
Posts: 1529
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apart from Campbells remarks, you are using a FlowLayout for the contentpane of your frame. Now, that is rather useless for what you want to achieve. Simply use the default BorderLayout.
The changes you need to make are minor and only in your constructor:


When you are finished comparing, just write whatever you want to your lbresult-label, with automatic adjustment of the required size.
 
Campbell Ritchie
Sheriff
Posts: 51415
87
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use equals(""); us the isEmpty() method.
I tried your app and got it to work. I can't see anything wrong with its functionality. But I had to resize it to see anything. It still seemed to work if I took out the repaint call. I think the real problem is a layout thing. I think flow layout is useless; in fact until I resized the window, I couldn't see that output label at all. I think you can sort out your problems simply with a different layout.
The action performed method is much too long; it shou‍ld be divided up into several smaller methods.
 
Lalit Sahu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Don't use equals(""); us the isEmpty() method.
I tried your app and got it to work. I can't see anything wrong with its functionality. But I had to resize it to see anything. It still seemed to work if I took out the repaint call. I think the real problem is a layout thing. I think flow layout is useless; in fact until I resized the window, I couldn't see that output label at all. I think you can sort out your problems simply with a different layout.
The action performed method is much too long; it shou‍ld be divided up into several smaller methods.



I got your point.Thanks
 
Lalit Sahu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piet Souris wrote:Apart from Campbells remarks, you are using a FlowLayout for the contentpane of your frame. Now, that is rather useless for what you want to achieve. Simply use the default BorderLayout.
The changes you need to make are minor and only in your constructor:


When you are finished comparing, just write whatever you want to your lbresult-label, with automatic adjustment of the required size.


okay .Thanks for editing and providing valuable help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic