completing MainFrame

This commit is contained in:
Arthur 2021-02-11 11:38:06 +01:00
parent c09383a121
commit d9078685d5

View File

@ -3,6 +3,7 @@ package jogl;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -10,7 +11,10 @@ import javax.swing.JButton;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane; import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToolBar; import javax.swing.JToolBar;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
@ -25,9 +29,12 @@ public class MainFrame extends JFrame implements ActionListener{
private JButton newGen; private JButton newGen;
private JButton help; private JButton help;
private JButton close; private JButton close;
private int nbRules;
public MainFrame(){ public MainFrame(){
nbRules = 1;
nbTabs = 0; nbTabs = 0;
basePanel = new JPanel(); basePanel = new JPanel();
basePanel.setLayout(new FlowLayout(FlowLayout.CENTER)); basePanel.setLayout(new FlowLayout(FlowLayout.CENTER));
@ -58,23 +65,64 @@ public class MainFrame extends JFrame implements ActionListener{
newHelp(); newHelp();
else if(e.getSource() == close) else if(e.getSource() == close)
closeTab(); closeTab();
else
throw new Error("This event does not trigger any action");
} }
public void newHelp() { public void newHelp() {
JPanel helpTab = new JPanel(); JPanel helpTab = new JPanel();
JLabel helpText = new JLabel(); JTextArea helpText = new JTextArea();
helpText.setText("Aled"); helpText.setEditable(false);
helpText.setText(new Help().getHelp());
helpTab.add(helpText); helpTab.add(helpText);
tabs.addTab("Oskour",helpTab); tabs.addTab("Aide",(new JScrollPane(helpTab)));
} }
public void newTab() { public void newTab() {
nbTabs ++; nbTabs ++;
JPanel tab = new JPanel(); JPanel tab = new JPanel();
JTextArea axiomList = new JTextArea();
axiomList.setEditable(false);
axiomList.setText("Axiome : \n");
JTextArea rulesList = new JTextArea();
rulesList.setEditable(false);
rulesList.setText("Règles : \n");
JLabel axiome = new JLabel("Axiome");
JLabel rules = new JLabel("Règle "+nbRules);
JTextField axiomeField = new JTextField();
JTextField rulesField = new JTextField();
tab.add(axiome);
tab.add(axiomeField);
tab.add(axiomList);
tab.add(rules);
tab.add(rulesField);
tab.add(rulesList);
tab.setLayout(new GridLayout(2,3));
tabs.addTab("Génération"+String.valueOf(nbTabs), tab); tabs.addTab("Génération"+String.valueOf(nbTabs), tab);
} }
public void closeTab() { public void closeTab() {
//TODO : Pour fermer un onglet, nécessite l'implémentation d'un button fermer grâce à la méthode newTab().
}
public void changeList(String stringToAdd, byte messageType, JTextArea list) {
if (stringToAdd == null) {
switch(messageType) {
case 0:
list.setText("Axiome : \n");
case 1:
list.setText("Règles : \n");
default:
throw new Error("Wrong argument given to method changeList");
}
}else{
list.append("-> "+stringToAdd + "\n");
}
}
public void sendRule(){
//TODO : send the string contain into a JTextField into the JTextAre ruleList or axiomList
} }
} }