diff --git a/src/jogl/MainFrame.java b/src/jogl/MainFrame.java index 58ccddf..259608f 100644 --- a/src/jogl/MainFrame.java +++ b/src/jogl/MainFrame.java @@ -3,6 +3,7 @@ package jogl; import java.awt.BorderLayout; import java.awt.FlowLayout; +import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -10,7 +11,10 @@ import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; import javax.swing.JToolBar; import javax.swing.SwingConstants; @@ -25,9 +29,12 @@ public class MainFrame extends JFrame implements ActionListener{ private JButton newGen; private JButton help; private JButton close; + private int nbRules; public MainFrame(){ + + nbRules = 1; nbTabs = 0; basePanel = new JPanel(); basePanel.setLayout(new FlowLayout(FlowLayout.CENTER)); @@ -58,23 +65,64 @@ public class MainFrame extends JFrame implements ActionListener{ newHelp(); else if(e.getSource() == close) closeTab(); + else + throw new Error("This event does not trigger any action"); } public void newHelp() { JPanel helpTab = new JPanel(); - JLabel helpText = new JLabel(); - helpText.setText("Aled"); + JTextArea helpText = new JTextArea(); + helpText.setEditable(false); + helpText.setText(new Help().getHelp()); helpTab.add(helpText); - tabs.addTab("Oskour",helpTab); + tabs.addTab("Aide",(new JScrollPane(helpTab))); } public void newTab() { + nbTabs ++; 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); } 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 } }