• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to refresh a JFrame containing a JPanel with lots of Components

 
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I m unable to refresh the JFrame , as the JFrame is consisting JPanel with few components on it. In that JPanel , I have added a JComboBOx , which should be updated as soon as the user update any value for the JComboBox. I am adding a piece of my Code-





I have already tried with validate(),repaint() , it may possible that i didnt work that one perfectly.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch Please use the code button for youir posts, rather than coloured text, which is hard to read. I have added code tags for you.

The methods of JComboBox which add or remove items don't work? Are there any Listeners on the JComboBox?
What is the bit about compareTo("New...") supposed to do? That will fail unless you pass "New..."

Otherwise, don't know. Maybe somebody else will be able to help.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And have you forgotten to close your BufferedWriter?
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right..Guess....Today is the 1st Day...in CodeRanch.will follow the standards..[try to]


My main concern is to update or refresh the entire JFrame.
JFrame consists a JPanel containing a total of 8 diff components. I want to refresh the whole JFrame so that the listener could update the data.

 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Right..Guess....Today is the 1st Day...in CodeRanch.will follow the standards



And while you're at it, learn Java coding standards. Variable names are not capitalized. I've never seen a text book or tutorial use capitalized names so why are you?

If you want to refresh a component then just use the "setText" (or equivalent) method of the component. There is no need to create new Components every time just to change its value.

If you are creating brand new components then you need to use "panel.revalidate()" after adding the components to a panel.
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I only posted a very small part of the Code..the code is actually like..I am allowing the user to enter the any Name to e added in the JComboBox , then I write that string into a file , an in the code , the JComboBox values are being fetched through the FileReader scenario , exactly I only want to update this particular Field after updting the File , but I am not sure is it possible here or not.


 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I only posted a very small part of the Code..the code is actually like..I am allowing the user to enter the any Name to e added in the JComboBox , then I write that string into a file , an in the code , the JComboBox values are being fetched through the FileReader scenario , exactly I only want to update this particular Field after updting the File , but I am not sure is it possible here or not.


Thanks, Issue Solved

 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

buntha Choudhary wrote:Thanks, Issue Solved

Please tell us how you solved it. That might be useful for other people in the future.
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I used the Revalidate() option..didnt require the Repaint();
 
I child proofed my house but they still get in. Distract them with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic