Hi Team,
Please follow the sample below.
Scenario 1:
----------------
1. enter the value as 100,200
2. press the button to get the value
3. it will print as 0.
Expected : 100,200
But the working steps is:
1. enter the value 200,200
2. press enter key
3. press the button and the print msg will be 200,200
Please resolve this.
Hope now you understood.
( And i noticed that the focus listener is not working in the point spinner. )
- Code: Select all
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.spinner.PointSpinner;
import com.jidesoft.swing.JideButton;
public class PointSpinnerDemo1 extends JFrame {
PointSpinnerDemo1() {
setTitle( "Focus retained problem" );
getContentPane().add( getDemoPanel() );
pack();
setVisible( true );
}
public Component getDemoPanel() {
JPanel panel = new JPanel();
panel.setLayout( new BorderLayout() );
final PointSpinner pointSpinner = new PointSpinner();
panel.add( pointSpinner, BorderLayout.CENTER );
final JideButton jbtn = new JideButton( "Press To Get Value" );
jbtn.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println( "Value : " + pointSpinner.getValue() );
}
} );
panel.add( jbtn, BorderLayout.NORTH );
pointSpinner.addFocusListener( new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
System.out.println( "--How to call this--------------fl" );
jbtn.doClick();
}
@Override
public void focusGained(FocusEvent e) {
}
} );
return panel;
}
static public void main(String[] s) {
LookAndFeelFactory.installDefaultLookAndFeelAndExtension();
new PointSpinnerDemo1();
}
}