Add a scroll-control on the spinner
This commit is contained in:
parent
7fcd7d4449
commit
d50b4f0042
@ -7,13 +7,10 @@ import lsystem.utils.Pair;
|
|||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.*;
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.KeyListener;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Listener implements ActionListener, KeyListener {
|
public class Listener implements ActionListener, KeyListener, MouseWheelListener {
|
||||||
Tab tab;
|
Tab tab;
|
||||||
MainFrame frame;
|
MainFrame frame;
|
||||||
Integer index;
|
Integer index;
|
||||||
@ -145,4 +142,12 @@ public class Listener implements ActionListener, KeyListener {
|
|||||||
public void resetNbAxioms(){
|
public void resetNbAxioms(){
|
||||||
nbAxioms = 0;
|
nbAxioms = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||||
|
if(e.getWheelRotation() < 0)
|
||||||
|
tab.itSpinner.setValue(tab.itSpinner.getNextValue());
|
||||||
|
else
|
||||||
|
tab.itSpinner.setValue(tab.itSpinner.getPreviousValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ public class Tab extends JPanel{
|
|||||||
|
|
||||||
int nbTabs;
|
int nbTabs;
|
||||||
int nbRules;
|
int nbRules;
|
||||||
JSpinner nbIterations,itSpinner;
|
public JSpinner itSpinner;
|
||||||
JTextField axiomeField,rulesField;
|
JTextField axiomeField,rulesField;
|
||||||
JTextArea axiomList,rulesList;;
|
JTextArea axiomList,rulesList;;
|
||||||
JButton submitButton, close;
|
JButton submitButton, close;
|
||||||
@ -22,12 +22,10 @@ public class Tab extends JPanel{
|
|||||||
axiomList = textArea("Axiome : \n",nbTabs);
|
axiomList = textArea("Axiome : \n",nbTabs);
|
||||||
rulesList = textArea("Règles : \n",nbTabs+10);
|
rulesList = textArea("Règles : \n",nbTabs+10);
|
||||||
|
|
||||||
nbIterations = new JSpinner();
|
|
||||||
nbIterations.setModel(new SpinnerNumberModel(1, 1, 15, 1));
|
|
||||||
|
|
||||||
JLabel itLabel = new JLabel("Nombre d'itérations : ");
|
JLabel itLabel = new JLabel("Nombre d'itérations : ");
|
||||||
itSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 30, 1));
|
itSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 30, 1));
|
||||||
((JSpinner.DefaultEditor) itSpinner.getEditor()).getTextField().setEditable(false);
|
((JSpinner.DefaultEditor) itSpinner.getEditor()).getTextField().setEditable(false);
|
||||||
|
itSpinner.addMouseWheelListener(new Listener(null,null,"Spinner",this));
|
||||||
|
|
||||||
JLabel axiome = new JLabel("Axiome :");
|
JLabel axiome = new JLabel("Axiome :");
|
||||||
JLabel rules = new JLabel("Règle "+ nbRules+" :");
|
JLabel rules = new JLabel("Règle "+ nbRules+" :");
|
||||||
|
Loading…
Reference in New Issue
Block a user