First close tab button implementation
This commit is contained in:
parent
5bc68bc127
commit
bbc74e1513
@ -33,6 +33,14 @@ public class Listener implements ActionListener, KeyListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (type) {
|
||||
case "Close":
|
||||
frame.getTab().removeTabAt(index-1);
|
||||
frame.decreaseTab();
|
||||
for(int i = 0; i <frame.getTab().getComponentCount(); i++){
|
||||
frame.getTab().setTitleAt(i,"Génération"+(i+1));
|
||||
}
|
||||
|
||||
break;
|
||||
case "Help":
|
||||
frame.newHelp();
|
||||
break;
|
||||
|
@ -47,8 +47,13 @@ public class MainFrame extends JFrame {
|
||||
this.setPreferredSize(new Dimension(640,600));
|
||||
|
||||
nbTabs++;
|
||||
new Tab(nbTabs, nbRules, tabs);
|
||||
// test
|
||||
new Tab(nbTabs, nbRules, tabs,this);
|
||||
}
|
||||
public JTabbedPane getTab(){
|
||||
return tabs;
|
||||
}
|
||||
public void decreaseTab(){
|
||||
nbTabs -=1;
|
||||
}
|
||||
|
||||
public void newHelp() {
|
||||
@ -88,7 +93,7 @@ public class MainFrame extends JFrame {
|
||||
JOptionPane.showMessageDialog(null, "Nombre maximal de générations atteintes");
|
||||
else {
|
||||
nbTabs++;
|
||||
new Tab(nbTabs, nbRules, tabs);
|
||||
new Tab(nbTabs, nbRules, tabs,this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,15 +8,12 @@ public class Tab extends JPanel{
|
||||
|
||||
int nbTabs;
|
||||
int nbRules;
|
||||
JSpinner nbIterations;
|
||||
JTextField axiomeField;
|
||||
JTextField rulesField;
|
||||
JTextArea axiomList;
|
||||
JTextArea rulesList;
|
||||
JSpinner itSpinner;
|
||||
JButton submitButton;
|
||||
JSpinner nbIterations,itSpinner;
|
||||
JTextField axiomeField,rulesField;
|
||||
JTextArea axiomList,rulesList;;
|
||||
JButton submitButton, close;
|
||||
|
||||
public Tab(int nbTabs,int nbRules,JTabbedPane tabs) {
|
||||
public Tab(int nbTabs,int nbRules,JTabbedPane tabs,MainFrame frame) {
|
||||
this.nbRules = nbRules;
|
||||
this.nbTabs = nbTabs;
|
||||
|
||||
@ -72,6 +69,11 @@ public class Tab extends JPanel{
|
||||
tab.add(southComponents);
|
||||
tab.setLayout(new BoxLayout(tab,1));
|
||||
|
||||
close = new JButton("Close");
|
||||
close.addActionListener(new Listener(frame,nbTabs,"Close",this));
|
||||
tab.add(close);
|
||||
|
||||
|
||||
tabs.addTab("Génération"+String.valueOf(nbTabs), tab);
|
||||
}
|
||||
public JTextArea textArea(String texte, int nb){
|
||||
|
Loading…
Reference in New Issue
Block a user