This commit is contained in:
Arthur 2021-04-13 15:57:01 +02:00
parent e991f4ff6c
commit 002653ada9
3 changed files with 19 additions and 13 deletions

View File

@ -33,7 +33,6 @@ public class Listener implements ActionListener, KeyListener, MouseWheelListener
case "Close":
Component selected = frame.tabs.getSelectedComponent();
if (selected != null) {
frame.tabs.remove(selected);
}
frame.decreaseTab();
@ -150,7 +149,7 @@ public class Listener implements ActionListener, KeyListener, MouseWheelListener
byte i = (byte) ((type.equals("Axiome")) ? 0 : 1);
if(nbAxioms==0 && ke.getKeyChar() !='\b')
if(nbAxioms==0 && ke.getKeyCode() != KeyEvent.VK_BACK_SPACE)
tab.changeList(String.valueOf(ke.getKeyChar()), tab.getTextArea(i),nbAxioms);
if(ke.getKeyChar() == '\b'){
String str = tab.getTextArea(i).getText();

View File

@ -21,7 +21,6 @@ public class MainFrame extends JFrame {
private final JButton help;
private final int nbRules;
public MainFrame(){
nbRules = 1;

View File

@ -1,7 +1,9 @@
package lsystem.screen.main;
import javax.swing.*;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;
import java.awt.event.ActionListener;
import java.util.Arrays;
public class Tab extends JPanel{
@ -17,8 +19,6 @@ public class Tab extends JPanel{
this.nbRules = nbRules;
this.nbTabs = nbTabs;
JPanel tab = new JPanel();
axiomList = textArea("Axiome : \n",nbTabs);
rulesList = textArea("Règles : \n",nbTabs+10);
@ -65,17 +65,17 @@ public class Tab extends JPanel{
aboveComponents.add(lists);
aboveComponents.add(Iterations);
aboveComponents.setLayout(new GridLayout(1,4));
tab.add(aboveComponents);
tab.add(southComponents2);
tab.setLayout(new BoxLayout(tab,1));
close = new JButton("Close");
close.addActionListener(new Listener(frame,this.nbTabs,"Close",this));
tab.add(close);
this.add(aboveComponents);
this.add(southComponents2);
this.setLayout(new BoxLayout(this,1));
this.add(new JButton("Close"));
tabs.addTab("Génération"+String.valueOf(nbTabs), tab);
tabs.addTab("Génération"+String.valueOf(nbTabs),this);
}
public JTextArea textArea(String texte, int nb){
JTextArea res = new JTextArea();
@ -129,4 +129,12 @@ public class Tab extends JPanel{
public int getNbIterations(){
return (int) itSpinner.getValue();
}
public JButton closeButton(MainFrame frame) {
close = new JButton("Close");
int size = 17;
close.setPreferredSize(new Dimension(size, size));
close.addActionListener(new Listener(frame,this.nbTabs,"Close",this));
return close;
}
}