• 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

JTextField & repaint issues.

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have JDialog box that houses 3 JPanels , SearchPanel, DataPanel and ButtonPanel.
The SearchPanel houses a JLabel (searchLabel) and JTextField (mySearchField).
The DataPanel (myDataPanel) has several JComboBox's. I've added (sub-classed) ActionListener to the combo boxes that will take the selected object, process the data, and do a mySearchField.setText(theData) on the SearchPanel's JTextField.
The problem I seem to have is it does not seem to be repainted, i.e. the old text "Blank" is still there. I've tried repaint() on the JDialog, DataPanel, JTextField (all I could think of) as well as invalidate() and revalidate(). I'm not sure what to try next. I know I'm missing something, just can't figure out what. I've show the relevent code below (cut out the non-revelent parts). Any help is greatly appreciated!



At line 143, in the debugger (Eclipse) I can see that the mySearchField->model (PlainDocument)->data->array has the correct string from what was selected in the combo box. I've even added an
mySearchField.addActionListener(new ActionListener(ActionEvent ae) {...}); in the initSearchPanel() as well as a mySearchField.postActionEvent() in the FieldListeners actionPerformed() to know avail.
 
Ranch Hand
Posts: 67
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please provide a full working example. I tried what you did, but I don't get problems with the following code:

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wasn't positive what you attempted exactly, it seems to me a just after line 142 should fix your problem. Is it my understanding you have already attempted that(or with revalidate) at that location and it still would not display the new string in your field? And you double checked that just after line 142 mySearchField does indeed hold the String you desire to display?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
validate() / invalidate() / revalidate() are all irrelevant in the context of setting the text of a JTextComponent. And repaint() isn't required.

To get better help sooner, post a SSCCE.
 
Roy Pozarelli
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, got the solution, in building up the SSCCE (although it was becoming a LSCCE - long, which is why I didn't want to post it to begin with) it actually was a issue of duplicates - Singleton solved the problem.
 
Bobby Smallman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad to hear it! :-)
reply
    Bookmark Topic Watch Topic
  • New Topic