Forums Register Login

jlist focus problem

+Pie Number of slices to send: Send
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
Attractive, successful people love this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1061 times.
Similar Threads
FocusListener problem
problem with insert and select
How to save the objects into a text file???
Problem on running an applet in linux...
How to set the objects into the applets???
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:54:07.