public class Main extends JFrame { Main() { Main x=new Main(); Other.a=x; } } public class Other extends JFrame { static Main a; Other() { a.dispose(); } }
/** * Create the singleton instance of the Main GUI. * * @param args commandline options */ public static void createSingleton(String[] args) { if (m_MainSingleton == null) { m_MainSingleton = new Main(); } // set options try { m_MainSingleton.setOptions(args); } catch (Exception e) { e.printStackTrace(); } // notify listeners (if any) for (int i = 0; i < m_StartupListeners.size(); i++) { m_StartupListeners.elementAt(i).startUpComplete(); } }
@Override public void actionPerformed(ActionEvent evt) { String title = jMenuItemApplicationsExplorer.getText(); if (!containsWindow(title)) { createFrame(m_Self, title, new Explorer(), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true); } else { showWindow(getWindow(title)); } } });
createTitle(""); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource( "weka/gui/weka_icon_new_48.png")).getImage()); "weka/gui/images/weka_background.gif"); jDesktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); setContentPane(jDesktopPane); } else { jDesktopPane = null; setJMenuBar(jMenuBar); submenu = new JMenu(ext.getSubmenuTitle()); submenus.put(ext.getSubmenuTitle(), submenu); insertMenuItem(jMenuExtensions, submenu); insertMenuItem(submenu, menuitem); } else { insertMenuItem(jMenuExtensions, menuitem); int screenHeight = getGraphicsConfiguration().getBounds().height; int screenWidth = getGraphicsConfiguration().getBounds().width; if (m_GUIType == GUI_MDI) { int newHeight = (int) ((screenHeight) * 0.75); int newWidth = (int) ((screenWidth) * 0.75); setSize(1000 > newWidth ? newWidth : 1000, 800 > newHeight ? newHeight : 800); setLocation((screenWidth - getBounds().width) / 2,
System.out.println(); Enumeration<Option> enu = new Main().listOptions(); while (enu.hasMoreElements()) { Option option = enu.nextElement(); Main.addStartupListener(new weka.gui.beans.StartUpListener() { @Override public void startUpComplete() { Main.addStartupListener(new StartUpListener() { @Override public void startUpComplete() {
/** * de-registers the child frame with the parent first. */ @Override public void dispose() { if (getParentFrame() != null) { getParentFrame().removeChildFrame(this); getParentFrame().createTitle(""); } super.dispose(); } }
@Override public void actionPerformed(ActionEvent evt) { // close all children Iterator<Container> iter = getWindowList(); Vector<Container> list = new Vector<Container>(); while (iter.hasNext()) { list.add(iter.next()); } for (int i = 0; i < list.size(); i++) { Container c = list.get(i); if (c instanceof ChildFrameMDI) { ((ChildFrameMDI) c).dispose(); } else if (c instanceof ChildFrameSDI) { ((ChildFrameSDI) c).dispose(); } } // close logwindow m_LogWindow.dispose(); // close main window m_Self.dispose(); // make sure we stop System.exit(0); } });
@Override public void actionPerformed(ActionEvent e) { Component frame = createFrame(m_Self, finalMenuitem.getText(), null, null, null, -1, -1, null, false, false); finalExt.fillFrame(frame); frame.setVisible(true); } });
/** * constructs a new internal frame that knows about its parent. * * @param parent the parent frame * @param title the title of the frame */ public ChildFrameSDI(Main parent, String title) { super(title); m_Parent = parent; addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent e) { // update title of parent if (getParentFrame() != null) { getParentFrame().createTitle(getTitle()); } } }); // add to parent if (getParentFrame() != null) { getParentFrame().addChildFrame(this); setIconImage(getParentFrame().getIconImage()); } }
@Override public void windowActivated(WindowEvent e) { // update title of parent if (getParentFrame() != null) { getParentFrame().createTitle(getTitle()); } } });
/** * is called when window list changed somehow (add or remove). */ public void windowListChanged() { createWindowMenu(); }
/** * constructs a new internal frame that knows about its parent. * * @param parent the parent frame * @param title the title of the frame */ public ChildFrameMDI(Main parent, String title) { super(title, true, true, true, true); m_Parent = parent; addInternalFrameListener(new InternalFrameAdapter() { @Override public void internalFrameActivated(InternalFrameEvent e) { // update title of parent if (getParentFrame() != null) { getParentFrame().createTitle(getTitle()); } } }); // add to parent if (getParentFrame() != null) { getParentFrame().addChildFrame(this); getParentFrame().jDesktopPane.add(this); } }
@Override public void actionPerformed(ActionEvent evt) { String title = jMenuItemApplicationsExperimenter.getText(); if (!containsWindow(title)) { createFrame(m_Self, title, new Experimenter(false), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true); } else { showWindow(getWindow(title)); } } });
createTitle(""); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource( "weka/gui/weka_icon_new_48.png")).getImage()); "weka/gui/images/weka_background.gif"); jDesktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); setContentPane(jDesktopPane); } else { jDesktopPane = null; setJMenuBar(jMenuBar); submenu = new JMenu(ext.getSubmenuTitle()); submenus.put(ext.getSubmenuTitle(), submenu); insertMenuItem(jMenuExtensions, submenu); insertMenuItem(submenu, menuitem); } else { insertMenuItem(jMenuExtensions, menuitem); int screenHeight = getGraphicsConfiguration().getBounds().height; int screenWidth = getGraphicsConfiguration().getBounds().width; if (m_GUIType == GUI_MDI) { int newHeight = (int) ((screenHeight) * 0.75); int newWidth = (int) ((screenWidth) * 0.75); setSize(1000 > newWidth ? newWidth : 1000, 800 > newHeight ? newHeight : 800); setLocation((screenWidth - getBounds().width) / 2,
System.out.println(); Enumeration<Option> enu = new Main().listOptions(); while (enu.hasMoreElements()) { Option option = enu.nextElement(); Main.addStartupListener(new weka.gui.beans.StartUpListener() { @Override public void startUpComplete() { Main.addStartupListener(new StartUpListener() { @Override public void startUpComplete() {
/** * de-registers the child frame with the parent first. */ @Override public void dispose() { if (getParentFrame() != null) { getParentFrame().removeChildFrame(this); getParentFrame().createTitle(""); } super.dispose(); } }
@Override public void actionPerformed(ActionEvent evt) { // close all children Iterator<Container> iter = getWindowList(); Vector<Container> list = new Vector<Container>(); while (iter.hasNext()) { list.add(iter.next()); } for (int i = 0; i < list.size(); i++) { Container c = list.get(i); if (c instanceof ChildFrameMDI) { ((ChildFrameMDI) c).dispose(); } else if (c instanceof ChildFrameSDI) { ((ChildFrameSDI) c).dispose(); } } // close logwindow m_LogWindow.dispose(); // close main window m_Self.dispose(); // make sure we stop System.exit(0); } });
@Override public void actionPerformed(ActionEvent e) { Component frame = createFrame(m_Self, finalMenuitem.getText(), null, null, null, -1, -1, null, false, false); finalExt.fillFrame(frame); frame.setVisible(true); } });
/** * constructs a new internal frame that knows about its parent. * * @param parent the parent frame * @param title the title of the frame */ public ChildFrameSDI(Main parent, String title) { super(title); m_Parent = parent; addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent e) { // update title of parent if (getParentFrame() != null) { getParentFrame().createTitle(getTitle()); } } }); // add to parent if (getParentFrame() != null) { getParentFrame().addChildFrame(this); setIconImage(getParentFrame().getIconImage()); } }