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 java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.*;
|
||||
import java.util.List;
|
||||
|
||||
public class Listener implements ActionListener, KeyListener {
|
||||
public class Listener implements ActionListener, KeyListener, MouseWheelListener {
|
||||
Tab tab;
|
||||
MainFrame frame;
|
||||
Integer index;
|
||||
@ -36,7 +33,7 @@ public class Listener implements ActionListener, KeyListener {
|
||||
case "Close":
|
||||
frame.getTab().removeTabAt(index-1);
|
||||
frame.decreaseTab();
|
||||
for(int i = 0; i <frame.getTab().getComponentCount(); i++){
|
||||
for(int i = 0; i < frame.getTab().getComponentCount(); i++){
|
||||
frame.getTab().setTitleAt(i,"Génération"+(i+1));
|
||||
}
|
||||
|
||||
@ -145,4 +142,12 @@ public class Listener implements ActionListener, KeyListener {
|
||||
public void resetNbAxioms(){
|
||||
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 nbRules;
|
||||
JSpinner nbIterations,itSpinner;
|
||||
public JSpinner itSpinner;
|
||||
JTextField axiomeField,rulesField;
|
||||
JTextArea axiomList,rulesList;;
|
||||
JButton submitButton, close;
|
||||
@ -22,12 +22,10 @@ public class Tab extends JPanel{
|
||||
axiomList = textArea("Axiome : \n",nbTabs);
|
||||
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 : ");
|
||||
itSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 30, 1));
|
||||
((JSpinner.DefaultEditor) itSpinner.getEditor()).getTextField().setEditable(false);
|
||||
itSpinner.addMouseWheelListener(new Listener(null,null,"Spinner",this));
|
||||
|
||||
JLabel axiome = new JLabel("Axiome :");
|
||||
JLabel rules = new JLabel("Règle "+ nbRules+" :");
|
||||
|
Loading…
Reference in New Issue
Block a user