Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem painting Jlist  RSS feed

 
Barry Brashear
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • 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
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code Code Code, would love to see some Code.
 
Ed Tidwell
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!