From: <ton...@us...> - 2008-02-01 06:38:07
|
Revision: 481 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=481&view=rev Author: tonytacker Date: 2008-01-31 22:38:03 -0800 (Thu, 31 Jan 2008) Log Message: ----------- implement JMenu for later open/save config Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-01 05:28:50 UTC (rev 480) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-01 06:38:03 UTC (rev 481) @@ -76,19 +76,20 @@ } - public void update(Component component, Class<? extends Component> componentOption) { + public void update(Component component, + Class<? extends Component> componentOption) { this.componentOption = componentOption; this.component = component; showWidgets(); } /* - * define here what core.config.class is what type of widget - * WidgetPanelDefault is for none defined classes + * Define here what core.config.class is what type of widget. + * WidgetPanelDefault is for none defined classes. */ private void showWidgets() { JPanel widgetPanel; - optionList = ComponentManager.getConfigOptions(componentOption); + optionList = ComponentManager.getConfigOptions(componentOption); centerPanel.removeAll(); // clear panel for (int i = 0; i < optionList.size(); i++) { buildConstraints(constraints, 0, i, 1, 1, 0, 0); @@ -105,9 +106,9 @@ widgetPanel = new WidgetPanelDouble(config, component, componentOption, optionList.get(i)); } else if (optionList.get(i).getClass().toString().contains( - "StringConfigOption")) { - widgetPanel = new WidgetPanelString(config, component, - componentOption, optionList.get(i)); + "StringConfigOption")) { + widgetPanel = new WidgetPanelString(config, component, + componentOption, optionList.get(i)); } else { widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-01 05:28:50 UTC (rev 480) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-01 06:38:03 UTC (rev 481) @@ -22,6 +22,9 @@ import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -33,25 +36,31 @@ * @author Tilo Hielscher * */ +public class StartGUI extends JFrame implements ActionListener { -public class StartGUI extends JFrame { - private static final long serialVersionUID = -739265982906533775L; - public JTabbedPane tabPane = new JTabbedPane(); + private JTabbedPane tabPane = new JTabbedPane(); + private Config config = new Config(); + private JPanel tab1 = new JPanel(); private JPanel tab2 = new JPanel(); private JPanel tab3 = new JPanel(); private JPanel tab4 = new JPanel(); private JPanel tab5 = new JPanel(); + private JMenuBar menuBar = new JMenuBar(); + private JMenu menuFile = new JMenu("File"); + private JMenuItem openItem = new JMenuItem("Open Config"); + private JMenuItem saveItem = new JMenuItem("Save Config"); + public StartGUI() { - Config config = new Config(); this.setTitle("DL-Learner GUI"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationByPlatform(true); this.setSize(800, 600); + tab1.add(new KnowledgeSourcePanel(config)); tab2.add(new ReasonerPanel(config)); tab3.add(new LearningProblemPanel(config)); @@ -62,6 +71,14 @@ tabPane.addTab("Learning Problem", tab3); tabPane.addTab("Learning Algorithm", tab4); tabPane.addTab("Run", tab5); + + this.setJMenuBar(menuBar); + menuBar.add(menuFile); + menuFile.add(openItem); + openItem.addActionListener(this); + menuFile.add(saveItem); + saveItem.addActionListener(this); + this.add(tabPane); this.setVisible(true); } @@ -78,8 +95,13 @@ new StartGUI(); } - protected void renew() { - tabPane.repaint(); + public void actionPerformed(ActionEvent e) { + if (e.getSource() == openItem) { + System.out.println("openItem was pressed"); + } + if (e.getSource() == saveItem) { + System.out.println("saveItem was pressed"); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |