• 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

Problem painting Jlist

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an application that opens a JDialog containing some text. Occasionally, the dialog will open and look totally grey with no text visible. After inserting System.out.println and other debugging aids, it appears that the Jlist contains the data. I just can't see it.
I have tried using revalidate, but to no affect.
Any ideas?
thanks,
Barry
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Code Code Code, would love to see some Code.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
/**
* Notifies <code>JList</code> <code>ListSelectionListener</code>s that
* the selection model has changed. It's used to forward
* <code>ListSelectionEvents</code> from the <code>selectionModel</code>
* to the <code>ListSelectionListener</code>s added directly to the
* <code>JList</code>.
* @param firstIndex the first selected index
* @param lastIndex the last selected index
* @param isAdjusting true if multiple changes are being made
*
* @see #addListSelectionListener
* @see #removeListSelectionListener
* @see EventListenerList
*/
protected void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
Is this the answer to your problem?
I forget to do this alot when I work with JTables.
Hope this helps,
Ed
 
Barry Brashear
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would I use it? fireSelectionValueChanged is
a protected method.
 
Barry Brashear
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
private JScrollPane scrollOne = null;
private JList listOne = null;
listOne = new JList( );
listOne.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
listOne.setFont( new Font( "serif", Font.BOLD, 18 ) );
scrollOne = new JScrollPane( listOne,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );

scrollOne.setPreferredSize(new Dimension(400, 100));
scrollOne.setMaximumSize ( new Dimension(1000,1000 ) );

listOne.setCellRenderer(new TextListRenderer
(pageItem)); // pageItem is a class
used to set the color for a particular
type of text
listOne.setListData( listItems );// listItems is a Vector of text
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic