This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jlist focus problem  RSS feed

 
kajal sharma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I want to do is when user select value from two jlist I match the to selected value with the event on lostfocus of wordList2(second one) and then let him pass to enter other fields in the form.

item1 and item2 are selected value by him.


public void focusGained(FocusEvent fe){}

public void focusLost(FocusEvent fe){
Object source=fe.getSource();
System.out.println(source); //here I am printing which
source is been click
if(source==wordList12){
if(fe.isTemporary()){return;}
else if ( item1.equals("M-9 Other Antibiotics")
&& (item2.equals("R-1 Oral") | | item2.equals("R-2 Intra Muscular")) ){ JOptionPane.showMessageDialog( this, "Age should be in between 2 and 60" );

SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
System.out.println("Requesting focus to"+wordList1); wordList1.requestFocus();
}
});

}
}
}

------------------------------------------------------------------------
----------------------
I am using two list as
wordList1.setName("wordList1");
wordList1.setVisibleRowCount(1);
JScrollPane scrollpane1=new JScrollPane(wordList1);
jPanel7.add(scrollpane1);
wordList1.setSelectedIndex(0);
wordList1.addListSelectionListener(this);
wordList1.addFocusListener(this);

AND

wordList2.setName("wordList2");
wordList2.setSelectedIndex(0);
wordList2.setVisibleRowCount(1);
JScrollPane scrollpane2=new JScrollPane(wordList2);
jPanel8.add(scrollpane2);
wordList2.addListSelectionListener(this);
wordList2.addFocusListener(this);


First I click wordList1 and then wordList2 so the following code get printed out on my screen as I am calling system.out but nothing happens after that.

It is here -152

javax.swing.JList[wordList1,0,-
152,152x475,alignmentX=null,alignmentY=null,border=,flags=32,maximumSize =,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=- 1,horizontalScrollIncrement=-
1,selectionBackground=javax.swing.plaf.ColorUIResource
[r=0,g=0,b=128],selectionForeground=javax.swing.plaf.ColorUIResource [r=255,g=255,b=255],visibleRowCount=1]

javax.swing.JList
[wordList2,0,0,118x133,alignmentX=null,alignmentY=null,border=,flags=32, maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-
1,fixedCellWidth=-1,horizontalScrollIncrement=-
1,selectionBackground=javax.swing.plaf.ColorUIResource
[r=0,g=0,b=128],selectionForeground=javax.swing.plaf.ColorUIResource [r=255,g=255,b=255],visibleRowCount=1]


any sugestion
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!