Java Examples for javax.swing.JDesktopPane

The following java examples will help you to understand the usage of javax.swing.JDesktopPane. These source code samples are taken from different open source projects.

Example 1
Project: HUSACCT-master  File: MainGui.java View source code
private void addComponents() {
    // Create and add contentPane
    JPanel contentPane = new JPanel(new BorderLayout());
    actionLogPanel = new ActionLogPanel(mainController);
    contentPane.add(actionLogPanel, BorderLayout.SOUTH);
    //toolBar = new ToolBar(getMenu(), mainController.getStateController()); // Disabled since it takes space and does not add much.
    //contentPane.add(toolBar, BorderLayout.NORTH);
    desktopPane = new JDesktopPane();
    desktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    contentPane.add(desktopPane, BorderLayout.CENTER);
    add(contentPane);
    // Create and add taskBarPane
    taskBar = new TaskBar();
    taskBarPane = new TaskBarPane(taskBar);
    taskBarPane.setBackground(PANELBACKGROUND);
    add(taskBarPane);
}
Example 2
Project: com.opendoorlogistics-master  File: ODLInternalFrame.java View source code
public void run() {
    try {
        InitialiseStudio.initialise(false);
        JFrame outer = new JFrame();
        outer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JDesktopPane pane = new JDesktopPane();
        pane.add(frame);
        frame.setVisible(true);
        outer.setContentPane(pane);
        outer.setVisible(true);
        frame.toFront();
        outer.setMinimumSize(new Dimension(600, 600));
        outer.pack();
        // frame doesn't appear without a set bounds...
        frame.setBounds(50, 50, 200, 200);
    // frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    // frame.getFrame().setVisible(true);
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Example 3
Project: openflexo-master  File: MultipleEditorsOneToolbar.java View source code
/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
private void initComponents() {
    //GEN-BEGIN:initComponents
    jDesktopPane1 = new javax.swing.JDesktopPane();
    internalFrame1 = new javax.swing.JInternalFrame();
    internalFrame2 = new javax.swing.JInternalFrame();
    toolbarPanel = new javax.swing.JPanel();
    addWindowListener(new java.awt.event.WindowAdapter() {

        public void windowClosing(java.awt.event.WindowEvent evt) {
            exitForm(evt);
        }
    });
    internalFrame1.setResizable(true);
    internalFrame1.setVisible(true);
    internalFrame1.setBounds(90, 130, 270, 140);
    jDesktopPane1.add(internalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);
    internalFrame2.setResizable(true);
    internalFrame2.setVisible(true);
    internalFrame2.setBounds(20, 10, 290, 130);
    jDesktopPane1.add(internalFrame2, javax.swing.JLayeredPane.DEFAULT_LAYER);
    getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER);
    toolbarPanel.setLayout(new java.awt.GridLayout(2, 1));
    getContentPane().add(toolbarPanel, java.awt.BorderLayout.NORTH);
    pack();
}
Example 4
Project: jnode-master  File: JNodeToolkit.java View source code
@Override
public Insets getScreenInsets(GraphicsConfiguration gc) throws HeadlessException {
    JNodeAwtContext awtc = getAwtContext();
    if (awtc == null)
        return super.getScreenInsets(gc);
    Component root = awtc.getTopLevelRootComponent();
    if (root == null)
        return super.getScreenInsets(gc);
    JDesktopPane jdp = awtc.getDesktop();
    if (jdp == null)
        return super.getScreenInsets(gc);
    Rectangle trc_bounds = root.getBounds();
    Point jdp_loc = jdp.getLocationOnScreen();
    Rectangle jdp_bounds = jdp.getBounds();
    return new Insets(jdp_loc.y, jdp_loc.x, trc_bounds.height - jdp_loc.y - jdp_bounds.height, trc_bounds.width - jdp_loc.x - jdp_bounds.width);
}
Example 5
Project: JWildfire-master  File: JWildfire.java View source code
private JDesktopPane getMainDesktopPane() {
    if (mainDesktopPane == null) {
        mainDesktopPane = createMainDesktopPane();
        for (InternalFrameHolder<?> internalFrame : mainInternalFrames) {
            mainDesktopPane.add(internalFrame.getInternalFrame());
        }
        getInternalFrame(NavigatorInternalFrame.class).setDesktop(this);
        TinaInternalFrame tinaInternalFrame = getInternalFrame(TinaInternalFrame.class);
        tinaInternalFrame.addComponentListener(new java.awt.event.ComponentAdapter() {

            public void componentResized(java.awt.event.ComponentEvent e) {
                tinaController.refreshFlameImage(true, false, 1, true, false);
            }
        });
        if (!tinaInternalFrame.isVisible()) {
            tinaInternalFrame.setVisible(true);
        }
        for (InternalFrameHolder<?> internalFrame : settingsInternalFrames) {
            mainDesktopPane.add(internalFrame.getInternalFrame());
        }
        for (InternalFrameHolder<?> internalFrame : helpInternalFrames) {
            mainDesktopPane.add(internalFrame.getInternalFrame());
        }
        errorHandler = new StandardErrorHandler(mainDesktopPane, getShowErrorDlg(), getShowErrorDlgMessageTextArea(), getShowErrorDlgStacktraceTextArea());
        NavigatorInternalFrame navigatorInternalFrame = getInternalFrame(NavigatorInternalFrame.class);
        if (!navigatorInternalFrame.isVisible()) {
            navigatorInternalFrame.setVisible(true);
        }
        navigatorInternalFrame.moveToFront();
        /*
            WelcomeInternalFrame welcomeInternalFrame = getInternalFrame(WelcomeInternalFrame.class);
            if (!welcomeInternalFrame.isVisible()) {
              welcomeInternalFrame.setVisible(true);
            }
            welcomeInternalFrame.moveToFront();
      */
        TipOfTheDayInternalFrame tipOfTheDayInternalFrame = getInternalFrame(TipOfTheDayInternalFrame.class);
        if (!tipOfTheDayInternalFrame.isVisible() && Prefs.getPrefs().isShowTipsAtStartup()) {
            tipOfTheDayInternalFrame.setVisible(true);
        }
        tipOfTheDayInternalFrame.moveToFront();
        try {
            getInternalFrame(ListOfChangesInternalFrame.class).initChangesPane();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        try {
            getInternalFrame(GPURenderInfoInternalFrame.class).initChangesPane();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        MutaGenInternalFrame mutaGenFrame = getInternalFrame(MutaGenInternalFrame.class);
        FlameBrowserInternalFrame flameBrowserFrame = getInternalFrame(FlameBrowserInternalFrame.class);
        EasyMovieMakerInternalFrame easyMovieMakerFrame = getInternalFrame(EasyMovieMakerInternalFrame.class);
        DancingFlamesInternalFrame dancingFlamesFrame = getInternalFrame(DancingFlamesInternalFrame.class);
        BatchFlameRendererInternalFrame batchFlameRendererFrame = getInternalFrame(BatchFlameRendererInternalFrame.class);
        MeshGenInternalFrame meshGenFrame = getInternalFrame(MeshGenInternalFrame.class);
        InteractiveRendererInternalFrame interactiveRendererFrame = getInternalFrame(InteractiveRendererInternalFrame.class);
        // create some unregistered window even when FACLRender is not available, in order to avoid further null-checks etc.
        FlamesGPURenderInternalFrame gpuRendererFrame = FACLRenderTools.isFaclRenderAvalailable() ? getInternalFrame(FlamesGPURenderInternalFrame.class) : new FlamesGPURenderInternalFrame();
        HelpInternalFrame helpFrame = getInternalFrame(HelpInternalFrame.class);
        TinaInternalFrame tinaFrame = getInternalFrame(TinaInternalFrame.class);
        tinaController = tinaFrame.createController(this, errorHandler, prefs, mutaGenFrame, flameBrowserFrame, easyMovieMakerFrame, dancingFlamesFrame, batchFlameRendererFrame, meshGenFrame, interactiveRendererFrame, gpuRendererFrame, helpFrame);
        try {
            RandomFlameGenerator randGen = RandomFlameGeneratorList.getRandomFlameGeneratorInstance(RandomFlameGeneratorList.DEFAULT_GENERATOR_NAME, true);
            if (randGen instanceof AllRandomFlameGenerator) {
                ((AllRandomFlameGenerator) randGen).setUseSimpleGenerators(true);
            }
            RandomSymmetryGenerator randSymmGen = RandomSymmetryGeneratorList.getRandomSymmetryGeneratorInstance(RandomSymmetryGeneratorList.DEFAULT_GENERATOR_NAME, true);
            RandomGradientGenerator randGradientGen = RandomGradientGeneratorList.getRandomGradientGeneratorInstance((RandomGradientGeneratorList.DEFAULT_GENERATOR_NAME), true);
            tinaController.createRandomBatch(2, randGen, randSymmGen, randGradientGen, RandomBatchQuality.LOW);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        flameBrowserFrame.setTinaController(tinaController);
        mutaGenFrame.setTinaController(tinaController);
        easyMovieMakerFrame.setTinaController(tinaController);
        dancingFlamesFrame.setTinaController(tinaController);
        batchFlameRendererFrame.setTinaController(tinaController);
        meshGenFrame.setTinaController(tinaController);
        interactiveRendererFrame.setTinaController(tinaController);
        gpuRendererFrame.setTinaController(tinaController);
        helpFrame.setTinaController(tinaController);
        FormulaExplorerInternalFrame formulaExplorerFrame = getInternalFrame(FormulaExplorerInternalFrame.class);
        formulaExplorerController = new FormulaExplorerController((FormulaPanel) formulaExplorerFrame.getFormulaPanel(), formulaExplorerFrame.getFormulaExplorerFormula1REd(), formulaExplorerFrame.getFormulaExplorerFormula2REd(), formulaExplorerFrame.getFormulaExplorerFormula3REd(), formulaExplorerFrame.getFormulaExplorerFormulaXMinREd(), formulaExplorerFrame.getFormulaExplorerFormulaXMaxREd(), formulaExplorerFrame.getFormulaExplorerFormulaXCountREd(), formulaExplorerFrame.getFormulaExplorerValuesTextArea());
        OperatorsInternalFrame operatorsFrame = getInternalFrame(OperatorsInternalFrame.class);
        operatorsFrame.setDesktop(this);
        PreferencesInternalFrame preferencesFrame = getInternalFrame(PreferencesInternalFrame.class);
        preferencesFrame.setDesktop(this);
        preferencesFrame.setPrefs(prefs);
        preferencesFrame.setMainController(mainController);
        mainController = new MainController(prefs, errorHandler, mainDesktopPane, getWindowMenu(), operatorsFrame.getTransformerInputCmb(), operatorsFrame.getTransformerPresetCmb(), operatorsFrame.getCreatorPresetCmb(), getShowMessageDlg(), getShowMessageDlgTextArea(), null, null, null, null, null, null, null, mainInternalFrames.size());
        /*
      EDENInternalFrame edenFrame = (EDENInternalFrame) getEDENInternalFrame();
      edenFrame.createController(mainController, errorHandler, prefs).newEmptyScene();
      */
        IFlamesInternalFrame iflamesInternalFrame = getInternalFrame(IFlamesInternalFrame.class);
        iflamesInternalFrame.createController(mainController, tinaController, errorHandler);
        tinaController.setMainController(mainController);
        operatorsFrame.setMainController(mainController);
        formulaExplorerFrame.setMainController(mainController);
        formulaExplorerFrame.setFormulaExplorerController(formulaExplorerController);
    }
    try {
        getInternalFrame(WelcomeInternalFrame.class).setSelected(true);
    } catch (PropertyVetoException ex) {
        ex.printStackTrace();
    }
    return mainDesktopPane;
}
Example 6
Project: openjdk-master  File: JInternalFrameOperator.java View source code
/**
     * Initiaites suboperators.
     */
protected void initOperators() {
    iconOperator = new JDesktopIconOperator(((JInternalFrame) getSource()).getDesktopIcon());
    iconOperator.copyEnvironment(this);
    Container titlePane = findTitlePane();
    if (!isIcon() && titlePane != null) {
        if (titleOperator == null) {
            titleOperator = new ContainerOperator<>(titlePane);
            int bttCount = 0;
            if (getContainer(new ComponentChooser() {

                @Override
                public boolean checkComponent(Component comp) {
                    return comp instanceof JDesktopPane;
                }

                @Override
                public String getDescription() {
                    return "Desctop pane";
                }

                @Override
                public String toString() {
                    return "JInternalFrameOperator.initOperators.ComponentChooser{description = " + getDescription() + '}';
                }
            }) != null) {
                minOper = new JButtonOperator(titleOperator, bttCount);
                bttCount++;
                if (((JInternalFrame) getSource()).isMaximizable()) {
                    maxOper = new JButtonOperator(titleOperator, bttCount);
                    bttCount++;
                } else {
                    maxOper = null;
                }
            } else {
                minOper = null;
                maxOper = null;
            }
            if (isClosable()) {
                closeOper = new JButtonOperator(titleOperator, bttCount);
            } else {
                closeOper = null;
            }
        }
    } else {
        titleOperator = null;
        minOper = null;
        maxOper = null;
        closeOper = null;
    }
}
Example 7
Project: openjump-core-rels-master  File: WorkbenchFrame.java View source code
public void addInternalFrame(final JInternalFrame internalFrame, boolean alwaysOnTop, boolean autoUpdateToolBar) {
    if (internalFrame instanceof LayerManagerProxy) {
        setClosingBehaviour((LayerManagerProxy) internalFrame);
        installTitleBarModifiedIndicator((LayerManagerProxy) internalFrame);
    }
    // <<TODO:IMPROVE>> Listen for when the frame closes, and when it does,
    // activate the topmost frame. Because Swing does not seem to do this
    // automatically. [Jon Aquino]
    JUMPWorkbench.setIcon(internalFrame);
    // Call JInternalFrame#setVisible before JDesktopPane#add; otherwise,
    // the
    // TreeLayerNamePanel starts too narrow (100 pixels or so) for some
    // reason.
    // <<TODO>>Investigate. [Jon Aquino]
    internalFrame.setVisible(true);
    desktopPane.add(internalFrame, alwaysOnTop ? JLayeredPane.PALETTE_LAYER : JLayeredPane.DEFAULT_LAYER);
    if (autoUpdateToolBar) {
        internalFrame.addInternalFrameListener(new InternalFrameListener() {

            public void internalFrameActivated(InternalFrameEvent e) {
                toolBar.updateEnabledState();
                // Associate current cursortool with the new frame [Jon
                // Aquino]
                toolBar.reClickSelectedCursorToolButton();
            }

            public void internalFrameClosed(InternalFrameEvent e) {
                toolBar.updateEnabledState();
            }

            public void internalFrameClosing(InternalFrameEvent e) {
                toolBar.updateEnabledState();
            }

            public void internalFrameDeactivated(InternalFrameEvent e) {
                toolBar.updateEnabledState();
            }

            public void internalFrameDeiconified(InternalFrameEvent e) {
                toolBar.updateEnabledState();
            }

            public void internalFrameIconified(InternalFrameEvent e) {
                toolBar.updateEnabledState();
            }

            public void internalFrameOpened(InternalFrameEvent e) {
                toolBar.updateEnabledState();
            }
        });
        // Call #activateFrame *after* adding the listener. [Jon Aquino]
        activateFrame(internalFrame);
        position(internalFrame);
    }
}
Example 8
Project: phresco-master  File: HelloWorld.java View source code
public void initComponents() {
    setTitle("Hello World");
    setResizable(false);
    panel = new JDesktopPane();
    getContentPane().add("Center", panel);
    container.add(panel);
    panel.setBackground(new Color(216, 229, 246));
    panel.setVisible(true);
    panel.setBounds(300, 350, 100, 120);
    lbl_username = new JLabel();
    lbl_username.setText("Hello World");
    Font font = new Font("Arial", 1, 40);
    lbl_username.setFont(font);
    panel.add(lbl_username, JLayeredPane.DEFAULT_LAYER);
    lbl_username.setBounds(550, 450, 500, lbl_username.getPreferredSize().height);
}
Example 9
Project: spring-rich-client-master  File: DefaultDesktopCommandGroupFactory.java View source code
/**
	 * Create a desktop pane context menu CommandGroup.
	 * @return the context menu CommandGroup
	 */
public CommandGroup createContextMenuCommandGroup(CommandManager commandManager, JDesktopPane desktop) {
    CommandGroup commandGroup = new CommandGroup();
    TileCommand tileCommand = new TileCommand(desktop);
    CascadeCommand cascadeCommand = new CascadeCommand(desktop, cascadeOffset, cascadeResizesFrames);
    MinimizeAllCommand minimizeAllCommand = new MinimizeAllCommand(desktop);
    commandManager.configure(tileCommand);
    commandManager.configure(cascadeCommand);
    commandManager.configure(minimizeAllCommand);
    commandGroup.add(tileCommand);
    commandGroup.add(cascadeCommand);
    commandGroup.add(minimizeAllCommand);
    if (desktop.getAllFrames().length > 0) {
        commandGroup.addSeparator();
        // pane instead of the current z-order.
        for (int i = 0; i < desktop.getAllFrames().length; i++) {
            JInternalFrame frame = desktop.getAllFrames()[i];
            ShowFrameCommand showFrameCommand = new ShowFrameCommand(frame);
            showFrameCommand.setIcon(frame.getFrameIcon());
            showFrameCommand.setCaption("" + frame.getTitle());
            String label = i + " " + frame.getTitle();
            if (i < 10) {
                label = "&" + label;
            }
            showFrameCommand.setLabel(label);
            commandGroup.add(showFrameCommand);
        }
    }
    return commandGroup;
}
Example 10
Project: springrcp-master  File: DefaultDesktopCommandGroupFactory.java View source code
/**
	 * Create a desktop pane context menu CommandGroup.
	 * @return the context menu CommandGroup
	 */
public CommandGroup createContextMenuCommandGroup(CommandManager commandManager, JDesktopPane desktop) {
    CommandGroup commandGroup = new CommandGroup();
    TileCommand tileCommand = new TileCommand(desktop);
    CascadeCommand cascadeCommand = new CascadeCommand(desktop, cascadeOffset, cascadeResizesFrames);
    MinimizeAllCommand minimizeAllCommand = new MinimizeAllCommand(desktop);
    commandManager.configure(tileCommand);
    commandManager.configure(cascadeCommand);
    commandManager.configure(minimizeAllCommand);
    commandGroup.add(tileCommand);
    commandGroup.add(cascadeCommand);
    commandGroup.add(minimizeAllCommand);
    if (desktop.getAllFrames().length > 0) {
        commandGroup.addSeparator();
        // pane instead of the current z-order.
        for (int i = 0; i < desktop.getAllFrames().length; i++) {
            JInternalFrame frame = desktop.getAllFrames()[i];
            ShowFrameCommand showFrameCommand = new ShowFrameCommand(frame);
            showFrameCommand.setIcon(frame.getFrameIcon());
            showFrameCommand.setCaption("" + frame.getTitle());
            String label = i + " " + frame.getTitle();
            if (i < 10) {
                label = "&" + label;
            }
            showFrameCommand.setLabel(label);
            commandGroup.add(showFrameCommand);
        }
    }
    return commandGroup;
}
Example 11
Project: Gmote-master  File: PasswordSettingsUi.java View source code
/**
   * This method initializes jDesktopPane
   * 
   * @return javax.swing.JDesktopPane
   */
private JDesktopPane getJDesktopPane() {
    if (jDesktopPane == null) {
        lblPasswordConfirm = new JLabel();
        lblPasswordConfirm.setBounds(new Rectangle(15, 30, 290, 16));
        lblPasswordConfirm.setText("Create a new password for your server:");
        lblPassword = new JLabel();
        lblPassword.setBounds(new Rectangle(15, 60, 290, 15));
        lblPassword.setText("Please re-enter the password to confirm:");
        jDesktopPane = new JDesktopPane();
        jDesktopPane.setName("Settings");
        jDesktopPane.add(lblPassword, null);
        jDesktopPane.add(getJPasswordField(), null);
        jDesktopPane.add(lblPasswordConfirm, null);
        jDesktopPane.add(getJPasswordConfirm(), null);
        jDesktopPane.add(getCmdOk(), null);
        jDesktopPane.add(getCmdCancel(), null);
    }
    return jDesktopPane;
}
Example 12
Project: fest-swing-1.x-master  File: JInternalFrameDesktopPaneQuery_desktopPaneOf_Test.java View source code
@RunsInEDT
private static JDesktopPane setNullIconAndReturnDesktopPane(final JInternalFrame internalFrame) {
    JDesktopPane desktopPane = execute(new GuiQuery<JDesktopPane>() {

        @Override
        protected JDesktopPane executeInEDT() {
            internalFrame.setDesktopIcon(null);
            return JInternalFrameDesktopPaneQuery.desktopPaneOf(internalFrame);
        }
    });
    return desktopPane;
}
Example 13
Project: javabuilders-master  File: IssuesTest.java View source code
@Test
public void issue62_JInternalFrame() {
    BuildResult r = new SwingYamlBuilder("JFrame(name=main,title=Main Frame):") {

        {
            ___("- JDesktopPane(name=desktop):");
            _____("- JInternalFrame(name=frame1,title='Frame 1')");
            _____("- JInternalFrame(name=frame2,title='Frame 2')");
        }
    }.build(this);
    JFrame f = (JFrame) r.getRoot();
    JDesktopPane desktop = (JDesktopPane) f.getContentPane();
    assertNotNull(desktop);
    JInternalFrame frame1 = (JInternalFrame) desktop.getComponent(0);
    assertNotNull(frame1);
    JInternalFrame frame2 = (JInternalFrame) desktop.getComponent(1);
    assertNotNull(frame2);
}
Example 14
Project: DockingFrames-master  File: InternalExample.java View source code
public static void main(String[] args) {
    /* DockingFrames has limited support for JDesktopPane and JInternalFrames. 
		 * This example sets up a frame containing a JInternalFrame and shows how to
		 * configure the framework to support this. */
    /* As usual we need some frame */
    JTutorialFrame frame = new JTutorialFrame(InternalExample.class);
    /* Setting up a new JDesktopPane and a new JInternalFrame, we will add our
		 * content the the JInternalFrame "internalFrame". */
    JDesktopPane desktop = new JDesktopPane();
    frame.add(desktop);
    JInternalFrame internalFrame = new JInternalFrame("Internal");
    internalFrame.setResizable(true);
    desktop.add(internalFrame);
    internalFrame.setBounds(20, 20, 400, 300);
    internalFrame.setVisible(true);
    internalFrame.setLayout(new BorderLayout());
    /* Creating a controller */
    DockController controller = new DockController();
    controller.setRootWindow(frame);
    frame.destroyOnClose(controller);
    /* The ScreenDockStation needs some special factories and strategies to handle 
		 * the JDesktopPane.
		 *  - The boundary restriction ensures that a window cannot be moved out of the desktop
		 *  - The fullscreen strategy tells when a window is in fullscreen mode and when not
		 *  - The window factory creates the windows on which Dockables are shown */
    DockProperties properties = controller.getProperties();
    properties.set(ScreenDockStation.BOUNDARY_RESTRICTION, new InternalBoundaryRestriction(desktop));
    properties.set(ScreenDockStation.FULL_SCREEN_STRATEGY, new InternalFullscreenStrategy(desktop));
    properties.set(ScreenDockStation.WINDOW_FACTORY, new InternalScreenDockWindowFactory(desktop));
    /* Nothing special about the rest of the application, just setting up some stations
		 * and Dockables */
    SplitDockStation center = new SplitDockStation();
    controller.add(center);
    internalFrame.add(center, BorderLayout.CENTER);
    /* The FlapDockStation will recognize and handle the JDesktopPane automatically */
    FlapDockStation north = new FlapDockStation();
    controller.add(north);
    internalFrame.add(north.getComponent(), BorderLayout.NORTH);
    ScreenDockStation screen = new ScreenDockStation(controller.getRootWindowProvider());
    controller.add(screen);
    center.drop(new ColorDockable("Green", Color.GREEN));
    north.drop(new ColorDockable("Red", Color.RED));
    screen.drop(new ColorDockable("Blue", Color.BLUE), new ScreenDockProperty(300, 200, 100, 100));
    /* Now we make all frames and windows visible. */
    frame.setVisible(true);
    screen.setShowing(true);
}
Example 15
Project: gstreamer-java-master  File: SwingMultiPlayerAlpha.java View source code
public void run() {
    JFrame window = new JFrame("Swing Video Player");
    JDesktopPane panel = new JDesktopPane();
    window.add(panel);
    for (int i = files.length - 1; i >= 0; --i) {
        File file = files[i];
        JInternalFrame frame = new JInternalFrame(file.getName());
        panel.add(frame);
        frame.setResizable(true);
        frame.setClosable(true);
        frame.setIconifiable(true);
        frame.setMaximizable(true);
        frame.setLocation(i * 100, i * 100);
        final float alpha = 0.6f;
        final VideoPlayer player = new VideoPlayer(file) {

            private static final long serialVersionUID = 4925431893247320169L;

            @Override
            protected void paintComponent(Graphics g) {
                Graphics2D g2d = (Graphics2D) g.create();
                g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
                g2d.setColor(Color.BLACK);
                g2d.fillRect(0, 0, getWidth(), getHeight());
                g2d.dispose();
            }
        };
        player.setPreferredSize(new Dimension(400, 250));
        player.setControlsVisible(true);
        player.setOpaque(false);
        player.setOpacity(alpha);
        Pipeline pipe = player.getMediaPlayer().getPipeline();
        if (pipe instanceof PlayBin2) {
            ((PlayBin2) pipe).setAudioSink(ElementFactory.make("fakesink", "audio"));
        }
        frame.setOpaque(false);
        frame.setContentPane(player);
        frame.pack();
        frame.setVisible(true);
        javax.swing.Timer timer = new javax.swing.Timer(5000 * i, new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                player.getMediaPlayer().play();
            }
        });
        timer.setRepeats(false);
        timer.start();
    }
    window.setPreferredSize(new Dimension(1024, 768));
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.pack();
    window.setVisible(true);
}
Example 16
Project: gtitool-master  File: ControlPanel.java View source code
private void setupUI() {
    JPanel p0 = new JPanel();
    p0.setBounds(0, 0, preferredSize.width, preferredSize.height);
    // Table
    exampleTable = new JTable(new TinyTableModel());
    exampleTable.setRowSelectionAllowed(true);
    exampleTable.setColumnSelectionAllowed(true);
    exampleTable.setColumnSelectionInterval(2, 2);
    exampleTable.setRowSelectionInterval(0, 2);
    exampleTable.setDefaultRenderer(TinyTableModel.TableColorIcon.class, new IconRenderer());
    JScrollPane sp = new JScrollPane(exampleTable);
    sp.setBounds(10, 10, 192, 132);
    add(sp, JDesktopPane.DEFAULT_LAYER);
    scrollBars[6] = sp;
    // Disabled TabbedPane
    exampleTb = new JTabbedPane();
    exampleTb.add("Disabled", new ContentLabel());
    exampleTb.add("Tabbed", new ContentLabel());
    exampleTb.add("Pane", new ContentLabel());
    exampleTb.setEnabled(false);
    exampleTb.setPreferredSize(new Dimension(180, 60));
    exampleTb.setBounds(210, 40, 180, 60);
    add(exampleTb, JDesktopPane.DEFAULT_LAYER);
    // Internal Frame
    frames = new Component[2];
    internalFrame = new JInternalFrame("InternalFrame", true, true, true, true);
    frames[0] = internalFrame;
    internalFrame.updateUI();
    internalFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    internalFrame.addInternalFrameListener(new InternalFrameAdapter() {

        public void internalFrameClosing(InternalFrameEvent e) {
            String msg = "This internal frame cannot be closed.";
            JOptionPane.showInternalMessageDialog(internalFrame, msg);
            e.getInternalFrame().show();
        }
    });
    internalFrame.getContentPane().add(new SizedPanel(200, 100));
    internalFrame.pack();
    Dimension frameSize = internalFrame.getPreferredSize();
    internalFrame.setBounds(400, 10, frameSize.width, frameSize.height);
    internalFrame.show();
    add(internalFrame, JDesktopPane.PALETTE_LAYER);
    // Palette
    palette = new JInternalFrame("Palette", false, true, true, true);
    frames[1] = palette;
    palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
    palette.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    palette.addInternalFrameListener(new InternalFrameAdapter() {

        public void internalFrameClosing(InternalFrameEvent e) {
            String msg = "This internal palette cannot be closed.";
            JOptionPane.showInternalMessageDialog(palette, msg);
            e.getInternalFrame().show();
        }
    });
    JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
    JButton defaultButton = new JButton("InternalMessageDialog");
    buttons[12] = defaultButton;
    defaultButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JOptionPane.showInternalMessageDialog(palette, "Life is a while(true) loop.");
        }
    });
    palette.getRootPane().setDefaultButton(defaultButton);
    JButton b = new JButton("InternalConfirmDialog ");
    buttons[13] = b;
    b.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JOptionPane.showInternalConfirmDialog(palette, "Is programming art?");
        }
    });
    JPanel p3 = new JPanel(new GridLayout(4, 1));
    p3.add(new JLabel());
    p3.add(defaultButton);
    p3.add(new JLabel());
    p3.add(b);
    p2.add(p3);
    palette.getContentPane().add(p2);
    palette.setBounds(400 + internalFrame.getWidth() + 12, 10, 180, 140);
    palette.show();
    add(palette, JDesktopPane.PALETTE_LAYER);
}
Example 17
Project: jedit_cc4401-master  File: DefaultController.java View source code
/**
     * @param provider
     * @param projectName
     * @param monitor
     */
protected void openView(final Statistics stats, final TaskProgressMonitor monitor) {
    final JavaProject project = stats.getEIG().getJavaProject();
    final List<JSwingRipplesEIGNode> members = getMembers(stats.getEIG());
    monitor.beginTask("Create statistics view", 1);
    final HierarchicalView view;
    try {
        view = new HierarchicalView(project, members);
    } finally {
        monitor.done();
    }
    final JInternalFrame frame = new JInternalFrame(project.getName() + " (" + stats.getId() + ")");
    frame.getContentPane().setLayout(new BorderLayout());
    final JScrollPane comp = new JScrollPane(view);
    comp.getViewport().setBackground(Color.WHITE);
    frame.getContentPane().add(comp);
    final JDesktopPane viewArea = JSwingRipplesApplication.getInstance().getViewArea();
    frame.setBounds(0, 0, viewArea.getWidth(), viewArea.getHeight());
    frame.setClosable(true);
    frame.setMaximizable(true);
    frame.setVisible(true);
    frame.setResizable(true);
    viewArea.add(frame);
}
Example 18
Project: Cooking-to-Goal-master  File: PrintPreviewPanel.java View source code
/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    jScrollPaneOuter = new javax.swing.JScrollPane();
    jDesktopPane1 = new javax.swing.JDesktopPane();
    printPanel = new javax.swing.JScrollPane();
    jToolBar1 = new javax.swing.JToolBar();
    printButton = new javax.swing.JButton();
    jSeparator1 = new javax.swing.JToolBar.Separator();
    cancelButton = new javax.swing.JButton();
    jScrollPaneOuter.setBackground(java.awt.SystemColor.controlDkShadow);
    jScrollPaneOuter.setBorder(null);
    jDesktopPane1.setBackground(java.awt.SystemColor.controlDkShadow);
    jDesktopPane1.addComponentListener(new java.awt.event.ComponentAdapter() {

        public void componentResized(java.awt.event.ComponentEvent evt) {
            jDesktopPane1ComponentResized(evt);
        }
    });
    printPanel.setBorder(null);
    printPanel.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    printPanel.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    printPanel.setBounds(0, 0, 420, 310);
    jDesktopPane1.add(printPanel, javax.swing.JLayeredPane.DEFAULT_LAYER);
    jScrollPaneOuter.setViewportView(jDesktopPane1);
    jToolBar1.setRollover(true);
    printButton.setText("Print");
    printButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            printButtonActionPerformed(evt);
        }
    });
    jToolBar1.add(printButton);
    jToolBar1.add(jSeparator1);
    cancelButton.setText("Close");
    cancelButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cancelButtonActionPerformed(evt);
        }
    });
    jToolBar1.add(cancelButton);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 410, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap()).addComponent(jScrollPaneOuter, javax.swing.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jScrollPaneOuter, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)));
}
Example 19
Project: Feuille-master  File: KaraokePanel.java View source code
/**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    bgOriginal = new javax.swing.ButtonGroup();
    jFileChooser1 = new javax.swing.JFileChooser();
    bgResult = new javax.swing.ButtonGroup();
    popOrg = new javax.swing.JPopupMenu();
    popOrgCut = new javax.swing.JMenuItem();
    popOrgCopy = new javax.swing.JMenuItem();
    popOrgPaste = new javax.swing.JMenuItem();
    popOrgSep1 = new javax.swing.JPopupMenu.Separator();
    popOrgDelete = new javax.swing.JMenuItem();
    popOrgClear = new javax.swing.JMenuItem();
    popOrgSep2 = new javax.swing.JPopupMenu.Separator();
    popOrgRemove = new javax.swing.JMenuItem();
    popRes = new javax.swing.JPopupMenu();
    popResCut = new javax.swing.JMenuItem();
    popResCopy = new javax.swing.JMenuItem();
    popResPaste = new javax.swing.JMenuItem();
    popResSep = new javax.swing.JPopupMenu.Separator();
    popResDelete = new javax.swing.JMenuItem();
    popResClear = new javax.swing.JMenuItem();
    popResetFx = new javax.swing.JPopupMenu();
    mnuPopRfReset = new javax.swing.JMenuItem();
    mnuPopRfInfo = new javax.swing.JMenuItem();
    popTimeKara = new javax.swing.JPopupMenu();
    popmToSelected = new javax.swing.JRadioButtonMenuItem();
    popmDirectly = new javax.swing.JRadioButtonMenuItem();
    popSetGetKaraoke = new javax.swing.JPopupMenu();
    popmGetSelLine = new javax.swing.JMenuItem();
    jDesktopPane1 = new javax.swing.JDesktopPane();
    ifrOriginal = new javax.swing.JInternalFrame();
    jToolBar1 = new javax.swing.JToolBar();
    btnOpen = new javax.swing.JButton();
    btnSaveOri = new javax.swing.JButton();
    jSeparator1 = new javax.swing.JToolBar.Separator();
    tbNormalOri = new javax.swing.JToggleButton();
    tbItemsOri = new javax.swing.JToggleButton();
    tbStripOri = new javax.swing.JToggleButton();
    jSeparator2 = new javax.swing.JToolBar.Separator();
    btnOneLine = new javax.swing.JButton();
    btnBlock = new javax.swing.JButton();
    jSeparator4 = new javax.swing.JToolBar.Separator();
    bStyles = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    orgTable = new javax.swing.JTable();
    ifrResult = new javax.swing.JInternalFrame();
    jToolBar2 = new javax.swing.JToolBar();
    btnSaveRes = new javax.swing.JButton();
    jSeparator3 = new javax.swing.JToolBar.Separator();
    tbNormalRes = new javax.swing.JToggleButton();
    tbItemsRes = new javax.swing.JToggleButton();
    tbStripRes = new javax.swing.JToggleButton();
    jScrollPane2 = new javax.swing.JScrollPane();
    resTable = new javax.swing.JTable();
    ifrTree = new javax.swing.JInternalFrame();
    toolbarPanel = new javax.swing.JPanel();
    jToolBar3 = new javax.swing.JToolBar();
    btnAddFxoToLine = new javax.swing.JButton();
    btnAddXmlPresetFx = new javax.swing.JButton();
    btnModXmlPresetFx = new javax.swing.JButton();
    btnDelXmlPresetFx = new javax.swing.JButton();
    btnImpXmlPresetFx = new javax.swing.JButton();
    btnExpXmlPresetFx = new javax.swing.JButton();
    btnModRuby = new javax.swing.JButton();
    jToolBar4 = new javax.swing.JToolBar();
    btnCreateParticle = new javax.swing.JButton();
    btnEditParticle = new javax.swing.JButton();
    btnDeleteParticle = new javax.swing.JButton();
    jScrollPane3 = new javax.swing.JScrollPane();
    jTree1 = new javax.swing.JTree();
    ifrSound = new javax.swing.JInternalFrame();
    jToolBar5 = new javax.swing.JToolBar();
    btnOpen1 = new javax.swing.JButton();
    jSeparator10 = new javax.swing.JToolBar.Separator();
    btnPlay = new javax.swing.JButton();
    btnStop = new javax.swing.JButton();
    jSeparator11 = new javax.swing.JToolBar.Separator();
    btnPlayArea = new javax.swing.JButton();
    btnPlayBeforeBegin = new javax.swing.JButton();
    btnPlayAfterBegin = new javax.swing.JButton();
    btnPlayBeforeEnd = new javax.swing.JButton();
    btnPlayAfterEnd = new javax.swing.JButton();
    btnNewtime = new javax.swing.JButton();
    btnSetKara = new javax.swing.JButton();
    btnGetKara = new javax.swing.JButton();
    tfTimeKara = new javax.swing.JTextField();
    realWavePanel = new javax.swing.JPanel();
    jScrollBar1 = new javax.swing.JScrollBar();
    popOrgCut.setText("Cut");
    popOrgCut.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            popOrgCutActionPerformed(evt);
        }
    });
    popOrg.add(popOrgCut);
    popOrgCopy.setText("Copy");
    popOrgCopy.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            popOrgCopyActionPerformed(evt);
        }
    });
    popOrg.add(popOrgCopy);
    popOrgPaste.setText("Paste");
    popOrgPaste.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            popOrgPasteActionPerformed(evt);
        }
    });
    popOrg.add(popOrgPaste);
    popOrg.add(popOrgSep1);
    popOrgDelete.setText("Delete");
    popOrgDelete.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            popOrgDeleteActionPerformed(evt);
        }
    });
    popOrg.add(popOrgDelete);
    popOrgClear.setText("Clear");
    popOrgClear.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            popOrgClearActionPerformed(evt);
        }
    });
    popOrg.add(popOrgClear);
    popOrg.add(popOrgSep2);
    popOrgRemove.setText("Remove FX");
    popOrgRemove.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            popOrgRemoveActionPerformed(evt);
        }
    });
    popOrg.add(popOrgRemove);
    popResCut.setText("Cut");
    popResCut.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            popResCutActionPerformed(evt);
        }
    });
    popRes.add(popResCut);
    popResCopy.setText("Copy");
    popResCopy.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            popResCopyActionPerformed(evt);
        }
    });
    popRes.add(popResCopy);
    popResPaste.setText("Paste");
    popResPaste.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            popResPasteActionPerformed(evt);
        }
    });
    popRes.add(popResPaste);
    popRes.add(popResSep);
    popResDelete.setText("Delete");
    popResDelete.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            popResDeleteActionPerformed(evt);
        }
    });
    popRes.add(popResDelete);
    popResClear.setText("Clear");
    popResClear.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            popResClearActionPerformed(evt);
        }
    });
    popRes.add(popResClear);
    mnuPopRfReset.setText("Refresh the ruby scripts list");
    mnuPopRfReset.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            mnuPopRfResetActionPerformed(evt);
        }
    });
    popResetFx.add(mnuPopRfReset);
    mnuPopRfInfo.setText("Get info about this object");
    mnuPopRfInfo.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            mnuPopRfInfoActionPerformed(evt);
        }
    });
    popResetFx.add(mnuPopRfInfo);
    popmToSelected.setText("To the selected line");
    popTimeKara.add(popmToSelected);
    popmDirectly.setSelected(true);
    popmDirectly.setText("Add a new line");
    popTimeKara.add(popmDirectly);
    popmGetSelLine.setText("Get the selected line");
    popmGetSelLine.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            popmGetSelLineActionPerformed(evt);
        }
    });
    popSetGetKaraoke.add(popmGetSelLine);
    ifrOriginal.setIconifiable(true);
    ifrOriginal.setMaximizable(true);
    ifrOriginal.setResizable(true);
    ifrOriginal.setTitle("Karaoké original");
    ifrOriginal.setVisible(true);
    jToolBar1.setFloatable(false);
    jToolBar1.setRollover(true);
    // NOI18N
    btnOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/funsub_open.png")));
    btnOpen.setToolTipText("Ouvriur un fichier SSA ou ASS");
    btnOpen.setFocusable(false);
    btnOpen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnOpen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnOpen.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnOpenActionPerformed(evt);
        }
    });
    jToolBar1.add(btnOpen);
    // NOI18N
    btnSaveOri.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/funsub_save.png")));
    btnSaveOri.setToolTipText("Sauvegarder le karaoké original");
    btnSaveOri.setFocusable(false);
    btnSaveOri.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnSaveOri.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnSaveOri.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSaveOriActionPerformed(evt);
        }
    });
    jToolBar1.add(btnSaveOri);
    jToolBar1.add(jSeparator1);
    bgOriginal.add(tbNormalOri);
    // NOI18N
    tbNormalOri.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-NormalMode.png")));
    tbNormalOri.setSelected(true);
    tbNormalOri.setToolTipText("Montrer toutes les balises");
    tbNormalOri.setFocusable(false);
    tbNormalOri.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    tbNormalOri.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    tbNormalOri.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tbNormalOriActionPerformed(evt);
        }
    });
    jToolBar1.add(tbNormalOri);
    bgOriginal.add(tbItemsOri);
    // NOI18N
    tbItemsOri.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-ItemsMode.png")));
    tbItemsOri.setToolTipText("Montrer des items");
    tbItemsOri.setFocusable(false);
    tbItemsOri.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    tbItemsOri.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    tbItemsOri.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tbItemsOriActionPerformed(evt);
        }
    });
    jToolBar1.add(tbItemsOri);
    bgOriginal.add(tbStripOri);
    // NOI18N
    tbStripOri.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-StripMode.png")));
    tbStripOri.setToolTipText("Montrer le texte seul");
    tbStripOri.setFocusable(false);
    tbStripOri.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    tbStripOri.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    tbStripOri.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tbStripOriActionPerformed(evt);
        }
    });
    jToolBar1.add(tbStripOri);
    jToolBar1.add(jSeparator2);
    // NOI18N
    btnOneLine.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-ExecuteForOneLine.png")));
    btnOneLine.setToolTipText("Exécuter ligne par ligne");
    btnOneLine.setFocusable(false);
    btnOneLine.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnOneLine.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnOneLine.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnOneLineActionPerformed(evt);
        }
    });
    jToolBar1.add(btnOneLine);
    // NOI18N
    btnBlock.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-ExecuteForFewLines.png")));
    btnBlock.setToolTipText("Exécuter par bloc");
    btnBlock.setFocusable(false);
    btnBlock.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnBlock.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnBlock.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnBlockActionPerformed(evt);
        }
    });
    jToolBar1.add(btnBlock);
    jToolBar1.add(jSeparator4);
    // NOI18N
    bStyles.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/32px-Crystal_Clear_action_fonts.png")));
    bStyles.setFocusable(false);
    bStyles.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    bStyles.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    bStyles.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            bStylesActionPerformed(evt);
        }
    });
    jToolBar1.add(bStyles);
    ifrOriginal.getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH);
    jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    orgTable.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
    orgTable.setComponentPopupMenu(popOrg);
    jScrollPane1.setViewportView(orgTable);
    ifrOriginal.getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
    jDesktopPane1.add(ifrOriginal);
    ifrOriginal.setBounds(10, 10, 430, 270);
    ifrResult.setIconifiable(true);
    ifrResult.setMaximizable(true);
    ifrResult.setResizable(true);
    ifrResult.setTitle("Karaoké résultant");
    ifrResult.setVisible(true);
    jToolBar2.setFloatable(false);
    jToolBar2.setRollover(true);
    // NOI18N
    btnSaveRes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/funsub_save2.png")));
    btnSaveRes.setToolTipText("Sauvegarder le karaoké résultant");
    btnSaveRes.setFocusable(false);
    btnSaveRes.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnSaveRes.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnSaveRes.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSaveResActionPerformed(evt);
        }
    });
    jToolBar2.add(btnSaveRes);
    jToolBar2.add(jSeparator3);
    bgResult.add(tbNormalRes);
    // NOI18N
    tbNormalRes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-NormalMode.png")));
    tbNormalRes.setSelected(true);
    tbNormalRes.setToolTipText("Montrer toutes les balises");
    tbNormalRes.setFocusable(false);
    tbNormalRes.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    tbNormalRes.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    tbNormalRes.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tbNormalResActionPerformed(evt);
        }
    });
    jToolBar2.add(tbNormalRes);
    bgResult.add(tbItemsRes);
    // NOI18N
    tbItemsRes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-ItemsMode.png")));
    tbItemsRes.setToolTipText("Montrer des items");
    tbItemsRes.setFocusable(false);
    tbItemsRes.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    tbItemsRes.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    tbItemsRes.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tbItemsResActionPerformed(evt);
        }
    });
    jToolBar2.add(tbItemsRes);
    bgResult.add(tbStripRes);
    // NOI18N
    tbStripRes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-StripMode.png")));
    tbStripRes.setToolTipText("Montrer le texte seul");
    tbStripRes.setFocusable(false);
    tbStripRes.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    tbStripRes.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    tbStripRes.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tbStripResActionPerformed(evt);
        }
    });
    jToolBar2.add(tbStripRes);
    ifrResult.getContentPane().add(jToolBar2, java.awt.BorderLayout.NORTH);
    jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    resTable.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
    resTable.setComponentPopupMenu(popRes);
    jScrollPane2.setViewportView(resTable);
    ifrResult.getContentPane().add(jScrollPane2, java.awt.BorderLayout.CENTER);
    jDesktopPane1.add(ifrResult);
    ifrResult.setBounds(10, 300, 430, 270);
    ifrTree.setIconifiable(true);
    ifrTree.setResizable(true);
    ifrTree.setTitle("Liste d'effets");
    ifrTree.setVisible(true);
    toolbarPanel.setLayout(new java.awt.BorderLayout());
    jToolBar3.setFloatable(false);
    jToolBar3.setRollover(true);
    // NOI18N
    btnAddFxoToLine.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-AddFxoToList.png")));
    btnAddFxoToLine.setFocusable(false);
    btnAddFxoToLine.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddFxoToLine.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddFxoToLine.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddFxoToLineActionPerformed(evt);
        }
    });
    jToolBar3.add(btnAddFxoToLine);
    // NOI18N
    btnAddXmlPresetFx.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-NewFxo.png")));
    btnAddXmlPresetFx.setFocusable(false);
    btnAddXmlPresetFx.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddXmlPresetFx.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddXmlPresetFx.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddXmlPresetFxActionPerformed(evt);
        }
    });
    jToolBar3.add(btnAddXmlPresetFx);
    // NOI18N
    btnModXmlPresetFx.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-ModFxo.png")));
    btnModXmlPresetFx.setFocusable(false);
    btnModXmlPresetFx.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnModXmlPresetFx.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnModXmlPresetFx.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnModXmlPresetFxActionPerformed(evt);
        }
    });
    jToolBar3.add(btnModXmlPresetFx);
    // NOI18N
    btnDelXmlPresetFx.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-DelFxo.png")));
    btnDelXmlPresetFx.setFocusable(false);
    btnDelXmlPresetFx.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnDelXmlPresetFx.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnDelXmlPresetFx.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnDelXmlPresetFxActionPerformed(evt);
        }
    });
    jToolBar3.add(btnDelXmlPresetFx);
    // NOI18N
    btnImpXmlPresetFx.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-ImportFxo.png")));
    btnImpXmlPresetFx.setFocusable(false);
    btnImpXmlPresetFx.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnImpXmlPresetFx.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnImpXmlPresetFx.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnImpXmlPresetFxActionPerformed(evt);
        }
    });
    jToolBar3.add(btnImpXmlPresetFx);
    // NOI18N
    btnExpXmlPresetFx.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-ExportFxo.png")));
    btnExpXmlPresetFx.setFocusable(false);
    btnExpXmlPresetFx.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnExpXmlPresetFx.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnExpXmlPresetFx.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnExpXmlPresetFxActionPerformed(evt);
        }
    });
    jToolBar3.add(btnExpXmlPresetFx);
    // NOI18N
    btnModRuby.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-ModRuby.png")));
    btnModRuby.setFocusable(false);
    btnModRuby.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnModRuby.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnModRuby.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnModRubyActionPerformed(evt);
        }
    });
    jToolBar3.add(btnModRuby);
    toolbarPanel.add(jToolBar3, java.awt.BorderLayout.NORTH);
    jToolBar4.setFloatable(false);
    jToolBar4.setRollover(true);
    // NOI18N
    btnCreateParticle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-NewPart.png")));
    btnCreateParticle.setFocusable(false);
    btnCreateParticle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnCreateParticle.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnCreateParticle.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnCreateParticleActionPerformed(evt);
        }
    });
    jToolBar4.add(btnCreateParticle);
    // NOI18N
    btnEditParticle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-ModPart.png")));
    btnEditParticle.setFocusable(false);
    btnEditParticle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnEditParticle.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnEditParticle.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnEditParticleActionPerformed(evt);
        }
    });
    jToolBar4.add(btnEditParticle);
    // NOI18N
    btnDeleteParticle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/AFM-DelPart.png")));
    btnDeleteParticle.setFocusable(false);
    btnDeleteParticle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnDeleteParticle.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnDeleteParticle.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnDeleteParticleActionPerformed(evt);
        }
    });
    jToolBar4.add(btnDeleteParticle);
    toolbarPanel.add(jToolBar4, java.awt.BorderLayout.SOUTH);
    ifrTree.getContentPane().add(toolbarPanel, java.awt.BorderLayout.NORTH);
    jTree1.setComponentPopupMenu(popResetFx);
    jScrollPane3.setViewportView(jTree1);
    ifrTree.getContentPane().add(jScrollPane3, java.awt.BorderLayout.CENTER);
    jDesktopPane1.add(ifrTree);
    ifrTree.setBounds(450, 10, 200, 560);
    ifrSound.setIconifiable(true);
    ifrSound.setResizable(true);
    ifrSound.setTitle("Forme d'onde");
    ifrSound.setVisible(true);
    jToolBar5.setFloatable(false);
    jToolBar5.setRollover(true);
    // NOI18N
    btnOpen1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/32px-Crystal_Clear_filesystem_folder_grey_open.png")));
    btnOpen1.setToolTipText("Open a new sound...");
    btnOpen1.setFocusable(false);
    btnOpen1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnOpen1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnOpen1.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnOpen1ActionPerformed(evt);
        }
    });
    jToolBar5.add(btnOpen1);
    jToolBar5.add(jSeparator10);
    // NOI18N
    btnPlay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/play-32.png")));
    btnPlay.setToolTipText("Play the sound from the beginning");
    btnPlay.setFocusable(false);
    btnPlay.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnPlay.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnPlay.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnPlayActionPerformed(evt);
        }
    });
    jToolBar5.add(btnPlay);
    // NOI18N
    btnStop.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/stop-32.png")));
    btnStop.setToolTipText("Stop the sound");
    btnStop.setFocusable(false);
    btnStop.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnStop.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnStop.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnStopActionPerformed(evt);
        }
    });
    jToolBar5.add(btnStop);
    jToolBar5.add(jSeparator11);
    // NOI18N
    btnPlayArea.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/playarea-32.png")));
    btnPlayArea.setToolTipText("Play the delimited part of the sound");
    btnPlayArea.setFocusable(false);
    btnPlayArea.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnPlayArea.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnPlayArea.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnPlayAreaActionPerformed(evt);
        }
    });
    jToolBar5.add(btnPlayArea);
    // NOI18N
    btnPlayBeforeBegin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/playbeforebegin-32.png")));
    btnPlayBeforeBegin.setToolTipText("Play before the beginning of the delimited area");
    btnPlayBeforeBegin.setFocusable(false);
    btnPlayBeforeBegin.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnPlayBeforeBegin.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnPlayBeforeBegin.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnPlayBeforeBeginActionPerformed(evt);
        }
    });
    jToolBar5.add(btnPlayBeforeBegin);
    // NOI18N
    btnPlayAfterBegin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/playafterbegin-32.png")));
    btnPlayAfterBegin.setToolTipText("Play after the beginning of the delimited area");
    btnPlayAfterBegin.setFocusable(false);
    btnPlayAfterBegin.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnPlayAfterBegin.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnPlayAfterBegin.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnPlayAfterBeginActionPerformed(evt);
        }
    });
    jToolBar5.add(btnPlayAfterBegin);
    // NOI18N
    btnPlayBeforeEnd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/playbeforeend-32.png")));
    btnPlayBeforeEnd.setToolTipText("Play before the end of the delimited area");
    btnPlayBeforeEnd.setFocusable(false);
    btnPlayBeforeEnd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnPlayBeforeEnd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnPlayBeforeEnd.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnPlayBeforeEndActionPerformed(evt);
        }
    });
    jToolBar5.add(btnPlayBeforeEnd);
    // NOI18N
    btnPlayAfterEnd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/playafterend-32.png")));
    btnPlayAfterEnd.setToolTipText("Play after the end of the delimited area");
    btnPlayAfterEnd.setFocusable(false);
    btnPlayAfterEnd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnPlayAfterEnd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnPlayAfterEnd.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnPlayAfterEndActionPerformed(evt);
        }
    });
    jToolBar5.add(btnPlayAfterEnd);
    // NOI18N
    btnNewtime.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/newtime-32.png")));
    btnNewtime.setToolTipText("Get the time of the start and the time of the end");
    btnNewtime.setComponentPopupMenu(popTimeKara);
    btnNewtime.setFocusable(false);
    btnNewtime.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNewtime.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnNewtime.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnNewtimeActionPerformed(evt);
        }
    });
    jToolBar5.add(btnNewtime);
    // NOI18N
    btnSetKara.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/setkara-32.png")));
    btnSetKara.setToolTipText("Set the karaoke");
    btnSetKara.setFocusable(false);
    btnSetKara.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnSetKara.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnSetKara.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSetKaraActionPerformed(evt);
        }
    });
    jToolBar5.add(btnSetKara);
    // NOI18N
    btnGetKara.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/changetime-32.png")));
    btnGetKara.setToolTipText("Get the karaoke");
    btnGetKara.setFocusable(false);
    btnGetKara.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnGetKara.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnGetKara.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnGetKaraActionPerformed(evt);
        }
    });
    jToolBar5.add(btnGetKara);
    tfTimeKara.setComponentPopupMenu(popSetGetKaraoke);
    tfTimeKara.setPreferredSize(new java.awt.Dimension(500, 30));
    jToolBar5.add(tfTimeKara);
    ifrSound.getContentPane().add(jToolBar5, java.awt.BorderLayout.NORTH);
    realWavePanel.setLayout(null);
    ifrSound.getContentPane().add(realWavePanel, java.awt.BorderLayout.CENTER);
    jScrollBar1.setOrientation(javax.swing.JScrollBar.HORIZONTAL);
    jScrollBar1.addAdjustmentListener(new java.awt.event.AdjustmentListener() {

        public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {
            jScrollBar1AdjustmentValueChanged(evt);
        }
    });
    ifrSound.getContentPane().add(jScrollBar1, java.awt.BorderLayout.SOUTH);
    jDesktopPane1.add(ifrSound);
    ifrSound.setBounds(670, 180, 520, 220);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jDesktopPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1261, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(0, 0, Short.MAX_VALUE)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 595, Short.MAX_VALUE));
}
Example 20
Project: opentrader.github.com-master  File: OpenTraderJFrame.java View source code
/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">
void initComponents() {
    jDesktopPane1 = new javax.swing.JDesktopPane();
    jInternalFrame1 = new javax.swing.JInternalFrame();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenu2 = new javax.swing.JMenu();
    jPanel1 = new javax.swing.JPanel();
    jPanel2 = new javax.swing.JPanel();
    jPanel3 = new javax.swing.JPanel();
    jSplitPane1 = new javax.swing.JSplitPane();
    jSplitPane2 = new javax.swing.JSplitPane();
    jSplitPane3 = new javax.swing.JSplitPane();
    jTabbedPane1 = new javax.swing.JTabbedPane();
    jTabbedPane2 = new javax.swing.JTabbedPane();
    jTabbedPane3 = new javax.swing.JTabbedPane();
    jTextFieldSearch = new javax.swing.JTextField();
    jToolBar1 = new javax.swing.JToolBar();
    jToolBar2 = new javax.swing.JToolBar();
    /** UI properties */
    rootPane.putClientProperty("SeaGlass.UnifiedToolbarLook", Boolean.TRUE);
    rootPane.putClientProperty("JRootPane.MenuInTitle", Boolean.TRUE);
    jTextFieldSearch.putClientProperty("JTextField.variant", "search");
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("OpenTrader Trading Platform");
    setIconImage(new ImageIcon(getClass().getResource("/org/opentrader/resource/icons/shield_64.png")).getImage());
    setMinimumSize(new java.awt.Dimension(800, 600));
    jToolBar1.setFloatable(false);
    jToolBar1.setRollover(true);
    jToolBar1.add(javax.swing.Box.createHorizontalGlue());
    jTextFieldSearch.setText("");
    jTextFieldSearch.setMinimumSize(new java.awt.Dimension(200, 28));
    jTextFieldSearch.setPreferredSize(new java.awt.Dimension(200, 28));
    jToolBar1.add(jTextFieldSearch);
    jToolBar2.setFloatable(false);
    jToolBar2.setRollover(true);
    jSplitPane1.setDividerLocation(250);
    jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    jSplitPane2.setDividerLocation(200);
    jSplitPane3.setDividerLocation(140);
    jSplitPane3.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    jTabbedPane2.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 147, Short.MAX_VALUE));
    jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 104, Short.MAX_VALUE));
    jTabbedPane2.addTab("tab1", jPanel2);
    jSplitPane3.setTopComponent(jTabbedPane2);
    jTabbedPane3.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
    javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout.setHorizontalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 147, Short.MAX_VALUE));
    jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 68, Short.MAX_VALUE));
    jTabbedPane3.addTab("tab1", jPanel3);
    jSplitPane3.setRightComponent(jTabbedPane3);
    jSplitPane2.setLeftComponent(jSplitPane3);
    jInternalFrame1.setVisible(true);
    javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
    jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
    jInternalFrame1Layout.setHorizontalGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 148, Short.MAX_VALUE));
    jInternalFrame1Layout.setVerticalGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 104, Short.MAX_VALUE));
    jInternalFrame1.setBounds(50, 60, 150, 130);
    jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);
    jSplitPane2.setRightComponent(jDesktopPane1);
    jSplitPane1.setTopComponent(jSplitPane2);
    jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 656, Short.MAX_VALUE));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 78, Short.MAX_VALUE));
    jTabbedPane1.addTab("tab1*", jPanel1);
    jSplitPane1.setRightComponent(jTabbedPane1);
    jMenu1.setText("File");
    jMenuBar1.add(jMenu1);
    jMenu2.setText("Edit");
    jMenuBar1.add(jMenu2);
    setJMenuBar(jMenuBar1);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 664, Short.MAX_VALUE).addComponent(jToolBar2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 664, Short.MAX_VALUE).addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 664, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 370, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)));
    pack();
}
Example 21
Project: Question_Box_Desktop-master  File: AdminConsole.java View source code
/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    desktopPane = new javax.swing.JDesktopPane();
    buttonAddOperator = new javax.swing.JButton();
    btnAddCategory = new javax.swing.JButton();
    btnAddAnswer = new javax.swing.JButton();
    jButton1 = new javax.swing.JButton();
    jSplitPane1 = new javax.swing.JSplitPane();
    menuBar = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    saveMenuItem = new javax.swing.JMenuItem();
    saveAsMenuItem = new javax.swing.JMenuItem();
    exitMenuItem = new javax.swing.JMenuItem();
    editMenu = new javax.swing.JMenu();
    cutMenuItem = new javax.swing.JMenuItem();
    copyMenuItem = new javax.swing.JMenuItem();
    pasteMenuItem = new javax.swing.JMenuItem();
    deleteMenuItem = new javax.swing.JMenuItem();
    helpMenu = new javax.swing.JMenu();
    contentMenuItem = new javax.swing.JMenuItem();
    aboutMenuItem = new javax.swing.JMenuItem();
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    // NOI18N
    setName("Form");
    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(questionbox.QuestionBoxApp.class).getContext().getResourceMap(AdminConsole.class);
    // NOI18N
    desktopPane.setBackground(resourceMap.getColor("desktopPane.background"));
    // NOI18N
    desktopPane.setName("desktopPane");
    // NOI18N
    buttonAddOperator.setText(resourceMap.getString("buttonAddOperator.text"));
    // NOI18N
    buttonAddOperator.setName("buttonAddOperator");
    buttonAddOperator.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonAddOperatorActionPerformed(evt);
        }
    });
    buttonAddOperator.setBounds(20, 20, 160, 30);
    desktopPane.add(buttonAddOperator, javax.swing.JLayeredPane.DEFAULT_LAYER);
    // NOI18N
    btnAddCategory.setText(resourceMap.getString("btnAddCategory.text"));
    // NOI18N
    btnAddCategory.setName("btnAddCategory");
    btnAddCategory.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddCategoryActionPerformed(evt);
        }
    });
    btnAddCategory.setBounds(20, 60, 160, 30);
    desktopPane.add(btnAddCategory, javax.swing.JLayeredPane.DEFAULT_LAYER);
    // NOI18N
    btnAddAnswer.setText(resourceMap.getString("btnAddAnswer.text"));
    // NOI18N
    btnAddAnswer.setName("btnAddAnswer");
    btnAddAnswer.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddAnswerActionPerformed(evt);
        }
    });
    btnAddAnswer.setBounds(20, 100, 160, 30);
    desktopPane.add(btnAddAnswer, javax.swing.JLayeredPane.DEFAULT_LAYER);
    javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(questionbox.QuestionBoxApp.class).getContext().getActionMap(AdminConsole.class, this);
    // NOI18N
    jButton1.setAction(actionMap.get("openRecsites"));
    // NOI18N
    jButton1.setText(resourceMap.getString("jButton1.text"));
    // NOI18N
    jButton1.setName("jButton1");
    jButton1.setBounds(20, 140, 160, 30);
    desktopPane.add(jButton1, javax.swing.JLayeredPane.DEFAULT_LAYER);
    // NOI18N
    jSplitPane1.setName("jSplitPane1");
    // NOI18N
    menuBar.setName("menuBar");
    // NOI18N
    fileMenu.setText(resourceMap.getString("fileMenu.text"));
    // NOI18N
    fileMenu.setName("fileMenu");
    // NOI18N
    saveMenuItem.setText(resourceMap.getString("saveMenuItem.text"));
    // NOI18N
    saveMenuItem.setName("saveMenuItem");
    fileMenu.add(saveMenuItem);
    // NOI18N
    saveAsMenuItem.setText(resourceMap.getString("saveAsMenuItem.text"));
    // NOI18N
    saveAsMenuItem.setName("saveAsMenuItem");
    fileMenu.add(saveAsMenuItem);
    // NOI18N
    exitMenuItem.setText(resourceMap.getString("exitMenuItem.text"));
    // NOI18N
    exitMenuItem.setName("exitMenuItem");
    exitMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(exitMenuItem);
    menuBar.add(fileMenu);
    // NOI18N
    editMenu.setText(resourceMap.getString("editMenu.text"));
    // NOI18N
    editMenu.setName("editMenu");
    // NOI18N
    cutMenuItem.setText(resourceMap.getString("cutMenuItem.text"));
    // NOI18N
    cutMenuItem.setName("cutMenuItem");
    editMenu.add(cutMenuItem);
    // NOI18N
    copyMenuItem.setText(resourceMap.getString("copyMenuItem.text"));
    // NOI18N
    copyMenuItem.setName("copyMenuItem");
    editMenu.add(copyMenuItem);
    // NOI18N
    pasteMenuItem.setText(resourceMap.getString("pasteMenuItem.text"));
    // NOI18N
    pasteMenuItem.setName("pasteMenuItem");
    editMenu.add(pasteMenuItem);
    // NOI18N
    deleteMenuItem.setText(resourceMap.getString("deleteMenuItem.text"));
    // NOI18N
    deleteMenuItem.setName("deleteMenuItem");
    editMenu.add(deleteMenuItem);
    menuBar.add(editMenu);
    // NOI18N
    helpMenu.setText(resourceMap.getString("helpMenu.text"));
    // NOI18N
    helpMenu.setName("helpMenu");
    // NOI18N
    contentMenuItem.setText(resourceMap.getString("contentMenuItem.text"));
    // NOI18N
    contentMenuItem.setName("contentMenuItem");
    helpMenu.add(contentMenuItem);
    // NOI18N
    aboutMenuItem.setText(resourceMap.getString("aboutMenuItem.text"));
    // NOI18N
    aboutMenuItem.setName("aboutMenuItem");
    helpMenu.add(aboutMenuItem);
    menuBar.add(helpMenu);
    setJMenuBar(menuBar);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 378, Short.MAX_VALUE).addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE).addGap(22, 22, 22)));
    pack();
}
Example 22
Project: bham-master  File: BhamFrame.java View source code
/**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
@SuppressWarnings("all")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;
    mainSplitPane = new javax.swing.JSplitPane();
    projectTreeScrollPane = new javax.swing.JScrollPane();
    javax.swing.JTree projectTree = this.bhamProjectTree;
    javax.swing.JDesktopPane desktopPane = this.desktop;
    javax.swing.JPanel progressPanel = this.multiTaskProgress;
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    getContentPane().setLayout(new java.awt.GridBagLayout());
    projectTreeScrollPane.setViewportView(projectTree);
    mainSplitPane.setLeftComponent(projectTreeScrollPane);
    mainSplitPane.setRightComponent(desktopPane);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    getContentPane().add(mainSplitPane, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    getContentPane().add(progressPanel, gridBagConstraints);
    pack();
}
Example 23
Project: jdk7u-jdk-master  File: SynthDesktopPaneUI.java View source code
void adjustSize() {
    JDesktopPane desktop = (JDesktopPane) getParent();
    if (desktop != null) {
        int height = getPreferredSize().height;
        Insets insets = getInsets();
        if (height == insets.top + insets.bottom) {
            if (getHeight() <= height) {
                // Initial size, because we have no buttons yet
                height += 21;
            } else {
                // We already have a good height
                height = getHeight();
            }
        }
        setBounds(0, desktop.getHeight() - height, desktop.getWidth(), height);
        revalidate();
        repaint();
    }
}
Example 24
Project: openjdk8-jdk-master  File: SynthDesktopPaneUI.java View source code
void adjustSize() {
    JDesktopPane desktop = (JDesktopPane) getParent();
    if (desktop != null) {
        int height = getPreferredSize().height;
        Insets insets = getInsets();
        if (height == insets.top + insets.bottom) {
            if (getHeight() <= height) {
                // Initial size, because we have no buttons yet
                height += 21;
            } else {
                // We already have a good height
                height = getHeight();
            }
        }
        setBounds(0, desktop.getHeight() - height, desktop.getWidth(), height);
        revalidate();
        repaint();
    }
}
Example 25
Project: pentaho-reporting-master  File: InternalFrameDemoHandler.java View source code
/**
   * Creates the content for the application frame.
   *
   * @return a panel containing the basic user interface.
   */
private JDesktopPane init(final DemoController ctrl) {
    final JPanel content = new JPanel(new BorderLayout());
    content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    content.add(createDefaultTable(data));
    content.add(new JButton(ctrl.getExportAction()), BorderLayout.SOUTH);
    final JInternalFrame frame = new JInternalFrame();
    frame.setClosable(false);
    frame.setVisible(true);
    frame.setContentPane(content);
    frame.pack();
    final JDesktopPane desktop = new JDesktopPane();
    desktop.setDoubleBuffered(false);
    desktop.add(frame);
    return desktop;
}
Example 26
Project: seaglass-master  File: SeaGlassDesktopPaneUI.java View source code
void adjustSize() {
    JDesktopPane desktop = (JDesktopPane) getParent();
    if (desktop != null) {
        int height = getPreferredSize().height;
        Insets insets = getInsets();
        if (height == insets.top + insets.bottom) {
            if (getHeight() <= height) {
                // Initial size, because we have no buttons yet
                height += 21;
            } else {
                // We already have a good height
                height = getHeight();
            }
        }
        setBounds(0, desktop.getHeight() - height, desktop.getWidth(), height);
        revalidate();
        repaint();
    }
}
Example 27
Project: substance-master  File: ControlPanelFactory.java View source code
public void run() {
    JDialog dialog = new JDialog(mainFrame, "Sample dialog", true);
    dialog.setSize(400, 300);
    dialog.setLocationRelativeTo(mainFrame);
    dialog.setLayout(new BorderLayout());
    JDesktopPane panel = new JDesktopPane();
    dialog.add(panel, BorderLayout.CENTER);
    JOptionPane.showInputDialog(panel, "Sample Question Message?", "Default Answer");
    dialog.dispose();
}
Example 28
Project: rjava-interface-master  File: ApplicationFrame.java View source code
/**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
@SuppressWarnings("all")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;
    javax.swing.JSplitPane outerSplitPane = new javax.swing.JSplitPane();
    javax.swing.JSplitPane innerSplitPane = new javax.swing.JSplitPane();
    dataTreeScrollPane = new javax.swing.JScrollPane();
    javax.swing.JDesktopPane desktopPane = desktop;
    javax.swing.JPanel terminalPanel = new javax.swing.JPanel();
    javax.swing.JPanel terminalHeaderPanel = new javax.swing.JPanel();
    terminalToolBar = new javax.swing.JToolBar();
    javax.swing.JButton insertCommandButton = new javax.swing.JButton();
    javax.swing.JPanel taskTrackerPanelDowncast = taskProgressPanel;
    javax.swing.JScrollPane terminalScrollPane = new javax.swing.JScrollPane();
    terminalTextPane = new javax.swing.JTextPane();
    javax.swing.JMenuBar mainMenu = menuBar;
    setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new java.awt.event.WindowAdapter() {

        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });
    outerSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    outerSplitPane.setResizeWeight(0.7);
    outerSplitPane.setOneTouchExpandable(true);
    innerSplitPane.setResizeWeight(0.2);
    innerSplitPane.setOneTouchExpandable(true);
    innerSplitPane.setLeftComponent(dataTreeScrollPane);
    innerSplitPane.setRightComponent(desktopPane);
    outerSplitPane.setTopComponent(innerSplitPane);
    terminalPanel.setLayout(new java.awt.BorderLayout());
    terminalHeaderPanel.setLayout(new java.awt.GridBagLayout());
    terminalToolBar.setFloatable(false);
    terminalToolBar.setRollover(true);
    // NOI18N
    insertCommandButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/terminal-16x16.png")));
    insertCommandButton.setText("Insert Comment or Command ...");
    insertCommandButton.setFocusable(false);
    insertCommandButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    insertCommandButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            insertCommandButtonActionPerformed(evt);
        }
    });
    terminalToolBar.add(insertCommandButton);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    terminalHeaderPanel.add(terminalToolBar, gridBagConstraints);
    terminalHeaderPanel.add(taskTrackerPanelDowncast, new java.awt.GridBagConstraints());
    terminalPanel.add(terminalHeaderPanel, java.awt.BorderLayout.PAGE_START);
    terminalTextPane.setEditable(false);
    terminalTextPane.setDragEnabled(false);
    terminalScrollPane.setViewportView(terminalTextPane);
    terminalPanel.add(terminalScrollPane, java.awt.BorderLayout.CENTER);
    outerSplitPane.setRightComponent(terminalPanel);
    getContentPane().add(outerSplitPane, java.awt.BorderLayout.CENTER);
    setJMenuBar(mainMenu);
    pack();
}
Example 29
Project: codjo-data-process-master  File: AbstractListWindow.java View source code
public static AbstractListWindow getListWindow(String preferenceId, JDesktopPane desktopPane) {
    Component[] components = desktopPane.getComponents();
    for (Component component : components) {
        if (component instanceof AbstractListWindow) {
            AbstractListWindow abstractListWindow = (AbstractListWindow) component;
            if (preferenceId.equals(abstractListWindow.getRequestTable().getPreference().getId())) {
                return abstractListWindow;
            }
        }
    }
    return null;
}
Example 30
Project: codjo-standalone-common-master  File: TableWindow.java View source code
/**
     * Init
     *
     * @param dp Le desktopPane dans lequel sera affichee la fenetre.
     * @param th Le TableHome.
     * @param conMan Le ConnectionManager.
     * @param packageOfTableDetailWindow Le nom du package où se trouve l'écran de
     *        détail.
     * @param whereClause La clause where pour l'affichage des tables propres à
     *        l'application.
     *
     * @exception SQLException -
     * @exception PersistenceException -
     */
private void init(JDesktopPane dp, TableHome th, ConnectionManager conMan, String packageOfTableDetailWindow, String whereClause) throws SQLException, PersistenceException {
    gexPane = dp;
    connectionManager = conMan;
    tableHome = th;
    pmTable = new GenericTable(tableHome.getTable("PM_TABLE"), true, whereClause, "ORDER BY DB_TABLE_NAME");
    tableToolBar = new PersistentToolBar(gexPane, pmTable, this, packageOfTableDetailWindow, false);
    pmLinkTable = new GenericTable(tableHome.getTable("PM_LINK_TABLE"), true, "WHERE DB_TABLE_NAME_ID = -1");
    tableNameRenderer = new TableNameRenderer(tableHome);
    pmLinkTable.getColumnByDbField("LINK_DB_TABLE_NAME_ID").setCellRenderer(tableNameRenderer);
    DbChangeListener l = tableHome.getDbChangeListener();
    try {
        tableToolBar.add(l);
    } catch (java.util.TooManyListenersException ex) {
    }
}
Example 31
Project: CompendiumNG-master  File: ProjectCompendiumFrame.java View source code
/**
	 * Creates and initializes the desktop.
	 */
protected void createDesktop() {
    oDesktop = new JDesktopPane();
    UIDesktopManager manager = new UIDesktopManager(oDesktop);
    oDesktop.setDesktopManager(manager);
    // Part of an attempt to use a scrollable desktop to make sure internal frame never
    // lost off the right/bottom bounderies.
    // Was buggy, so for now, just restricted the internalframe to the available space.
    /*JScrollPane scrollpane = new JScrollPane(oDesktop);
		(scrollpane.getVerticalScrollBar()).setUnitIncrement(100);
		(scrollpane.getHorizontalScrollBar()).setUnitIncrement(100);
		scrollpane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
		    public void adjustmentValueChanged(AdjustmentEvent evt) {
		        if (evt.getID() == AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED) {
	            	//log.info("vertical adjustment by:"+evt.getValue());
		        } 
		    }
		});
		scrollpane.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener() {
		    public void adjustmentValueChanged(AdjustmentEvent evt) {
		        if (evt.getID() == AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED) {
	            	log.info("horizontal adjustment by:"+evt.getValue());
		        } 
		    }
		});*/
    oSplitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, oTabbedPane, oDesktop);
    oSplitter.setOneTouchExpandable(true);
    oSplitter.setDividerSize(10);
    oSplitter.setContinuousLayout(true);
    oInnerPanel.add(oSplitter, BorderLayout.CENTER);
    oMainPanel.add(oInnerPanel, BorderLayout.CENTER);
    oWelcomePanel = new UIWelcomePane();
}
Example 32
Project: deegree2-desktop-master  File: IGeoDesktop.java View source code
/**
     * 
     * 
     */
@Override
public void paint() {
    if (this.proj != null) {
        processMonitor.updateStatus("initializing frame ...");
        initFrame();
        _AbstractViewFormType vfc = this.proj.getView().getViewForm().get_AbstractViewForm().getValue();
        this.frame.setResizable(((FrameViewFormType) vfc).isResizeable());
        String name = ((FrameViewFormType) vfc).getFrameTitle();
        this.frame.setTitle(getFrameTitle(name));
        if (modules.size() > 0 && modules.get(0).getViewForm() instanceof JInternalFrame) {
            // if at least one child module is an JInternalFrame the current content
            // pane must be replaced by a JDesktopPane
            this.frame.getContentPane().setLayout(new BorderLayout());
            rootTargetPane = new JDesktopPane();
            // rootTargetPane.setBackground( new Color( 145,129,98) );
            rootTargetPane.setBackground(new Color(138, 127, 106));
            this.frame.getContentPane().add(rootTargetPane, BorderLayout.CENTER);
        } else {
            rootTargetPane = new JPanel(new BorderLayout());
            this.frame.setContentPane(rootTargetPane);
        }
        boolean hscb = vfc.isUseHorizontalScrollBar();
        boolean vscb = vfc.isUseVerticalScrollBar();
        addFooter(this.frame.getContentPane());
        LayoutType layout = this.proj.getView().getViewForm().getLayout();
        rootTargetPane = setTargetLayout(layout, rootTargetPane, this.modules, hscb, vscb);
        addMenuBarEntries();
        addToolBarEntries();
        addPopupEntries();
        try {
            processMonitor.cancel();
        } catch (Exception e) {
            LOG.logError(e.getMessage(), e);
        }
        appendModules(this.modules, rootTargetPane);
        SwingUtilities.updateComponentTreeUI(frame);
        // frame.pack();
        WindowType w = this.proj.getView().getWindow();
        if (w.getWidth() > 0) {
            this.frame.setSize(w.getWidth(), w.getHeight());
            this.frame.setLocation(w.getLeft(), w.getTop());
            this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.frame.addWindowListener(new WindowAdapter() {

                @Override
                public void windowClosing(WindowEvent e) {
                    if (e.getWindow().equals(frame)) {
                        cleanUp();
                    }
                }
            });
            this.frame.setVisible(true);
        } else {
            LOG.logInfo("Application Container defined to be invisible");
        }
        this.frame.repaint();
    }
}
Example 33
Project: docx4all-master  File: WordMLEditor.java View source code
JComponent createMainPanel() {
    _desktop = new JDesktopPane();
    _desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    _desktop.setBackground(Color.LIGHT_GRAY);
    JPanel toolbar = FxScriptUIHelper.getInstance().createToolBar();
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(toolbar, BorderLayout.NORTH);
    panel.add(_desktop, BorderLayout.CENTER);
    // top, left, bottom, right
    panel.setBorder(new EmptyBorder(0, 2, 2, 2));
    panel.setPreferredSize(new Dimension(640, 480));
    return panel;
}
Example 34
Project: eent-for-android-master  File: Tigris2.java View source code
/**
	 * 
	 */
private void initComponents() {
    setTitle("Euphrates & Tigris");
    setFocusableWindowState(false);
    setFont(new Font("Arial", 0, 12));
    setLocationRelativeTo(this);
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            exitForm(e);
        }
    });
    jDesktopPane1 = new JDesktopPane();
    jDesktopPane1.add(board, JLayeredPane.DEFAULT_LAYER);
    tileBag = new Bag();
    currentBag = tileBag;
    players = new Player[2];
    HumanPlayer hump = new HumanPlayer();
    ComputerPlayer cpu = new ComputerPlayer();
    players[0] = (Player) hump;
    players[1] = (Player) cpu;
    playercount = 0;
    Board.currentPlayer = players[playercount];
    tileBag.setIcon(new ImageIcon(getClass().getResource("/images/bag-full.gif")));
    tileBag.setBorder(new BevelBorder(BevelBorder.RAISED));
    tileBag.setActionCommand("14");
    tileBag.setBounds(650, 280, 80, 70);
    tileBag.addActionListener(a2);
    jDesktopPane1.add(tileBag, JLayeredPane.DEFAULT_LAYER);
    int x = 50;
    int i = 0;
    for (; i < 6; i++) {
        uic[i] = new Grid(-1, x, 450, 35, 35, (String.valueOf(i) + "P"), null);
        uic[i].addActionListener(a1);
        x = x + 40;
        jDesktopPane1.add(uic[i], JLayeredPane.DEFAULT_LAYER);
    }
    /*
		 * give the players their civTiles
		 */
    for (int p = 0; p < players.length; p++) {
        if (players[p].isCPU()) {
            currentBag.setPlayerTiles(players[p]);
        } else {
            tileBag.setImage(players[p]);
        }
    }
    x = 320;
    /*
		 * Placing the leader tiles
		 */
    LeadTile[] templead = players[0].getLeaders();
    for (; i < 10; i++) {
        uic[i] = new Grid(-1, x, 460, 35, 35, (i + "L"), null);
        uic[i].setTile(templead[i - 6]);
        uic[i].addActionListener(a1);
        jDesktopPane1.add(uic[i], JLayeredPane.DEFAULT_LAYER);
        x = x + 40;
    }
    uic[10] = new Grid(-1, 530, 450, 35, 35, "10C", null);
    uic[10].setTile(new Tile(CatTile.CAT_TILE));
    uic[10].addActionListener(a1);
    jDesktopPane1.add(uic[10], JLayeredPane.DEFAULT_LAYER);
    uic[11] = new Grid(-1, 575, 450, 35, 35, "11C", null);
    uic[11].setTile(new Tile(CatTile.CAT_TILE));
    uic[11].addActionListener(a1);
    jDesktopPane1.add(uic[11], JLayeredPane.DEFAULT_LAYER);
    Cancel = new JButton();
    Cancel.setText("Cancel");
    Cancel.setBorder(new BevelBorder(BevelBorder.RAISED));
    Cancel.setActionCommand(CANCEL);
    Cancel.setBounds(650, 405, 80, 30);
    Cancel.addActionListener(a1);
    jDesktopPane1.add(Cancel, JLayeredPane.DEFAULT_LAYER);
    Ok = new JButton();
    Ok.setText("OK");
    Ok.setBorder(new BevelBorder(BevelBorder.RAISED));
    Ok.setActionCommand(OK);
    Ok.setBounds(650, 370, 80, 30);
    Ok.addActionListener(a1);
    jDesktopPane1.add(Ok, JLayeredPane.DEFAULT_LAYER);
    infolabel = new JLabel();
    infolabel.setText("Tigris & Euphrates");
    infolabel.setBorder(new LineBorder(new Color(0, 0, 0)));
    infolabel.setBounds(50, 510, 455, 30);
    infolabel.setBackground(Color.white);
    infolabel.setOpaque(true);
    jDesktopPane1.add(infolabel, JLayeredPane.DEFAULT_LAYER);
    ScoreBoard1 = new JLabel();
    ScoreBoard1.setHorizontalAlignment(SwingConstants.CENTER);
    ScoreBoard1.setBorder(new LineBorder(new Color(0, 0, 0), 4, true));
    ScoreBoard1.setBounds(550, 510, 30, 30);
    jDesktopPane1.add(ScoreBoard1, JLayeredPane.DEFAULT_LAYER);
    ScoreBoard2 = new JLabel();
    ScoreBoard2.setHorizontalAlignment(SwingConstants.CENTER);
    ScoreBoard2.setBorder(new LineBorder(new Color(255, 0, 0), 4, true));
    ScoreBoard2.setBounds(590, 510, 30, 30);
    jDesktopPane1.add(ScoreBoard2, JLayeredPane.DEFAULT_LAYER);
    ScoreBoard3 = new JLabel();
    ScoreBoard3.setHorizontalAlignment(SwingConstants.CENTER);
    ScoreBoard3.setBorder(new LineBorder(new Color(0, 51, 255), 4, true));
    ScoreBoard3.setBounds(630, 510, 30, 30);
    jDesktopPane1.add(ScoreBoard3, JLayeredPane.DEFAULT_LAYER);
    ScoreBoard4 = new JLabel();
    ScoreBoard4.setHorizontalAlignment(SwingConstants.CENTER);
    ScoreBoard4.setBorder(new LineBorder(new Color(0, 204, 0), 4, true));
    ScoreBoard4.setBounds(670, 510, 30, 30);
    jDesktopPane1.add(ScoreBoard4, JLayeredPane.DEFAULT_LAYER);
    /*
		 * Checkboxes te swap player tiles
		 */
    jCheckBox1 = new JCheckBox();
    jCheckBox1.setBackground((Color) UIManager.getDefaults().get("Button.focus"));
    jCheckBox1.setMargin(new Insets(0, 0, 0, 0));
    jCheckBox1.setBounds(60, 490, 15, 15);
    jCheckBox1.addItemListener(a3);
    jDesktopPane1.add(jCheckBox1, JLayeredPane.DEFAULT_LAYER);
    jCheckBox2 = new JCheckBox();
    jCheckBox2.setBackground((Color) UIManager.getDefaults().get("Button.focus"));
    jCheckBox2.setMargin(new Insets(0, 0, 0, 0));
    jCheckBox2.setBounds(100, 490, 15, 15);
    jCheckBox2.addItemListener(a3);
    jDesktopPane1.add(jCheckBox2, JLayeredPane.DEFAULT_LAYER);
    jCheckBox3 = new JCheckBox();
    jCheckBox3.setBackground((Color) UIManager.getDefaults().get("Button.focus"));
    jCheckBox3.setMargin(new Insets(0, 0, 0, 0));
    jCheckBox3.setBounds(140, 490, 15, 15);
    jCheckBox3.addItemListener(a3);
    jDesktopPane1.add(jCheckBox3, JLayeredPane.DEFAULT_LAYER);
    jCheckBox4 = new JCheckBox();
    jCheckBox4.setBackground((Color) UIManager.getDefaults().get("Button.focus"));
    jCheckBox4.setMargin(new Insets(0, 0, 0, 0));
    jCheckBox4.setBounds(180, 490, 15, 15);
    jCheckBox4.addItemListener(a3);
    jDesktopPane1.add(jCheckBox4, JLayeredPane.DEFAULT_LAYER);
    jCheckBox5 = new JCheckBox();
    jCheckBox5.setBackground((Color) UIManager.getDefaults().get("Button.focus"));
    jCheckBox5.setMargin(new Insets(0, 0, 0, 0));
    jCheckBox5.setBounds(220, 490, 15, 15);
    jCheckBox5.addItemListener(a3);
    jDesktopPane1.add(jCheckBox5, JLayeredPane.DEFAULT_LAYER);
    jCheckBox6 = new JCheckBox();
    jCheckBox6.setBackground((Color) UIManager.getDefaults().get("Button.focus"));
    jCheckBox6.setMargin(new Insets(0, 0, 0, 0));
    jCheckBox6.setBounds(260, 490, 15, 15);
    jCheckBox6.addItemListener(a3);
    jDesktopPane1.add(jCheckBox6, JLayeredPane.DEFAULT_LAYER);
    swap = new JLabel();
    swap.setText("Swap");
    swap.setBounds(10, 490, 41, 16);
    jDesktopPane1.add(swap, JLayeredPane.DEFAULT_LAYER);
    getContentPane().add(jDesktopPane1, BorderLayout.CENTER);
}
Example 35
Project: griffon-master  File: SwingUtils.java View source code
/**
     * Centers a JInternalFrame on the screen<p>
     * Sets the internal frame on the top left corner if the frame's
     * dimensions are bigger than the desktop's.
     *
     * @param internalFrame a JInternalFrame object
     */
public static void centerOnScreen(@Nonnull JInternalFrame internalFrame) {
    requireNonNull(internalFrame, "Argument 'internalFrame' must not be null");
    JDesktopPane desktop = internalFrame.getDesktopPane();
    if (desktop == null)
        return;
    Dimension screen = desktop.getSize();
    Point center = new Point(screen.width / 2, screen.height / 2);
    double w = Math.min(internalFrame.getWidth(), screen.width);
    double h = Math.min(internalFrame.getHeight(), screen.height);
    int x = (int) (center.x - (w / 2));
    int y = (int) (center.y - (h / 2));
    Point corner = new Point((x >= 0 ? x : 0), (y >= 0 ? y : 0));
    internalFrame.setLocation(corner);
}
Example 36
Project: lilith-master  File: ViewContainerInternalFrame.java View source code
public void closeWindow() {
    if (logger.isDebugEnabled())
        logger.debug("Closing InternalFrame...");
    JDesktopPane desktop = mainFrame.getDesktop();
    if (logger.isDebugEnabled()) {
        JInternalFrame[] frames = desktop.getAllFrames();
        StringBuilder result = new StringBuilder();
        result.append("before closing:\n");
        if (frames != null) {
            for (JInternalFrame current : frames) {
                result.append(current).append("\n");
            }
        }
        logger.debug(result.toString());
    }
    setVisible(false);
    try {
        setClosed(true);
    } catch (PropertyVetoException ex) {
        if (logger.isWarnEnabled())
            logger.warn("Couldn't close InternalFrame!", ex);
    }
    if (logger.isDebugEnabled()) {
        JInternalFrame[] frames = desktop.getAllFrames();
        StringBuilder result = new StringBuilder();
        result.append("after closing:\n");
        if (frames != null) {
            for (JInternalFrame current : frames) {
                result.append(current).append("\n");
            }
        }
        logger.debug(result.toString());
    }
    if (logger.isInfoEnabled())
        logger.info("Closed InternalFrame...");
}
Example 37
Project: openDLX-master  File: MainFrame.java View source code
private void initialize() {
    undoMgr = new UndoManager();
    //uses a factory to outsource creation of the menuBar
    MainFrameMenuBarFactory menuBarFactory = new MainFrameMenuBarFactory(this, this, this);
    Hashtable<String, JMenuItem> importantItems = new Hashtable<>();
    menuBar = menuBarFactory.createJMenuBar(importantItems);
    setJMenuBar(menuBar);
    forwardingMenuItem = importantItems.get(MainFrameMenuBarFactory.STRING_MENU_SIMULATOR_FORWARDING);
    setMinimumSize(new Dimension(200, 200));
    desktop = new JDesktopPane();
    desktop.setBackground(Color.WHITE);
    setContentPane(desktop);
    editor = EditorFrame.getInstance(this);
    editor.setUndoManager(undoMgr);
    desktop.add(editor);
    output = Output.getInstance(mf);
    input = Input.getInstance(mf);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setMinimumSize(new Dimension(200, 200));
    setExtendedState(MAXIMIZED_BOTH);
    setVisible(true);
    /// select editor frame
    try {
        editor.setSelected(true);
    } catch (PropertyVetoException e1) {
        e1.printStackTrace();
    }
    setOpenDLXSimState(OpenDLXSimState.IDLE);
    pexHandler = new PipelineExceptionHandler(this);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            MainFrame frame = (MainFrame) e.getSource();
            CommandExitProgram exit = new CommandExitProgram(frame);
            if (exit.close())
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
    });
}
Example 38
Project: sdrtrunk-master  File: Viewer.java View source code
/**
     * Initialize the contents of the frame.
     */
private void initGUI() {
    /* Setup main JFrame window */
    mFrame = new JFrame();
    mFrame.setTitle("SDRTrunk - Sample File Viewer");
    mFrame.setBounds(100, 100, 800, 600);
    mFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    /* Multi-window desktop */
    mDesktop = new JDesktopPane();
    mFrame.add(mDesktop);
    /* Menu items */
    JMenuBar menuBar = new JMenuBar();
    mFrame.setJMenuBar(menuBar);
    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);
    fileMenu.add(new SourceFileItem());
    fileMenu.add(new JSeparator());
    JMenuItem exitMenu = new JMenuItem("Exit");
    exitMenu.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            System.exit(0);
        }
    });
    fileMenu.add(exitMenu);
    menuBar.add(new ScreenCaptureItem());
}
Example 39
Project: Thaw-master  File: LiquidInternalFrameUI.java View source code
JDesktopPane getDesktopPane(JComponent frame) {
    JDesktopPane pane = null;
    Component c = frame.getParent();
    // Find the JDesktopPane
    while (pane == null) {
        if (c instanceof JDesktopPane) {
            pane = (JDesktopPane) c;
        } else if (c == null) {
            break;
        } else {
            c = c.getParent();
        }
    }
    return pane;
}
Example 40
Project: twist-master  File: ServiceConsole.java View source code
@Override
public void init(ArrayList<Item> suite, ArrayList<Item> suitetest, final Hashtable<String, String> variables, Document pluginsConfig, Applet container) {
    super.init(suite, suitetest, variables, pluginsConfig, container);
    System.out.println("Initializing " + getName() + " ... ");
    //initializeSFTP();
    initializeRPC();
    //createXMLStructure();
    JMenuBar menubar = new JMenuBar();
    JMenu menu = new JMenu("Services");
    menubar.add(menu);
    final JDesktopPane pane = new JDesktopPane();
    p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add(menubar, BorderLayout.NORTH);
    p.add(pane, BorderLayout.CENTER);
    String[] serv = getServices();
    services = new JCheckBox[serv.length];
    for (int i = 0; i < serv.length; i++) {
        services[i] = new JCheckBox(serv[i]);
        services[i].addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (((JCheckBox) arg0.getSource()).isSelected()) {
                    MyInternalFrame frame = new MyInternalFrame(((JCheckBox) arg0.getSource()).getText());
                    pane.add(frame);
                    frame.setLocation(50, 10);
                    frame.setSize(300, 200);
                    frame.setVisible(true);
                } else {
                    for (JInternalFrame f : pane.getAllFrames()) {
                        if (f.getTitle().equals(((JCheckBox) arg0.getSource()).getText())) {
                            f.dispose();
                            break;
                        }
                    }
                }
            }
        });
        menu.add(services[i]);
    }
    System.out.println(getName() + " initialized");
}
Example 41
Project: twister.github.io-master  File: ServiceConsole.java View source code
@Override
public void init(ArrayList<Item> suite, ArrayList<Item> suitetest, final Hashtable<String, String> variables, Document pluginsConfig, Applet container) {
    super.init(suite, suitetest, variables, pluginsConfig, container);
    System.out.println("Initializing " + getName() + " ... ");
    //initializeSFTP();
    initializeRPC();
    //createXMLStructure();
    JMenuBar menubar = new JMenuBar();
    JMenu menu = new JMenu("Services");
    menubar.add(menu);
    final JDesktopPane pane = new JDesktopPane();
    p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add(menubar, BorderLayout.NORTH);
    p.add(pane, BorderLayout.CENTER);
    String[] serv = getServices();
    services = new JCheckBox[serv.length];
    for (int i = 0; i < serv.length; i++) {
        services[i] = new JCheckBox(serv[i]);
        services[i].addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (((JCheckBox) arg0.getSource()).isSelected()) {
                    MyInternalFrame frame = new MyInternalFrame(((JCheckBox) arg0.getSource()).getText());
                    pane.add(frame);
                    frame.setLocation(50, 10);
                    frame.setSize(300, 200);
                    frame.setVisible(true);
                } else {
                    for (JInternalFrame f : pane.getAllFrames()) {
                        if (f.getTitle().equals(((JCheckBox) arg0.getSource()).getText())) {
                            f.dispose();
                            break;
                        }
                    }
                }
            }
        });
        menu.add(services[i]);
    }
    System.out.println(getName() + " initialized");
}
Example 42
Project: windowtester-master  File: AWTHierarchy.java View source code
/** Return all descendents of interest of the given Component.
        This includes owned windows for Windows, children for Containers.
     */
public Collection getComponents(Component c) {
    if (c instanceof Container) {
        Container cont = (Container) c;
        ArrayList list = new ArrayList();
        list.addAll(Arrays.asList(cont.getComponents()));
        // that are conceptually descendents 
        if (c instanceof JMenu) {
            list.add(((JMenu) c).getPopupMenu());
        } else if (c instanceof Window) {
            list.addAll(Arrays.asList(((Window) c).getOwnedWindows()));
        } else if (c instanceof JDesktopPane) {
            // Add iconified frames, which are otherwise unreachable.
            // For consistency, they are still considerered children of
            // the desktop pane.
            list.addAll(findInternalFramesFromIcons(cont));
        }
        return list;
    }
    return EMPTY;
}
Example 43
Project: WebCams-master  File: WebcamStudio.java View source code
/**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    mainToolbar = new javax.swing.JToolBar();
    btnNewStudio = new javax.swing.JButton();
    btnImportStudio = new javax.swing.JButton();
    btnSaveStudio = new javax.swing.JButton();
    WCSAbout = new javax.swing.JButton();
    jSeparator16 = new javax.swing.JToolBar.Separator();
    filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(3, 0), new java.awt.Dimension(0, 0));
    cboWebcam = new javax.swing.JComboBox();
    btnAddWebcams = new javax.swing.JButton();
    btnRefreshWebcam = new javax.swing.JButton();
    btnVideoDevInfo = new javax.swing.JButton();
    jSeparator17 = new javax.swing.JToolBar.Separator();
    jLabel2 = new javax.swing.JLabel();
    cboAudioHz = new javax.swing.JComboBox();
    filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(2, 0), new java.awt.Dimension(0, 0));
    jSeparator10 = new javax.swing.JToolBar.Separator();
    jLabel3 = new javax.swing.JLabel();
    cboTheme = new javax.swing.JComboBox();
    filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(2, 0), new java.awt.Dimension(0, 0));
    jSeparator7 = new javax.swing.JToolBar.Separator();
    btnSysGC = new javax.swing.JButton();
    lblClrRam = new javax.swing.JLabel();
    filler5 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(2, 0), new java.awt.Dimension(0, 0));
    jSeparator12 = new javax.swing.JToolBar.Separator();
    filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(3, 0), new java.awt.Dimension(0, 0));
    filler7 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0));
    lblFFmpeg3 = new javax.swing.JLabel();
    tglFFmpeg = new javax.swing.JToggleButton();
    lblFFmpeg = new javax.swing.JLabel();
    tglAVconv = new javax.swing.JToggleButton();
    lblAVconv = new javax.swing.JLabel();
    tglGst = new javax.swing.JToggleButton();
    lblGst = new javax.swing.JLabel();
    filler6 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(3, 0), new java.awt.Dimension(0, 0));
    jSeparator13 = new javax.swing.JToolBar.Separator();
    mainVerticalSplit = new javax.swing.JSplitPane();
    masterPanelSplit = new javax.swing.JSplitPane();
    panMaster = new javax.swing.JPanel();
    mainSplit = new javax.swing.JSplitPane();
    panSources = new javax.swing.JPanel();
    toolbar = new javax.swing.JToolBar();
    btnAddFile = new javax.swing.JButton();
    btnAddFolder = new javax.swing.JButton();
    tglAutoAR = new javax.swing.JToggleButton();
    jSeparator3 = new javax.swing.JToolBar.Separator();
    btnAddDVB = new javax.swing.JButton();
    btnAddURL = new javax.swing.JButton();
    btnAddIPCam = new javax.swing.JButton();
    btnAddDVCam = new javax.swing.JButton();
    btnAddHDVCam = new javax.swing.JButton();
    btnAddDesktop = new javax.swing.JButton();
    btnAddText = new javax.swing.JButton();
    btnAddAudioSrc = new javax.swing.JButton();
    jSeparator1 = new javax.swing.JToolBar.Separator();
    cboAnimations = new javax.swing.JComboBox();
    btnAddAnimation = new javax.swing.JButton();
    jSeparator2 = new javax.swing.JToolBar.Separator();
    btnMinimizeTab = new javax.swing.JButton();
    btnMinimizeAll = new javax.swing.JButton();
    tabSources = new javax.swing.JTabbedPane();
    cameraDesktop = new javax.swing.JDesktopPane();
    videoDesktop = new javax.swing.JDesktopPane();
    musicDesktop = new javax.swing.JDesktopPane();
    pictureDesktop = new javax.swing.JDesktopPane();
    dvbDesktop = new javax.swing.JDesktopPane();
    urlDesktop = new javax.swing.JDesktopPane();
    desktopDesktop = new javax.swing.JDesktopPane();
    textDesktop = new javax.swing.JDesktopPane();
    audioInDesktop = new javax.swing.JDesktopPane();
    panControls = new javax.swing.JPanel();
    tabControls = new javax.swing.JTabbedPane();
    lblSourceSelected = new javax.swing.JLabel();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("WebcamStudio");
    addWindowListener(new java.awt.event.WindowAdapter() {

        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });
    mainToolbar.setFloatable(false);
    mainToolbar.setMargin(new java.awt.Insets(0, 0, 0, 50));
    // NOI18N
    mainToolbar.setName("mainToolbar");
    // NOI18N
    btnNewStudio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/document-new.png")));
    btnNewStudio.setToolTipText("New Studio");
    btnNewStudio.setFocusable(false);
    btnNewStudio.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNewStudio.setMaximumSize(new java.awt.Dimension(29, 28));
    btnNewStudio.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnNewStudio.setName("btnNewStudio");
    btnNewStudio.setPreferredSize(new java.awt.Dimension(28, 28));
    btnNewStudio.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnNewStudio.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnNewStudioActionPerformed(evt);
        }
    });
    mainToolbar.add(btnNewStudio);
    // NOI18N
    btnLoadStudio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/document-open.png")));
    // NOI18N
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("webcamstudio/Languages");
    // NOI18N
    btnLoadStudio.setToolTipText(bundle.getString("LOAD"));
    btnLoadStudio.setFocusable(false);
    btnLoadStudio.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnLoadStudio.setMaximumSize(new java.awt.Dimension(29, 28));
    btnLoadStudio.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnLoadStudio.setName("btnLoadStudio");
    btnLoadStudio.setPreferredSize(new java.awt.Dimension(28, 28));
    btnLoadStudio.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnLoadStudio.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnLoadStudioActionPerformed(evt);
        }
    });
    mainToolbar.add(btnLoadStudio);
    // NOI18N
    btnImportStudio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/chan-add.png")));
    btnImportStudio.setToolTipText("Import Studio");
    btnImportStudio.setFocusable(false);
    btnImportStudio.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnImportStudio.setMaximumSize(new java.awt.Dimension(29, 28));
    btnImportStudio.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnImportStudio.setName("btnImportStudio");
    btnImportStudio.setPreferredSize(new java.awt.Dimension(28, 28));
    btnImportStudio.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnImportStudio.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnImportStudioActionPerformed(evt);
        }
    });
    mainToolbar.add(btnImportStudio);
    // NOI18N
    btnSaveStudio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/document-save.png")));
    // NOI18N
    btnSaveStudio.setToolTipText(bundle.getString("SAVE"));
    btnSaveStudio.setFocusable(false);
    btnSaveStudio.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnSaveStudio.setMaximumSize(new java.awt.Dimension(29, 28));
    btnSaveStudio.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnSaveStudio.setName("btnSaveStudio");
    btnSaveStudio.setPreferredSize(new java.awt.Dimension(28, 28));
    btnSaveStudio.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnSaveStudio.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSaveStudioActionPerformed(evt);
        }
    });
    mainToolbar.add(btnSaveStudio);
    // NOI18N
    WCSAbout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/user-info.png")));
    WCSAbout.setToolTipText("About");
    WCSAbout.setFocusable(false);
    WCSAbout.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    WCSAbout.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
    WCSAbout.setMaximumSize(new java.awt.Dimension(29, 28));
    WCSAbout.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    WCSAbout.setName("WCSAbout");
    WCSAbout.setPreferredSize(new java.awt.Dimension(28, 28));
    WCSAbout.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    WCSAbout.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            WCSAboutActionPerformed(evt);
        }
    });
    mainToolbar.add(WCSAbout);
    jSeparator16.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    // NOI18N
    jSeparator16.setFont(new java.awt.Font("Ubuntu", 1, 15));
    // NOI18N
    jSeparator16.setName("jSeparator16");
    jSeparator16.setOpaque(true);
    jSeparator16.setSeparatorSize(new java.awt.Dimension(3, 10));
    mainToolbar.add(jSeparator16);
    // NOI18N
    filler1.setName("filler1");
    mainToolbar.add(filler1);
    cboWebcam.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    cboWebcam.setToolTipText("Detected Video Devices");
    cboWebcam.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    // NOI18N
    cboWebcam.setName("cboWebcam");
    mainToolbar.add(cboWebcam);
    // NOI18N
    btnAddWebcams.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/camera-video.png")));
    btnAddWebcams.setToolTipText("Add Selected Device");
    btnAddWebcams.setFocusable(false);
    btnAddWebcams.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddWebcams.setMaximumSize(new java.awt.Dimension(29, 28));
    btnAddWebcams.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnAddWebcams.setName("btnAddWebcams");
    btnAddWebcams.setPreferredSize(new java.awt.Dimension(28, 28));
    btnAddWebcams.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddWebcams.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddWebcamsActionPerformed(evt);
        }
    });
    mainToolbar.add(btnAddWebcams);
    // NOI18N
    btnRefreshWebcam.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/view-refresh.png")));
    btnRefreshWebcam.setToolTipText("Refresh Video Devices Detection");
    btnRefreshWebcam.setFocusable(false);
    btnRefreshWebcam.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnRefreshWebcam.setMaximumSize(new java.awt.Dimension(29, 28));
    btnRefreshWebcam.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnRefreshWebcam.setName("btnRefreshWebcam");
    btnRefreshWebcam.setPreferredSize(new java.awt.Dimension(28, 28));
    btnRefreshWebcam.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnRefreshWebcam.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnRefreshWebcamActionPerformed(evt);
        }
    });
    mainToolbar.add(btnRefreshWebcam);
    // NOI18N
    btnVideoDevInfo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/camera-info.png")));
    // NOI18N
    btnVideoDevInfo.setToolTipText(bundle.getString("VIDEO_DEVICE_INFO"));
    btnVideoDevInfo.setFocusable(false);
    btnVideoDevInfo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnVideoDevInfo.setMaximumSize(new java.awt.Dimension(29, 28));
    btnVideoDevInfo.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnVideoDevInfo.setName("btnVideoDevInfo");
    btnVideoDevInfo.setPreferredSize(new java.awt.Dimension(28, 28));
    btnVideoDevInfo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnVideoDevInfo.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnVideoDevInfoActionPerformed(evt);
        }
    });
    mainToolbar.add(btnVideoDevInfo);
    jSeparator17.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    // NOI18N
    jSeparator17.setFont(new java.awt.Font("Ubuntu", 1, 15));
    // NOI18N
    jSeparator17.setName("jSeparator17");
    jSeparator17.setOpaque(true);
    jSeparator17.setSeparatorSize(new java.awt.Dimension(5, 10));
    mainToolbar.add(jSeparator17);
    // NOI18N
    jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/audio-Hz.png")));
    jLabel2.setToolTipText("Master Audio Sample Rate");
    jLabel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 1));
    // NOI18N
    jLabel2.setName("jLabel2");
    mainToolbar.add(jLabel2);
    cboAudioHz.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    cboAudioHz.setToolTipText("Choose Default Audio Output Quality.");
    // NOI18N
    cboAudioHz.setName("cboAudioHz");
    cboAudioHz.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cboAudioHzActionPerformed(evt);
        }
    });
    mainToolbar.add(cboAudioHz);
    // NOI18N
    filler2.setName("filler2");
    mainToolbar.add(filler2);
    jSeparator10.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    // NOI18N
    jSeparator10.setFont(new java.awt.Font("Ubuntu", 1, 15));
    // NOI18N
    jSeparator10.setName("jSeparator10");
    jSeparator10.setOpaque(true);
    jSeparator10.setSeparatorSize(new java.awt.Dimension(5, 10));
    mainToolbar.add(jSeparator10);
    // NOI18N
    jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/image-x-generic.png")));
    jLabel3.setToolTipText("Master Theme Selector");
    jLabel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 1));
    // NOI18N
    jLabel3.setName("jLabel3");
    mainToolbar.add(jLabel3);
    cboTheme.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    cboTheme.setToolTipText("Choose Default WS Theme.");
    // NOI18N
    cboTheme.setName("cboTheme");
    cboTheme.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cboThemeActionPerformed(evt);
        }
    });
    mainToolbar.add(cboTheme);
    // NOI18N
    filler3.setName("filler3");
    mainToolbar.add(filler3);
    jSeparator7.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    // NOI18N
    jSeparator7.setFont(new java.awt.Font("Ubuntu", 1, 15));
    // NOI18N
    jSeparator7.setName("jSeparator7");
    jSeparator7.setOpaque(true);
    jSeparator7.setSeparatorSize(new java.awt.Dimension(5, 10));
    mainToolbar.add(jSeparator7);
    // NOI18N
    btnSysGC.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/button-small-clear.png")));
    btnSysGC.setToolTipText("Try to Clean Up some memory");
    btnSysGC.setFocusable(false);
    // NOI18N
    btnSysGC.setName("btnSysGC");
    btnSysGC.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnSysGC.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSysGCActionPerformed(evt);
        }
    });
    mainToolbar.add(btnSysGC);
    // NOI18N
    lblClrRam.setFont(new java.awt.Font("Ubuntu Condensed", 0, 12));
    lblClrRam.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lblClrRam.setText("RAM");
    lblClrRam.setToolTipText("Try to Clean Up some memory");
    // NOI18N
    lblClrRam.setName("lblClrRam");
    mainToolbar.add(lblClrRam);
    // NOI18N
    filler5.setName("filler5");
    mainToolbar.add(filler5);
    jSeparator12.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    // NOI18N
    jSeparator12.setFont(new java.awt.Font("Ubuntu", 1, 15));
    // NOI18N
    jSeparator12.setName("jSeparator12");
    jSeparator12.setOpaque(true);
    jSeparator12.setSeparatorSize(new java.awt.Dimension(5, 10));
    mainToolbar.add(jSeparator12);
    // NOI18N
    filler4.setName("filler4");
    mainToolbar.add(filler4);
    // NOI18N
    filler7.setName("filler7");
    mainToolbar.add(filler7);
    lblFFmpeg3.setBackground(new java.awt.Color(102, 102, 102));
    // NOI18N
    lblFFmpeg3.setFont(new java.awt.Font("Ubuntu Condensed", 1, 14));
    lblFFmpeg3.setText("OUT BackEnd: ");
    lblFFmpeg3.setToolTipText("Select Available Outputs Back-Ends");
    // NOI18N
    lblFFmpeg3.setName("lblFFmpeg3");
    mainToolbar.add(lblFFmpeg3);
    // NOI18N
    tglFFmpeg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/FFmpeg.png")));
    tglFFmpeg.setToolTipText("Use FFmpeg Output Backend.");
    tglFFmpeg.setFocusable(false);
    tglFFmpeg.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    tglFFmpeg.setMaximumSize(new java.awt.Dimension(29, 28));
    tglFFmpeg.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    tglFFmpeg.setName("tglFFmpeg");
    tglFFmpeg.setPreferredSize(new java.awt.Dimension(28, 29));
    // NOI18N
    tglFFmpeg.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/FFmpeg.png")));
    // NOI18N
    tglFFmpeg.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/FFmpegSelected.png")));
    tglFFmpeg.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    tglFFmpeg.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tglFFmpegActionPerformed(evt);
        }
    });
    mainToolbar.add(tglFFmpeg);
    // NOI18N
    lblFFmpeg.setFont(new java.awt.Font("Ubuntu Condensed", 0, 12));
    lblFFmpeg.setText("FFmpeg  ");
    // NOI18N
    lblFFmpeg.setName("lblFFmpeg");
    mainToolbar.add(lblFFmpeg);
    // NOI18N
    tglAVconv.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/FFmpeg.png")));
    tglAVconv.setToolTipText("Use Libav Output Backend.");
    tglAVconv.setFocusable(false);
    tglAVconv.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    tglAVconv.setMaximumSize(new java.awt.Dimension(29, 28));
    tglAVconv.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    tglAVconv.setName("tglAVconv");
    tglAVconv.setPreferredSize(new java.awt.Dimension(28, 29));
    // NOI18N
    tglAVconv.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/FFmpeg.png")));
    // NOI18N
    tglAVconv.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/FFmpegSelected.png")));
    tglAVconv.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    tglAVconv.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tglAVconvActionPerformed(evt);
        }
    });
    mainToolbar.add(tglAVconv);
    // NOI18N
    lblAVconv.setFont(new java.awt.Font("Ubuntu Condensed", 0, 12));
    lblAVconv.setText("Libav ");
    // NOI18N
    lblAVconv.setName("lblAVconv");
    mainToolbar.add(lblAVconv);
    // NOI18N
    tglGst.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/gstreamer.png")));
    tglGst.setToolTipText("Use GStreamer Output Backend.");
    tglGst.setFocusable(false);
    tglGst.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    tglGst.setMaximumSize(new java.awt.Dimension(29, 28));
    tglGst.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    tglGst.setName("tglGst");
    tglGst.setPreferredSize(new java.awt.Dimension(28, 29));
    // NOI18N
    tglGst.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/gstreamer.png")));
    // NOI18N
    tglGst.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/gstreamerSelected.png")));
    tglGst.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    tglGst.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tglGstActionPerformed(evt);
        }
    });
    mainToolbar.add(tglGst);
    // NOI18N
    lblGst.setFont(new java.awt.Font("Ubuntu Condensed", 0, 12));
    lblGst.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    lblGst.setText("GStreamer");
    // NOI18N
    lblGst.setName("lblGst");
    mainToolbar.add(lblGst);
    // NOI18N
    filler6.setName("filler6");
    mainToolbar.add(filler6);
    jSeparator13.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    // NOI18N
    jSeparator13.setFont(new java.awt.Font("Ubuntu", 1, 15));
    // NOI18N
    jSeparator13.setName("jSeparator13");
    jSeparator13.setOpaque(true);
    jSeparator13.setSeparatorSize(new java.awt.Dimension(5, 10));
    mainToolbar.add(jSeparator13);
    getContentPane().add(mainToolbar, java.awt.BorderLayout.PAGE_START);
    mainVerticalSplit.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    // NOI18N
    mainVerticalSplit.setName("mainVerticalSplit");
    mainVerticalSplit.setOneTouchExpandable(true);
    masterPanelSplit.setDividerSize(0);
    // NOI18N
    masterPanelSplit.setName("masterPanelSplit");
    // NOI18N
    panMaster.setName("panMaster");
    panMaster.setLayout(new java.awt.BorderLayout());
    masterPanelSplit.setLeftComponent(panMaster);
    mainSplit.setDividerLocation(500);
    // NOI18N
    mainSplit.setName("mainSplit");
    mainSplit.setOneTouchExpandable(true);
    // NOI18N
    panSources.setName("panSources");
    toolbar.setFloatable(false);
    toolbar.setRollover(true);
    toolbar.setMinimumSize(new java.awt.Dimension(200, 34));
    // NOI18N
    toolbar.setName("toolbar");
    // NOI18N
    btnAddFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/studio-add.png")));
    btnAddFile.setToolTipText("Load Media");
    btnAddFile.setFocusable(false);
    btnAddFile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddFile.setMaximumSize(new java.awt.Dimension(29, 28));
    btnAddFile.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnAddFile.setName("btnAddFile");
    btnAddFile.setPreferredSize(new java.awt.Dimension(28, 28));
    btnAddFile.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddFile.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddFileActionPerformed(evt);
        }
    });
    toolbar.add(btnAddFile);
    // NOI18N
    btnAddFolder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/media-add-folder.png")));
    btnAddFolder.setToolTipText("Load Media Folder");
    btnAddFolder.setFocusable(false);
    btnAddFolder.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddFolder.setMaximumSize(new java.awt.Dimension(29, 28));
    btnAddFolder.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnAddFolder.setName("btnAddFolder");
    btnAddFolder.setPreferredSize(new java.awt.Dimension(28, 28));
    btnAddFolder.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddFolder.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddFolderActionPerformed(evt);
        }
    });
    toolbar.add(btnAddFolder);
    // NOI18N
    tglAutoAR.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/ar_button.png")));
    tglAutoAR.setToolTipText("Automatic A/R detection Switch.");
    tglAutoAR.setFocusable(false);
    tglAutoAR.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    tglAutoAR.setMaximumSize(new java.awt.Dimension(29, 28));
    tglAutoAR.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    tglAutoAR.setName("tglAutoAR");
    tglAutoAR.setPreferredSize(new java.awt.Dimension(28, 29));
    // NOI18N
    tglAutoAR.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/ar_button.png")));
    // NOI18N
    tglAutoAR.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/ar_button_selected.png")));
    tglAutoAR.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    tglAutoAR.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tglAutoARActionPerformed(evt);
        }
    });
    toolbar.add(tglAutoAR);
    // NOI18N
    jSeparator3.setFont(new java.awt.Font("Ubuntu", 1, 15));
    // NOI18N
    jSeparator3.setName("jSeparator3");
    jSeparator3.setOpaque(true);
    toolbar.add(jSeparator3);
    // NOI18N
    btnAddDVB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/dvb.png")));
    btnAddDVB.setToolTipText("Add DVB-T Stream");
    btnAddDVB.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    btnAddDVB.setFocusable(false);
    btnAddDVB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddDVB.setMaximumSize(new java.awt.Dimension(29, 28));
    btnAddDVB.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnAddDVB.setName("btnAddDVB");
    btnAddDVB.setPreferredSize(new java.awt.Dimension(28, 28));
    btnAddDVB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddDVB.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddDVBActionPerformed(evt);
        }
    });
    toolbar.add(btnAddDVB);
    // NOI18N
    btnAddURL.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/url5.png")));
    btnAddURL.setToolTipText("Add URL Stream");
    btnAddURL.setFocusable(false);
    btnAddURL.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddURL.setMaximumSize(new java.awt.Dimension(29, 28));
    btnAddURL.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnAddURL.setName("btnAddURL");
    btnAddURL.setPreferredSize(new java.awt.Dimension(28, 28));
    btnAddURL.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddURL.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddURLActionPerformed(evt);
        }
    });
    toolbar.add(btnAddURL);
    // NOI18N
    btnAddIPCam.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/ip-cam-2.png")));
    btnAddIPCam.setToolTipText("Add IPCam Stream");
    btnAddIPCam.setFocusable(false);
    btnAddIPCam.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddIPCam.setMaximumSize(new java.awt.Dimension(29, 28));
    btnAddIPCam.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnAddIPCam.setName("btnAddIPCam");
    btnAddIPCam.setPreferredSize(new java.awt.Dimension(28, 28));
    btnAddIPCam.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddIPCam.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddIPCamActionPerformed(evt);
        }
    });
    toolbar.add(btnAddIPCam);
    // NOI18N
    btnAddDVCam.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/Firewire.png")));
    btnAddDVCam.setToolTipText("Add DVCam Stream");
    btnAddDVCam.setFocusable(false);
    btnAddDVCam.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddDVCam.setMaximumSize(new java.awt.Dimension(29, 28));
    btnAddDVCam.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnAddDVCam.setName("btnAddDVCam");
    btnAddDVCam.setPreferredSize(new java.awt.Dimension(28, 28));
    btnAddDVCam.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddDVCam.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddDVCamActionPerformed(evt);
        }
    });
    toolbar.add(btnAddDVCam);
    // NOI18N
    btnAddHDVCam.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/HDV2.png")));
    btnAddHDVCam.setToolTipText("Add Firewire HDV Stream");
    btnAddHDVCam.setFocusable(false);
    btnAddHDVCam.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddHDVCam.setMaximumSize(new java.awt.Dimension(29, 28));
    btnAddHDVCam.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnAddHDVCam.setName("btnAddHDVCam");
    btnAddHDVCam.setPreferredSize(new java.awt.Dimension(28, 28));
    btnAddHDVCam.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddHDVCam.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddHDVCamActionPerformed(evt);
        }
    });
    toolbar.add(btnAddHDVCam);
    // NOI18N
    btnAddDesktop.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/user-desktop.png")));
    // NOI18N
    btnAddDesktop.setToolTipText(bundle.getString("DESKTOP"));
    btnAddDesktop.setFocusable(false);
    btnAddDesktop.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddDesktop.setMaximumSize(new java.awt.Dimension(29, 28));
    btnAddDesktop.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnAddDesktop.setName("btnAddDesktop");
    btnAddDesktop.setPreferredSize(new java.awt.Dimension(28, 28));
    btnAddDesktop.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddDesktop.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddDesktopActionPerformed(evt);
        }
    });
    toolbar.add(btnAddDesktop);
    // NOI18N
    btnAddText.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/accessories-text-editor.png")));
    btnAddText.setToolTipText("Text/QRCode");
    btnAddText.setFocusable(false);
    btnAddText.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddText.setMaximumSize(new java.awt.Dimension(29, 28));
    btnAddText.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnAddText.setName("btnAddText");
    btnAddText.setPreferredSize(new java.awt.Dimension(28, 28));
    btnAddText.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddText.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddTextActionPerformed(evt);
        }
    });
    toolbar.add(btnAddText);
    // NOI18N
    btnAddAudioSrc.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/audio-volume-high.png")));
    btnAddAudioSrc.setToolTipText("AudioSource");
    btnAddAudioSrc.setFocusable(false);
    btnAddAudioSrc.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddAudioSrc.setMaximumSize(new java.awt.Dimension(29, 28));
    btnAddAudioSrc.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnAddAudioSrc.setName("btnAddAudioSrc");
    btnAddAudioSrc.setPreferredSize(new java.awt.Dimension(28, 28));
    btnAddAudioSrc.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddAudioSrc.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddAudioSrcActionPerformed(evt);
        }
    });
    toolbar.add(btnAddAudioSrc);
    jSeparator1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    // NOI18N
    jSeparator1.setFont(new java.awt.Font("Ubuntu", 1, 15));
    // NOI18N
    jSeparator1.setName("jSeparator1");
    jSeparator1.setOpaque(true);
    toolbar.add(jSeparator1);
    cboAnimations.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    // NOI18N
    cboAnimations.setToolTipText(bundle.getString("ANIMATIONS"));
    // NOI18N
    cboAnimations.setName("cboAnimations");
    toolbar.add(cboAnimations);
    // NOI18N
    btnAddAnimation.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/Anim-add.png")));
    // NOI18N
    btnAddAnimation.setToolTipText(bundle.getString("ADD_ANIMATION"));
    btnAddAnimation.setFocusable(false);
    btnAddAnimation.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnAddAnimation.setMaximumSize(new java.awt.Dimension(29, 28));
    btnAddAnimation.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnAddAnimation.setName("btnAddAnimation");
    btnAddAnimation.setPreferredSize(new java.awt.Dimension(28, 28));
    btnAddAnimation.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnAddAnimation.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddAnimationActionPerformed(evt);
        }
    });
    toolbar.add(btnAddAnimation);
    // NOI18N
    jSeparator2.setFont(new java.awt.Font("Ubuntu", 1, 15));
    // NOI18N
    jSeparator2.setName("jSeparator2");
    jSeparator2.setOpaque(true);
    toolbar.add(jSeparator2);
    // NOI18N
    btnMinimizeTab.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/go-down.png")));
    // NOI18N
    btnMinimizeTab.setToolTipText(bundle.getString("ICON_TAB"));
    btnMinimizeTab.setFocusable(false);
    btnMinimizeTab.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnMinimizeTab.setMaximumSize(new java.awt.Dimension(29, 28));
    btnMinimizeTab.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnMinimizeTab.setName("btnMinimizeTab");
    btnMinimizeTab.setPreferredSize(new java.awt.Dimension(28, 28));
    btnMinimizeTab.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnMinimizeTab.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnMinimizeTabActionPerformed(evt);
        }
    });
    toolbar.add(btnMinimizeTab);
    // NOI18N
    btnMinimizeAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/webcamstudio/resources/tango/minimize-all.png")));
    // NOI18N
    btnMinimizeAll.setToolTipText(bundle.getString("ICON_ALL"));
    btnMinimizeAll.setFocusable(false);
    btnMinimizeAll.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnMinimizeAll.setMaximumSize(new java.awt.Dimension(29, 28));
    btnMinimizeAll.setMinimumSize(new java.awt.Dimension(25, 25));
    // NOI18N
    btnMinimizeAll.setName("btnMinimizeAll");
    btnMinimizeAll.setPreferredSize(new java.awt.Dimension(28, 28));
    btnMinimizeAll.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    btnMinimizeAll.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnMinimizeAllActionPerformed(evt);
        }
    });
    toolbar.add(btnMinimizeAll);
    // NOI18N
    tabSources.setFont(new java.awt.Font("Noto Sans", 0, 11));
    // NOI18N
    tabSources.setName("tabSources");
    tabSources.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            tabSourcesMouseClicked(evt);
        }
    });
    // NOI18N
    cameraDesktop.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("SOURCE_CAMERAS")));
    // NOI18N
    cameraDesktop.setToolTipText(bundle.getString("DROP_SOURCSE"));
    cameraDesktop.setAutoscrolls(true);
    // NOI18N
    cameraDesktop.setName("cameraDesktop");
    tabSources.addTab("Cameras(0)", cameraDesktop);
    // NOI18N
    videoDesktop.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("SOURCE_VIDEOS")));
    // NOI18N
    videoDesktop.setToolTipText(bundle.getString("DROP_SOURCSE"));
    videoDesktop.setAutoscrolls(true);
    // NOI18N
    videoDesktop.setName("videoDesktop");
    tabSources.addTab("Videos(0)", videoDesktop);
    // NOI18N
    musicDesktop.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("SOURCE_MUSICS")));
    // NOI18N
    musicDesktop.setToolTipText(bundle.getString("DROP_SOURCSE"));
    musicDesktop.setAutoscrolls(true);
    // NOI18N
    musicDesktop.setName("musicDesktop");
    tabSources.addTab("Musics(0)", musicDesktop);
    // NOI18N
    pictureDesktop.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("SOURCE_PICTURES")));
    // NOI18N
    pictureDesktop.setToolTipText(bundle.getString("DROP_SOURCSE"));
    pictureDesktop.setAutoscrolls(true);
    // NOI18N
    pictureDesktop.setName("pictureDesktop");
    tabSources.addTab("Pictures(0)", pictureDesktop);
    // NOI18N
    dvbDesktop.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("SOURCE_DVBS")));
    // NOI18N
    dvbDesktop.setToolTipText(bundle.getString("DROP_SOURCSE"));
    dvbDesktop.setAutoscrolls(true);
    // NOI18N
    dvbDesktop.setName("dvbDesktop");
    tabSources.addTab("DVBs(0)", dvbDesktop);
    // NOI18N
    urlDesktop.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("SOURCE_URLS")));
    // NOI18N
    urlDesktop.setToolTipText(bundle.getString("DROP_SOURCSE"));
    urlDesktop.setAutoscrolls(true);
    // NOI18N
    urlDesktop.setName("urlDesktop");
    tabSources.addTab("URLs(0)", urlDesktop);
    // NOI18N
    desktopDesktop.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("SOURCE_DESKTOPS")));
    // NOI18N
    desktopDesktop.setToolTipText(bundle.getString("DROP_SOURCSE"));
    desktopDesktop.setAutoscrolls(true);
    // NOI18N
    desktopDesktop.setName("desktopDesktop");
    tabSources.addTab("Desktops(0)", desktopDesktop);
    // NOI18N
    textDesktop.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("SOURCES_TEXTS")));
    // NOI18N
    textDesktop.setToolTipText(bundle.getString("DROP_SOURCSE"));
    textDesktop.setAutoscrolls(true);
    // NOI18N
    textDesktop.setName("textDesktop");
    tabSources.addTab("Texts(0)", textDesktop);
    // NOI18N
    audioInDesktop.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("SOURCE_AUDIOINS")));
    // NOI18N
    audioInDesktop.setToolTipText(bundle.getString("DROP_SOURCSE"));
    audioInDesktop.setAutoscrolls(true);
    // NOI18N
    audioInDesktop.setName("audioInDesktop");
    tabSources.addTab("AudioIns(0)", audioInDesktop);
    javax.swing.GroupLayout panSourcesLayout = new javax.swing.GroupLayout(panSources);
    panSources.setLayout(panSourcesLayout);
    panSourcesLayout.setHorizontalGroup(panSourcesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(panSourcesLayout.createSequentialGroup().addContainerGap().addGroup(panSourcesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(toolbar, javax.swing.GroupLayout.DEFAULT_SIZE, 488, Short.MAX_VALUE).addComponent(tabSources))));
    panSourcesLayout.setVerticalGroup(panSourcesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(panSourcesLayout.createSequentialGroup().addComponent(toolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(tabSources, javax.swing.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE).addContainerGap()));
    mainSplit.setLeftComponent(panSources);
    // NOI18N
    panControls.setName("panControls");
    panControls.setPreferredSize(new java.awt.Dimension(200, 455));
    panControls.setLayout(new java.awt.BorderLayout());
    tabControls.setBorder(javax.swing.BorderFactory.createTitledBorder("Source Properties"));
    tabControls.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
    // NOI18N
    tabControls.setName("tabControls");
    tabControls.setPreferredSize(new java.awt.Dimension(200, 455));
    panControls.add(tabControls, java.awt.BorderLayout.CENTER);
    // NOI18N
    lblSourceSelected.setName("lblSourceSelected");
    panControls.add(lblSourceSelected, java.awt.BorderLayout.SOUTH);
    mainSplit.setRightComponent(panControls);
    masterPanelSplit.setRightComponent(mainSplit);
    mainVerticalSplit.setLeftComponent(masterPanelSplit);
    getContentPane().add(mainVerticalSplit, java.awt.BorderLayout.CENTER);
    pack();
}
Example 44
Project: QuaquaOld-master  File: DesktopPaneTest.java View source code
/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    jDesktopPane1 = new javax.swing.JDesktopPane();
    jInternalFrame4 = new javax.swing.JInternalFrame();
    jMenuBar4 = new javax.swing.JMenuBar();
    jMenu13 = new javax.swing.JMenu();
    jMenuItem37 = new javax.swing.JMenuItem();
    jMenuItem38 = new javax.swing.JMenuItem();
    jMenu14 = new javax.swing.JMenu();
    jMenuItem39 = new javax.swing.JMenuItem();
    jMenuItem40 = new javax.swing.JMenuItem();
    jSeparator16 = new javax.swing.JSeparator();
    jMenuItem41 = new javax.swing.JMenuItem();
    jMenuItem42 = new javax.swing.JMenuItem();
    jMenuItem43 = new javax.swing.JMenuItem();
    jMenuItem44 = new javax.swing.JMenuItem();
    jSeparator17 = new javax.swing.JSeparator();
    jMenuItem45 = new javax.swing.JMenuItem();
    jMenuItem46 = new javax.swing.JMenuItem();
    jMenu15 = new javax.swing.JMenu();
    cutMenuItem14 = new javax.swing.JMenuItem();
    copyMenuItem15 = new javax.swing.JMenuItem();
    jMenuItem47 = new javax.swing.JMenuItem();
    jMenuItem48 = new javax.swing.JMenuItem();
    jMenu16 = new javax.swing.JMenu();
    jCheckBoxMenuItem4 = new javax.swing.JCheckBoxMenuItem();
    jSeparator18 = new javax.swing.JSeparator();
    jRadioButtonMenuItem7 = new javax.swing.JRadioButtonMenuItem();
    jRadioButtonMenuItem8 = new javax.swing.JRadioButtonMenuItem();
    jSeparator19 = new javax.swing.JSeparator();
    zoomInMenuItem3 = new javax.swing.JMenuItem();
    zoomOutMenuItem3 = new javax.swing.JMenuItem();
    smallInternalFrame = new javax.swing.JInternalFrame();
    windowModifiedCheckBox = new javax.swing.JCheckBox();
    jMenuBar5 = new javax.swing.JMenuBar();
    jMenu17 = new javax.swing.JMenu();
    jMenuItem49 = new javax.swing.JMenuItem();
    jMenuItem50 = new javax.swing.JMenuItem();
    jMenu18 = new javax.swing.JMenu();
    jMenuItem51 = new javax.swing.JMenuItem();
    jMenuItem52 = new javax.swing.JMenuItem();
    jSeparator20 = new javax.swing.JSeparator();
    jMenuItem53 = new javax.swing.JMenuItem();
    jMenuItem54 = new javax.swing.JMenuItem();
    jMenuItem55 = new javax.swing.JMenuItem();
    jMenuItem56 = new javax.swing.JMenuItem();
    jSeparator21 = new javax.swing.JSeparator();
    jMenuItem57 = new javax.swing.JMenuItem();
    jMenuItem58 = new javax.swing.JMenuItem();
    jMenu19 = new javax.swing.JMenu();
    cutMenuItem15 = new javax.swing.JMenuItem();
    copyMenuItem16 = new javax.swing.JMenuItem();
    jMenuItem59 = new javax.swing.JMenuItem();
    jMenuItem60 = new javax.swing.JMenuItem();
    jMenu20 = new javax.swing.JMenu();
    jCheckBoxMenuItem5 = new javax.swing.JCheckBoxMenuItem();
    jSeparator22 = new javax.swing.JSeparator();
    jRadioButtonMenuItem9 = new javax.swing.JRadioButtonMenuItem();
    jRadioButtonMenuItem10 = new javax.swing.JRadioButtonMenuItem();
    jSeparator23 = new javax.swing.JSeparator();
    zoomInMenuItem4 = new javax.swing.JMenuItem();
    zoomOutMenuItem4 = new javax.swing.JMenuItem();
    toolFrame = new javax.swing.JInternalFrame();
    jCheckBox1 = new javax.swing.JCheckBox();
    jCheckBox2 = new javax.swing.JCheckBox();
    FormListener formListener = new FormListener();
    setLayout(new java.awt.BorderLayout());
    jInternalFrame4.setIconifiable(true);
    jInternalFrame4.setMaximizable(true);
    jInternalFrame4.setResizable(true);
    jInternalFrame4.setTitle("Internal Frame");
    jInternalFrame4.setVisible(true);
    jMenu13.setText("File");
    jMenuItem37.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.META_MASK));
    jMenuItem37.setText("New");
    jMenuItem37.addActionListener(formListener);
    jMenu13.add(jMenuItem37);
    jMenuItem38.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.META_MASK));
    jMenuItem38.setText("Open...");
    jMenuItem38.addActionListener(formListener);
    jMenu13.add(jMenuItem38);
    jMenu14.setText("Open Recent Document");
    jMenuItem39.setText("File1.txt");
    jMenuItem39.addActionListener(formListener);
    jMenu14.add(jMenuItem39);
    jMenuItem40.setText("File2.txt");
    jMenuItem40.addActionListener(formListener);
    jMenu14.add(jMenuItem40);
    jMenu13.add(jMenu14);
    jMenu13.add(jSeparator16);
    jMenuItem41.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_MASK));
    jMenuItem41.setText("Close");
    jMenuItem41.addActionListener(formListener);
    jMenu13.add(jMenuItem41);
    jMenuItem42.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.META_MASK));
    jMenuItem42.setText("Save");
    jMenuItem42.addActionListener(formListener);
    jMenu13.add(jMenuItem42);
    jMenuItem43.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.META_MASK | InputEvent.SHIFT_MASK));
    jMenuItem43.setText("Save As...");
    jMenuItem43.addActionListener(formListener);
    jMenu13.add(jMenuItem43);
    jMenuItem44.setText("Revert to Saved");
    jMenuItem44.addActionListener(formListener);
    jMenu13.add(jMenuItem44);
    jMenu13.add(jSeparator17);
    jMenuItem45.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.META_MASK | InputEvent.SHIFT_MASK));
    jMenuItem45.setText("Page Setup...");
    jMenuItem45.addActionListener(formListener);
    jMenu13.add(jMenuItem45);
    jMenuItem46.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.META_MASK));
    jMenuItem46.setText("Print...");
    jMenuItem46.addActionListener(formListener);
    jMenu13.add(jMenuItem46);
    jMenuBar4.add(jMenu13);
    jMenu15.setText("Edit");
    cutMenuItem14.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    cutMenuItem14.setText("Cut");
    jMenu15.add(cutMenuItem14);
    copyMenuItem15.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.META_MASK));
    copyMenuItem15.setText("Copy");
    jMenu15.add(copyMenuItem15);
    jMenuItem47.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.META_MASK));
    jMenuItem47.setText("Paste");
    jMenu15.add(jMenuItem47);
    jMenuItem48.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DELETE, 0));
    jMenuItem48.setText("Delete");
    jMenu15.add(jMenuItem48);
    jMenuBar4.add(jMenu15);
    jMenu16.setText("View");
    jCheckBoxMenuItem4.setSelected(true);
    jCheckBoxMenuItem4.setText("Ångström H");
    jMenu16.add(jCheckBoxMenuItem4);
    jMenu16.add(jSeparator18);
    jRadioButtonMenuItem7.setText("Dock at Right");
    jMenu16.add(jRadioButtonMenuItem7);
    jRadioButtonMenuItem8.setSelected(true);
    jRadioButtonMenuItem8.setText("Ångström H");
    jMenu16.add(jRadioButtonMenuItem8);
    jMenu16.add(jSeparator19);
    zoomInMenuItem3.setText("Ångström H");
    jMenu16.add(zoomInMenuItem3);
    zoomOutMenuItem3.setText("Zoom Out");
    jMenu16.add(zoomOutMenuItem3);
    jMenuBar4.add(jMenu16);
    jInternalFrame4.setJMenuBar(jMenuBar4);
    jInternalFrame4.setBounds(40, 30, 170, 170);
    jDesktopPane1.add(jInternalFrame4, javax.swing.JLayeredPane.DEFAULT_LAYER);
    smallInternalFrame.setClosable(true);
    smallInternalFrame.setIconifiable(true);
    smallInternalFrame.setMaximizable(true);
    smallInternalFrame.setResizable(true);
    smallInternalFrame.setTitle("Small Size");
    smallInternalFrame.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    smallInternalFrame.setVisible(true);
    windowModifiedCheckBox.setText("Window Modified");
    windowModifiedCheckBox.addItemListener(formListener);
    smallInternalFrame.getContentPane().add(windowModifiedCheckBox, java.awt.BorderLayout.CENTER);
    jMenuBar5.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenu17.setText("File");
    jMenu17.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem49.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.META_MASK));
    jMenuItem49.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem49.setText("New");
    jMenu17.add(jMenuItem49);
    jMenuItem50.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.META_MASK));
    jMenuItem50.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem50.setText("Open...");
    jMenu17.add(jMenuItem50);
    jMenu18.setText("Open Recent");
    jMenu18.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem51.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem51.setText("File1.txt");
    jMenu18.add(jMenuItem51);
    jMenuItem52.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem52.setText("File2.txt");
    jMenu18.add(jMenuItem52);
    jMenu17.add(jMenu18);
    jMenu17.add(jSeparator20);
    jMenuItem53.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_MASK));
    jMenuItem53.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem53.setText("Close");
    jMenu17.add(jMenuItem53);
    jMenuItem54.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.META_MASK));
    jMenuItem54.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem54.setText("Save");
    jMenu17.add(jMenuItem54);
    jMenuItem55.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.META_MASK | InputEvent.SHIFT_MASK));
    jMenuItem55.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem55.setText("Save As...");
    jMenu17.add(jMenuItem55);
    jMenuItem56.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem56.setText("Revert to Saved");
    jMenu17.add(jMenuItem56);
    jMenu17.add(jSeparator21);
    jMenuItem57.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.META_MASK | InputEvent.SHIFT_MASK));
    jMenuItem57.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem57.setText("Page Setup...");
    jMenu17.add(jMenuItem57);
    jMenuItem58.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.META_MASK));
    jMenuItem58.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem58.setText("Print...");
    jMenu17.add(jMenuItem58);
    jMenuBar5.add(jMenu17);
    jMenu19.setText("Edit");
    jMenu19.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    cutMenuItem15.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    cutMenuItem15.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    cutMenuItem15.setText("Cut");
    jMenu19.add(cutMenuItem15);
    copyMenuItem16.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.META_MASK));
    copyMenuItem16.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    copyMenuItem16.setText("Copy");
    jMenu19.add(copyMenuItem16);
    jMenuItem59.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.META_MASK));
    jMenuItem59.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem59.setText("Paste");
    jMenu19.add(jMenuItem59);
    jMenuItem60.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DELETE, 0));
    jMenuItem60.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jMenuItem60.setText("Delete");
    jMenu19.add(jMenuItem60);
    jMenuBar5.add(jMenu19);
    jMenu20.setText("View");
    jMenu20.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jCheckBoxMenuItem5.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jCheckBoxMenuItem5.setSelected(true);
    jCheckBoxMenuItem5.setText("Show Toolbar");
    jMenu20.add(jCheckBoxMenuItem5);
    jMenu20.add(jSeparator22);
    jRadioButtonMenuItem9.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jRadioButtonMenuItem9.setText("Dock at Right");
    jMenu20.add(jRadioButtonMenuItem9);
    jRadioButtonMenuItem10.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    jRadioButtonMenuItem10.setSelected(true);
    jRadioButtonMenuItem10.setText("Dock at Bottom");
    jMenu20.add(jRadioButtonMenuItem10);
    jMenu20.add(jSeparator23);
    zoomInMenuItem4.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    zoomInMenuItem4.setText("Zoom In");
    jMenu20.add(zoomInMenuItem4);
    zoomOutMenuItem4.setFont(new java.awt.Font("Lucida Grande", 0, 11));
    zoomOutMenuItem4.setText("Zoom Out");
    jMenu20.add(zoomOutMenuItem4);
    jMenuBar5.add(jMenu20);
    smallInternalFrame.setJMenuBar(jMenuBar5);
    smallInternalFrame.setBounds(200, 180, 180, 170);
    jDesktopPane1.add(smallInternalFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);
    toolFrame.setIconifiable(true);
    toolFrame.setMaximizable(true);
    toolFrame.setResizable(true);
    toolFrame.setNormalBounds(new java.awt.Rectangle(240, 50, 120, 120));
    toolFrame.setVisible(true);
    toolFrame.getContentPane().setLayout(new javax.swing.BoxLayout(toolFrame.getContentPane(), javax.swing.BoxLayout.Y_AXIS));
    jCheckBox1.setText("jCheckBox1");
    toolFrame.getContentPane().add(jCheckBox1);
    jCheckBox2.setText("jCheckBox2");
    toolFrame.getContentPane().add(jCheckBox2);
    toolFrame.setBounds(240, 50, 120, 90);
    jDesktopPane1.add(toolFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);
    add(jDesktopPane1, java.awt.BorderLayout.CENTER);
}
Example 45
Project: Soen6471Frinika-master  File: ScriptingDialog.java View source code
/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
    fileChooser = new javax.swing.JFileChooser();
    splitPane = new javax.swing.JSplitPane();
    desktopPane = new javax.swing.JDesktopPane();
    consolePanel = new javax.swing.JPanel();
    consoleScrollPane = new javax.swing.JScrollPane();
    consoleTextArea = new javax.swing.JTextArea();
    consoleButtonPanel = new javax.swing.JPanel();
    clearButton = new javax.swing.JButton();
    menuBar = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    fileNewMenuItem = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    fileOpenMenuItem = new javax.swing.JMenuItem();
    fileSaveMenuItem = new javax.swing.JMenuItem();
    fileSaveAsMenuItem = new javax.swing.JMenuItem();
    jSeparator2 = new javax.swing.JSeparator();
    fileCloseMenuItem = new javax.swing.JMenuItem();
    editMenu = new javax.swing.JMenu();
    undoMenuItem = new javax.swing.JMenuItem();
    redoMenuItem = new javax.swing.JMenuItem();
    runMenu = new javax.swing.JMenu();
    runExecuteMenuItem = new javax.swing.JMenuItem();
    runStopMenuItem = new javax.swing.JMenuItem();
    windowMenu = new javax.swing.JMenu();
    presetMenu = new javax.swing.JMenu();
    splitPane.setDividerLocation(550);
    splitPane.setDividerSize(8);
    splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    splitPane.setContinuousLayout(true);
    splitPane.setOneTouchExpandable(true);
    desktopPane.setBackground(new java.awt.Color(204, 204, 255));
    splitPane.setLeftComponent(desktopPane);
    consolePanel.setLayout(new java.awt.BorderLayout());
    consoleTextArea.setColumns(20);
    consoleTextArea.setFont(new java.awt.Font("DialogInput", 0, 12));
    consoleTextArea.setRows(5);
    consoleScrollPane.setViewportView(consoleTextArea);
    consolePanel.add(consoleScrollPane, java.awt.BorderLayout.CENTER);
    consoleButtonPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT, 1, 1));
    clearButton.setMnemonic('l');
    clearButton.setText("Clear");
    clearButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            clearButtonActionPerformed(evt);
        }
    });
    consoleButtonPanel.add(clearButton);
    consolePanel.add(consoleButtonPanel, java.awt.BorderLayout.SOUTH);
    splitPane.setRightComponent(consolePanel);
    getContentPane().add(splitPane, java.awt.BorderLayout.CENTER);
    fileMenu.setMnemonic('F');
    fileMenu.setText("File");
    fileNewMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileNewMenuItem.setMnemonic('N');
    fileNewMenuItem.setText("New");
    fileNewMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            fileNewMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(fileNewMenuItem);
    fileMenu.add(jSeparator1);
    fileOpenMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileOpenMenuItem.setMnemonic('O');
    fileOpenMenuItem.setText("Open");
    fileOpenMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            fileOpenMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(fileOpenMenuItem);
    fileSaveMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileSaveMenuItem.setMnemonic('S');
    fileSaveMenuItem.setText("Save");
    fileSaveMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            fileSaveMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(fileSaveMenuItem);
    fileSaveAsMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileSaveAsMenuItem.setMnemonic('A');
    fileSaveAsMenuItem.setText("Save As...");
    fileSaveAsMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            fileSaveAsMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(fileSaveAsMenuItem);
    fileMenu.add(jSeparator2);
    fileCloseMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileCloseMenuItem.setMnemonic('C');
    fileCloseMenuItem.setText("Close");
    fileCloseMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            fileCloseMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(fileCloseMenuItem);
    menuBar.add(fileMenu);
    editMenu.setMnemonic('E');
    editMenu.setText("Edit");
    undoMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    undoMenuItem.setMnemonic('U');
    undoMenuItem.setText("Undo");
    undoMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            undoMenuItemActionPerformed(evt);
        }
    });
    editMenu.add(undoMenuItem);
    redoMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    redoMenuItem.setMnemonic('R');
    redoMenuItem.setText("Redo");
    redoMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            redoMenuItemActionPerformed(evt);
        }
    });
    editMenu.add(redoMenuItem);
    menuBar.add(editMenu);
    runMenu.setMnemonic('R');
    runMenu.setText("Run");
    runExecuteMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK));
    runExecuteMenuItem.setMnemonic('E');
    runExecuteMenuItem.setText("Execute");
    runExecuteMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            runExecuteMenuItemActionPerformed(evt);
        }
    });
    runMenu.add(runExecuteMenuItem);
    runStopMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Y, java.awt.event.InputEvent.ALT_MASK));
    runStopMenuItem.setMnemonic('S');
    runStopMenuItem.setText("Stop");
    runStopMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            runStopMenuItemActionPerformed(evt);
        }
    });
    runMenu.add(runStopMenuItem);
    menuBar.add(runMenu);
    windowMenu.setMnemonic('W');
    windowMenu.setText("Window");
    menuBar.add(windowMenu);
    presetMenu.setMnemonic('P');
    presetMenu.setText("Presets");
    menuBar.add(presetMenu);
    setJMenuBar(menuBar);
    pack();
}
Example 46
Project: tif-master  File: TifWorkbenchApplication.java View source code
/**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    jPopupMenu1 = new javax.swing.JPopupMenu();
    jPopupMenu2 = new javax.swing.JPopupMenu();
    jMenuItem1 = new javax.swing.JMenuItem();
    desktopPane = new javax.swing.JDesktopPane();
    menuBar = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    newMenu = new javax.swing.JMenu();
    newTifMeniItem = new javax.swing.JMenuItem();
    newEnvMenuItem = new javax.swing.JMenuItem();
    openMenu = new javax.swing.JMenu();
    envOpenMenuItem = new javax.swing.JMenuItem();
    integrityMenuItem = new javax.swing.JMenuItem();
    integrityPlusMenuItem = new javax.swing.JMenuItem();
    tifMenuItem = new javax.swing.JMenuItem();
    saveMenuItem = new javax.swing.JMenuItem();
    saveAsMenuItem = new javax.swing.JMenuItem();
    exitMenuItem = new javax.swing.JMenuItem();
    editMenu = new javax.swing.JMenu();
    findMenuItem = new javax.swing.JMenuItem();
    copyMenuItem = new javax.swing.JMenuItem();
    toolsMenu = new javax.swing.JMenu();
    checkMenuItem = new javax.swing.JMenuItem();
    diffMenuItem = new javax.swing.JMenuItem();
    transformMenuItem = new javax.swing.JMenuItem();
    generateMenuItem = new javax.swing.JMenuItem();
    windowMenu = new javax.swing.JMenu();
    helpMenu = new javax.swing.JMenu();
    aboutMenuItem = new javax.swing.JMenuItem();
    jMenuItem1.setText("jMenuItem1");
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("TIF Workbench");
    setIconImage(new javax.swing.ImageIcon(getClass().getResource("/com/ptc/tifworkbench/ui/Utilities-icon.png")).getImage());
    // NOI18N
    setName("appFrame");
    desktopPane.setBackground(new java.awt.Color(204, 204, 255));
    fileMenu.setMnemonic('f');
    fileMenu.setText("File");
    newMenu.setText("New");
    newTifMeniItem.setText("New TIF");
    newTifMeniItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            newTifMeniItemActionPerformed(evt);
        }
    });
    newMenu.add(newTifMeniItem);
    newEnvMenuItem.setText("New Enviromnent");
    newEnvMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            newEnvMenuItemActionPerformed(evt);
        }
    });
    newMenu.add(newEnvMenuItem);
    fileMenu.add(newMenu);
    openMenu.setText("Open");
    envOpenMenuItem.setText("Environment");
    envOpenMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            envOpenMenuItemActionPerformed(evt);
        }
    });
    openMenu.add(envOpenMenuItem);
    integrityMenuItem.setText("Integrity");
    integrityMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            integrityMenuItemActionPerformed(evt);
        }
    });
    openMenu.add(integrityMenuItem);
    integrityPlusMenuItem.setText("Integrity + resources");
    integrityPlusMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            integrityPlusMenuItemActionPerformed(evt);
        }
    });
    openMenu.add(integrityPlusMenuItem);
    tifMenuItem.setText("TIF");
    tifMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            tifMenuItemActionPerformed(evt);
        }
    });
    openMenu.add(tifMenuItem);
    fileMenu.add(openMenu);
    saveMenuItem.setText("Save");
    fileMenu.add(saveMenuItem);
    saveAsMenuItem.setMnemonic('a');
    saveAsMenuItem.setText("Save As ...");
    saveAsMenuItem.setDisplayedMnemonicIndex(5);
    saveAsMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveAsMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(saveAsMenuItem);
    exitMenuItem.setMnemonic('x');
    exitMenuItem.setText("Exit");
    exitMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(exitMenuItem);
    menuBar.add(fileMenu);
    editMenu.setMnemonic('e');
    editMenu.setText("Edit");
    findMenuItem.setMnemonic('t');
    findMenuItem.setText("Find");
    editMenu.add(findMenuItem);
    copyMenuItem.setMnemonic('y');
    copyMenuItem.setText("Copy");
    editMenu.add(copyMenuItem);
    menuBar.add(editMenu);
    toolsMenu.setText("Tools");
    checkMenuItem.setText("Check TIF");
    checkMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            checkMenuItemActionPerformed(evt);
        }
    });
    toolsMenu.add(checkMenuItem);
    diffMenuItem.setText("Difference");
    diffMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            diffMenuItemActionPerformed(evt);
        }
    });
    toolsMenu.add(diffMenuItem);
    transformMenuItem.setText("Transform");
    transformMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            transformMenuItemActionPerformed(evt);
        }
    });
    toolsMenu.add(transformMenuItem);
    generateMenuItem.setText("Generate wrappers");
    generateMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            generateMenuItemActionPerformed(evt);
        }
    });
    toolsMenu.add(generateMenuItem);
    menuBar.add(toolsMenu);
    windowMenu.setText("Window");
    menuBar.add(windowMenu);
    helpMenu.setMnemonic('h');
    helpMenu.setText("Help");
    aboutMenuItem.setMnemonic('a');
    aboutMenuItem.setText("About");
    aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            aboutMenuItemActionPerformed(evt);
        }
    });
    helpMenu.add(aboutMenuItem);
    menuBar.add(helpMenu);
    setJMenuBar(menuBar);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE));
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 584) / 2, (screenSize.height - 518) / 2, 584, 518);
}
Example 47
Project: choreos_v-v-master  File: InputScreen.java View source code
private void initContainers() {
    mainPanel = new JPanel();
    jDesktopPane1 = new JDesktopPane();
    jDesktopPane3 = new JDesktopPane();
    jScrollPane1 = new JScrollPane();
    itemEditor = new JEditorPane();
    jScrollPane2 = new JScrollPane();
    itemEditor1 = new JEditorPane();
    jDesktopPane5 = new JDesktopPane();
    jDesktopPane6 = new JDesktopPane();
    jDesktopPane7 = new JDesktopPane();
}
Example 48
Project: glg2d-master  File: UIDemo.java View source code
JComponent createMDIComponent() {
    JDesktopPane pane = new JDesktopPane();
    pane.setDragMode(JDesktopPane.LIVE_DRAG_MODE);
    pane.setBackground(new JPanel().getBackground());
    pane.setOpaque(true);
    pane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
    for (int i = 0; i < 3; i++) {
        JInternalFrame frame1 = new JInternalFrame("Foo" + i, true);
        frame1.setClosable(true);
        frame1.setMaximizable(true);
        pane.add(frame1);
        JMenuBar bar = new JMenuBar();
        JMenu menu = new JMenu("File");
        menu.add(new JMenuItem("Open"));
        menu.add(new JMenuItem("Close"));
        bar.add(menu);
        frame1.setJMenuBar(bar);
        frame1.setSize(200, 200);
        frame1.setLocation(100 * i, 5 * i);
        frame1.setVisible(true);
    }
    return pane;
}
Example 49
Project: JDK-master  File: SynthDesktopPaneUI.java View source code
void adjustSize() {
    JDesktopPane desktop = (JDesktopPane) getParent();
    if (desktop != null) {
        int height = getPreferredSize().height;
        Insets insets = getInsets();
        if (height == insets.top + insets.bottom) {
            if (getHeight() <= height) {
                // Initial size, because we have no buttons yet
                height += 21;
            } else {
                // We already have a good height
                height = getHeight();
            }
        }
        setBounds(0, desktop.getHeight() - height, desktop.getWidth(), height);
        revalidate();
        repaint();
    }
}
Example 50
Project: jtotus-master  File: JTotusMethodView.java View source code
public void initialize() {
    jScrollPane1 = new JScrollPane();
    drawDesktopPane = new JDesktopPane();
    //Register Method Results printer
    //TODO:remove from engine !!!
    Engine engine = Engine.getInstance();
    engine.registerResultsPrinter(this);
    EPServiceProvider cepEngine = BrokerWatcher.getMainEngine();
    EPAdministrator cepAdm = cepEngine.getEPAdministrator();
    EPStatement eps = cepAdm.createEPL("select * from MethodResults");
    eps.addListener(this);
    this.configureMethodTab();
    jScrollPane1.setHorizontalScrollBarPolicy(jScrollPane1.HORIZONTAL_SCROLLBAR_ALWAYS);
}
Example 51
Project: LibMaker-master  File: ActionPreview.java View source code
public static void showInFrame(Component parent, Action a) {
    final JFrame f = new JFrame();
    ActionPreview ap = new ActionPreview(a);
    ap.setVisible(true);
    ap.addInternalFrameListener(new InternalFrameAdapter() {

        public void internalFrameClosed(InternalFrameEvent e) {
            f.dispose();
        }
    });
    JDesktopPane dp = new JDesktopPane();
    dp.add(ap);
    f.add(dp);
    f.setSize(ap.getSize());
    f.setLocationRelativeTo(parent);
    f.setVisible(true);
}
Example 52
Project: geotoolkit-master  File: WindowCreator.java View source code
/**
         * Creates a {@link JDialog}, {@link JFrame} or {@link JInternalFrame} depending on
         * the {@code owner} ancestor.
         */
@Override
public Window createWindow(final Component owner, final Component content, final String title) {
    java.awt.Window window = null;
    Component parent = owner;
    while ((parent = parent.getParent()) != null) {
        if (parent instanceof JDesktopPane) {
            final InternalFrame frame = new InternalFrame(title);
            ((JDesktopPane) parent).add(frame);
            frame.add(content);
            frame.pack();
            return frame;
        }
        if (parent instanceof java.awt.Frame) {
            window = new Dialog((java.awt.Frame) parent, title);
            break;
        } else if (parent instanceof java.awt.Dialog) {
            window = new Dialog((java.awt.Dialog) parent, title);
            break;
        }
    }
    if (window == null) {
        window = new Frame(title);
    }
    window.add(content);
    window.pack();
    window.setLocationRelativeTo(owner);
    ((Window) window).setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    return (Window) window;
}
Example 53
Project: geotools-2.7.x-master  File: SwingUtilities.java View source code
/**
     * Insert a Swing component into a frame. The kind of frame depends on the owner:
     *
     * <ul>
     *   <li>If {@code owner} or one of its parent is a {@link JDesktopPane},
     *       then {@code panel} is added into a {@link JInternalFrame}.</li>
     *   <li>If {@code owner} or one of its parent is a {@link Frame} or a {@link Dialog},
     *       then {@code panel} is added into a {@link JDialog}.</li>
     *   <li>Otherwise, {@code panel} is added into a {@link JFrame}.</li>
     * </ul>
     *
     * @param  owner The frame's owner, or {@code null} if none.
     * @param  panel The panel to insert into a frame.
     * @param  title The frame's title.
     * @param  listener A listener to receives frame events.  If non-null, then this listener will
     *         be registered to whatever kind of frame this method will constructs. In the special
     *         case where this method constructs an {@linkplain JInternalFrame internal frame} and
     *         the {@code listener} is not an instance of {@link javax.swing.event.InternalFrameListener},
     *         then this method will wrap the {@code listener} into an {@code InternalFrameListener}.
     * @return The frame. This frame is not initially visible. The method
     *         {@code Component.setVisible(true)} must be invoked in order to show the frame.
     */
public static Component toFrame(Component owner, final JComponent panel, final String title, final WindowListener listener) {
    while (owner != null) {
        if (owner == panel) {
            throw new IllegalArgumentException();
        }
        // NOTE: All 'addFooListener(...)' below ignore null argument. No need to check ourself.
        if (owner instanceof JDesktopPane) {
            final JInternalFrame frame = new JInternalFrame(title, true, true, true, true);
            frame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
            frame.addInternalFrameListener(InternalWindowListener.wrap(listener));
            ((JDesktopPane) owner).add(frame);
            frame.getContentPane().add(panel);
            frame.pack();
            return frame;
        }
        if (owner instanceof Frame) {
            final JDialog dialog = new JDialog((Frame) owner, title);
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            dialog.addWindowListener(listener);
            dialog.getContentPane().add(panel);
            dialog.pack();
            return dialog;
        }
        if (owner instanceof Dialog) {
            final JDialog dialog = new JDialog((Dialog) owner, title);
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            dialog.addWindowListener(listener);
            dialog.getContentPane().add(panel);
            dialog.pack();
            return dialog;
        }
        owner = owner.getParent();
    }
    //
    // Add the panel as a standalone window.
    // This window has its own button on the task bar.
    //
    final JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(listener);
    frame.getContentPane().add(panel);
    frame.pack();
    return frame;
}
Example 54
Project: geotools-master  File: SwingUtilities.java View source code
/**
     * Insert a Swing component into a frame. The kind of frame depends on the owner:
     *
     * <ul>
     *   <li>If {@code owner} or one of its parent is a {@link JDesktopPane},
     *       then {@code panel} is added into a {@link JInternalFrame}.</li>
     *   <li>If {@code owner} or one of its parent is a {@link Frame} or a {@link Dialog},
     *       then {@code panel} is added into a {@link JDialog}.</li>
     *   <li>Otherwise, {@code panel} is added into a {@link JFrame}.</li>
     * </ul>
     *
     * @param  owner The frame's owner, or {@code null} if none.
     * @param  panel The panel to insert into a frame.
     * @param  title The frame's title.
     * @param  listener A listener to receives frame events.  If non-null, then this listener will
     *         be registered to whatever kind of frame this method will constructs. In the special
     *         case where this method constructs an {@linkplain JInternalFrame internal frame} and
     *         the {@code listener} is not an instance of {@link javax.swing.event.InternalFrameListener},
     *         then this method will wrap the {@code listener} into an {@code InternalFrameListener}.
     * @return The frame. This frame is not initially visible. The method
     *         {@code Component.setVisible(true)} must be invoked in order to show the frame.
     */
public static Component toFrame(Component owner, final JComponent panel, final String title, final WindowListener listener) {
    while (owner != null) {
        if (owner == panel) {
            throw new IllegalArgumentException();
        }
        // NOTE: All 'addFooListener(...)' below ignore null argument. No need to check ourself.
        if (owner instanceof JDesktopPane) {
            final JInternalFrame frame = new JInternalFrame(title, true, true, true, true);
            frame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
            frame.addInternalFrameListener(InternalWindowListener.wrap(listener));
            ((JDesktopPane) owner).add(frame);
            frame.getContentPane().add(panel);
            frame.pack();
            return frame;
        }
        if (owner instanceof Frame) {
            final JDialog dialog = new JDialog((Frame) owner, title);
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            dialog.addWindowListener(listener);
            dialog.getContentPane().add(panel);
            dialog.pack();
            return dialog;
        }
        if (owner instanceof Dialog) {
            final JDialog dialog = new JDialog((Dialog) owner, title);
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            dialog.addWindowListener(listener);
            dialog.getContentPane().add(panel);
            dialog.pack();
            return dialog;
        }
        owner = owner.getParent();
    }
    //
    // Add the panel as a standalone window.
    // This window has its own button on the task bar.
    //
    final JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(listener);
    frame.getContentPane().add(panel);
    frame.pack();
    return frame;
}
Example 55
Project: geotools-old-master  File: SwingUtilities.java View source code
/**
     * Insert a Swing component into a frame. The kind of frame depends on the owner:
     *
     * <ul>
     *   <li>If {@code owner} or one of its parent is a {@link JDesktopPane},
     *       then {@code panel} is added into a {@link JInternalFrame}.</li>
     *   <li>If {@code owner} or one of its parent is a {@link Frame} or a {@link Dialog},
     *       then {@code panel} is added into a {@link JDialog}.</li>
     *   <li>Otherwise, {@code panel} is added into a {@link JFrame}.</li>
     * </ul>
     *
     * @param  owner The frame's owner, or {@code null} if none.
     * @param  panel The panel to insert into a frame.
     * @param  title The frame's title.
     * @param  listener A listener to receives frame events.  If non-null, then this listener will
     *         be registered to whatever kind of frame this method will constructs. In the special
     *         case where this method constructs an {@linkplain JInternalFrame internal frame} and
     *         the {@code listener} is not an instance of {@link javax.swing.event.InternalFrameListener},
     *         then this method will wrap the {@code listener} into an {@code InternalFrameListener}.
     * @return The frame. This frame is not initially visible. The method
     *         {@code Component.setVisible(true)} must be invoked in order to show the frame.
     */
public static Component toFrame(Component owner, final JComponent panel, final String title, final WindowListener listener) {
    while (owner != null) {
        if (owner == panel) {
            throw new IllegalArgumentException();
        }
        // NOTE: All 'addFooListener(...)' below ignore null argument. No need to check ourself.
        if (owner instanceof JDesktopPane) {
            final JInternalFrame frame = new JInternalFrame(title, true, true, true, true);
            frame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
            frame.addInternalFrameListener(InternalWindowListener.wrap(listener));
            ((JDesktopPane) owner).add(frame);
            frame.getContentPane().add(panel);
            frame.pack();
            return frame;
        }
        if (owner instanceof Frame) {
            final JDialog dialog = new JDialog((Frame) owner, title);
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            dialog.addWindowListener(listener);
            dialog.getContentPane().add(panel);
            dialog.pack();
            return dialog;
        }
        if (owner instanceof Dialog) {
            final JDialog dialog = new JDialog((Dialog) owner, title);
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            dialog.addWindowListener(listener);
            dialog.getContentPane().add(panel);
            dialog.pack();
            return dialog;
        }
        owner = owner.getParent();
    }
    //
    // Add the panel as a standalone window.
    // This window has its own button on the task bar.
    //
    final JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(listener);
    frame.getContentPane().add(panel);
    frame.pack();
    return frame;
}
Example 56
Project: geotools-tike-master  File: SwingUtilities.java View source code
/**
     * Insert a Swing component into a frame. The kind of frame depends on the owner:
     *
     * <ul>
     *   <li>If {@code owner} or one of its parent is a {@link JDesktopPane},
     *       then {@code panel} is added into a {@link JInternalFrame}.</li>
     *   <li>If {@code owner} or one of its parent is a {@link Frame} or a {@link Dialog},
     *       then {@code panel} is added into a {@link JDialog}.</li>
     *   <li>Otherwise, {@code panel} is added into a {@link JFrame}.</li>
     * </ul>
     *
     * @param  owner The frame's owner, or {@code null} if none.
     * @param  panel The panel to insert into a frame.
     * @param  title The frame's title.
     * @param  listener A listener to receives frame events.  If non-null, then this listener will
     *         be registered to whatever kind of frame this method will constructs. In the special
     *         case where this method constructs an {@linkplain JInternalFrame internal frame} and
     *         the {@code listener} is not an instance of {@link javax.swing.event.InternalFrameListener},
     *         then this method will wrap the {@code listener} into an {@code InternalFrameListener}.
     * @return The frame. This frame is not initially visible. The method
     *         {@code Component.setVisible(true)} must be invoked in order to show the frame.
     */
public static Component toFrame(Component owner, final JComponent panel, final String title, final WindowListener listener) {
    while (owner != null) {
        if (owner == panel) {
            throw new IllegalArgumentException();
        }
        // NOTE: All 'addFooListener(...)' below ignore null argument. No need to check ourself.
        if (owner instanceof JDesktopPane) {
            final JInternalFrame frame = new JInternalFrame(title, true, true, true, true);
            frame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
            frame.addInternalFrameListener(InternalWindowListener.wrap(listener));
            ((JDesktopPane) owner).add(frame);
            frame.getContentPane().add(panel);
            frame.pack();
            return frame;
        }
        if (owner instanceof Frame) {
            final JDialog dialog = new JDialog((Frame) owner, title);
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            dialog.addWindowListener(listener);
            dialog.getContentPane().add(panel);
            dialog.pack();
            return dialog;
        }
        if (owner instanceof Dialog) {
            final JDialog dialog = new JDialog((Dialog) owner, title);
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            dialog.addWindowListener(listener);
            dialog.getContentPane().add(panel);
            dialog.pack();
            return dialog;
        }
        owner = owner.getParent();
    }
    //
    // Add the panel as a standalone window.
    // This window has its own button on the task bar.
    //
    final JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(listener);
    frame.getContentPane().add(panel);
    frame.pack();
    return frame;
}
Example 57
Project: geotools_trunk-master  File: SwingUtilities.java View source code
/**
     * Insert a Swing component into a frame. The kind of frame depends on the owner:
     *
     * <ul>
     *   <li>If {@code owner} or one of its parent is a {@link JDesktopPane},
     *       then {@code panel} is added into a {@link JInternalFrame}.</li>
     *   <li>If {@code owner} or one of its parent is a {@link Frame} or a {@link Dialog},
     *       then {@code panel} is added into a {@link JDialog}.</li>
     *   <li>Otherwise, {@code panel} is added into a {@link JFrame}.</li>
     * </ul>
     *
     * @param  owner The frame's owner, or {@code null} if none.
     * @param  panel The panel to insert into a frame.
     * @param  title The frame's title.
     * @param  listener A listener to receives frame events.  If non-null, then this listener will
     *         be registered to whatever kind of frame this method will constructs. In the special
     *         case where this method constructs an {@linkplain JInternalFrame internal frame} and
     *         the {@code listener} is not an instance of {@link javax.swing.event.InternalFrameListener},
     *         then this method will wrap the {@code listener} into an {@code InternalFrameListener}.
     * @return The frame. This frame is not initially visible. The method
     *         {@code Component.setVisible(true)} must be invoked in order to show the frame.
     */
public static Component toFrame(Component owner, final JComponent panel, final String title, final WindowListener listener) {
    while (owner != null) {
        if (owner == panel) {
            throw new IllegalArgumentException();
        }
        // NOTE: All 'addFooListener(...)' below ignore null argument. No need to check ourself.
        if (owner instanceof JDesktopPane) {
            final JInternalFrame frame = new JInternalFrame(title, true, true, true, true);
            frame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
            frame.addInternalFrameListener(InternalWindowListener.wrap(listener));
            ((JDesktopPane) owner).add(frame);
            frame.getContentPane().add(panel);
            frame.pack();
            return frame;
        }
        if (owner instanceof Frame) {
            final JDialog dialog = new JDialog((Frame) owner, title);
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            dialog.addWindowListener(listener);
            dialog.getContentPane().add(panel);
            dialog.pack();
            return dialog;
        }
        if (owner instanceof Dialog) {
            final JDialog dialog = new JDialog((Dialog) owner, title);
            dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            dialog.addWindowListener(listener);
            dialog.getContentPane().add(panel);
            dialog.pack();
            return dialog;
        }
        owner = owner.getParent();
    }
    //
    // Add the panel as a standalone window.
    // This window has its own button on the task bar.
    //
    final JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(listener);
    frame.getContentPane().add(panel);
    frame.pack();
    return frame;
}
Example 58
Project: jogl-demos-master  File: OffscreenDesktopManager.java View source code
public void closeFrame(JInternalFrame f) {
    boolean findNext = f.isSelected();
    JDesktopPane c = getDesktopPaneParent(f);
    if (findNext)
        try {
            f.setSelected(false);
        } catch (PropertyVetoException e2) {
        }
    if (c != null) {
        c.remove(f.getParent());
        repaintPortionOfDesktop(c, f);
    }
    removeIconFor(f);
    if (f.getNormalBounds() != null)
        f.setNormalBounds(null);
    if (wasIcon(f))
        setWasIcon(f, null);
    if (findNext)
        activateNextFrame(c);
    setNeedsReLayout();
}
Example 59
Project: pdfxtk-master  File: Preferences.java View source code
void grab(JDesktopPane jdp) {
    if (applyCnt != 0)
        return;
    JInternalFrame[] frames = jdp.getAllFrames();
    positions = new int[frames.length];
    paths = new String[frames.length];
    for (int i = 0; i < frames.length; i++) {
        iiuf.util.Preferences.watch(frames[i]);
        positions[i] = jdp.getPosition(frames[i]);
        paths[i] = iiuf.util.Preferences.getPath(frames[i]);
    }
}
Example 60
Project: vassal-master  File: GenericListener.java View source code
/**
     * Return true if the given component is likely to be a container such the each
     * component within the container should be be considered as a user input.
     * 
     * @param c
     * @return true if the component children should have this listener added.
     */
protected boolean isProbablyAContainer(Component c) {
    boolean result = extListener != null ? extListener.isContainer(c) : false;
    if (!result) {
        boolean isSwing = isSwingClass(c);
        if (isSwing) {
            result = c instanceof JPanel || c instanceof JSplitPane || c instanceof JToolBar || c instanceof JViewport || c instanceof JScrollPane || c instanceof JFrame || c instanceof JRootPane || c instanceof Window || c instanceof Frame || c instanceof Dialog || c instanceof JTabbedPane || c instanceof JInternalFrame || c instanceof JDesktopPane || c instanceof JLayeredPane;
        } else {
            result = c instanceof Container;
        }
    }
    return result;
}
Example 61
Project: damp.ekeko.snippets-master  File: Main.java View source code
private void init() {
    // Set the main application Icon.
    this.setIconImage(Loader.load("jmonkey16.gif"));
    // Set the look & feel for the app.
    try {
        UIManager.setLookAndFeel(this.getRegistry().getString("MAIN", "main.look&feel", UIManager.getSystemLookAndFeelClassName()));
    } catch (Exception e) {
        System.out.println("Unknown Look & Feel. Using Defaults.");
    }
    //Thread.sleep(1500);
    //splasher.showStatus("Setting up Desktop..");
    _DESKTOP = new MainDesktop();
    _DESKTOP.setBorder(BorderFactory.createLoweredBevelBorder());
    // run of the program) -- Brill
    if (this.getRegistry().getBoolean("MAIN", "mdi.outline.drag", true)) {
        _DESKTOP.putClientProperty("JDesktopPane.dragMode", "outline");
    }
    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    // We'll add everything to our special content pane first.
    this.setContentPane(contentPane);
    // Don't need to store DocumentManager
    // The desktop pane should always know
    // where it is and how to get it.
    // this helps us to write our code
    // so it doesn't depend on our own
    // copy being valid
    _DESKTOP.setDesktopManager(new DocumentManager(this));
    // we need to add the toolbars
    // before we add the desktop pane.
    // -- Brill 03/18/1999
    //Thread.sleep(1500);
    //splasher.showStatus("Setting up toolbars...");
    JPanel fileToolPanel = new JPanel();
    fileToolPanel.setLayout(new BorderLayout());
    fileToolPanel.add(this.getFileToolBar(), this.getRegistry().getString("USER", "position.file.toolbar", BorderLayout.WEST));
    // the edit toolbar should also go in here.
    JPanel formatToolPanel = new JPanel();
    formatToolPanel.setLayout(new BorderLayout());
    formatToolPanel.add(this.getFormatToolBar(), this.getRegistry().getString("USER", "position.format.toolbar", BorderLayout.NORTH));
    JPanel desktopContainer = new JPanel();
    desktopContainer.setLayout(new BorderLayout());
    desktopContainer.add(_DESKTOP, BorderLayout.CENTER);
    fileToolPanel.add(formatToolPanel, BorderLayout.CENTER);
    formatToolPanel.add(desktopContainer, BorderLayout.CENTER);
    contentPane.add(this.getStatusLabel(), BorderLayout.SOUTH);
    contentPane.add(fileToolPanel, BorderLayout.CENTER);
    //contentPane.add(_DESKTOP, BorderLayout.CENTER);
    // Create and add the menu bar.
    this.setJMenuBar(createMenuBar());
    //Thread.sleep(1500);
    //splasher.showStatus("Reading in Registry...");
    Enumeration fhEnum = this.getRegistry().getKeys("FILE_HISTORY");
    while (fhEnum.hasMoreElements()) {
        String fhKey = (String) fhEnum.nextElement();
        JMenuItem item = new JMenuItem(fhKey);
        item.setActionCommand(this.getRegistry().getString("FILE_HISTORY", fhKey, fhKey));
        item.addActionListener(_FILE_HISTROY_ACTION);
        _FILE_HISTORY.add(item);
    }
    //Thread.sleep(1500);
    //splasher.close();
    // Added this to dispose of
    // the main app window when
    // it gets closed.
    this.addWindowListener(new java.awt.event.WindowAdapter() {

        public void windowClosing(java.awt.event.WindowEvent e) {
            doExit();
        }
    });
    // Restore the apps last location and size.
    // Changed this to use the screen size as defaults.
    this.setSize(this.getRegistry().getInteger("MAIN", "main.window.w", ((Toolkit.getDefaultToolkit().getScreenSize().width / 5) * 4)), this.getRegistry().getInteger("MAIN", "main.window.h", ((Toolkit.getDefaultToolkit().getScreenSize().height / 5) * 4)));
    this.setLocation(this.getRegistry().getInteger("MAIN", "main.window.x", 0), this.getRegistry().getInteger("MAIN", "main.window.y", 0));
}
Example 62
Project: Electric8-master  File: Main.java View source code
/**
	 * The main entry point of Electric.
	 * @param args the arguments to the program.
	 */
public void init() {
    String param;
    List<String> argsList = null;
    /**
		// -v (short version)
		if (hasCommandLineOption(argsList, "-v"))
		{
			System.out.println(Version.getVersion());
			System.exit(0);
		}

		// -version
		if (hasCommandLineOption(argsList, "-version"))
		{
			System.out.println(Version.getApplicationInformation());
			System.out.println("\t"+Version.getVersionInformation());
			System.out.println("\t"+Version.getCopyrightInformation());
			System.out.println("\t"+Version.getWarrantyInformation());
			System.exit(0);
		}

        // -help
        if (hasCommandLineOption(argsList, "-help"))
		{
	        System.out.println("Usage (without plugins):");
	        System.out.println("\tjava -jar electric.jar [electric-options]");
	        System.out.println("Usage (with plugins):");
	        System.out.println("\tjava -classpath electric.jar<delim>{list of plugins} com.sun.electric.Launcher [electric-options]");
	        System.out.println("\t\twhere <delim> is OS-dependant separator (colon or semicolon)");
	        System.out.println("\nOptions:");
            System.out.println("\t-mdi: multiple document interface mode");
	        System.out.println("\t-sdi: single document interface mode");
	        System.out.println("\t-NOMINMEM: ignore minimum memory provided for JVM");
	        System.out.println("\t-s <script name>: bean shell script to execute");
	        System.out.println("\t-version: version information");
	        System.out.println("\t-v: brief version information");
	        System.out.println("\t-debug: debug mode. Extra information is available");
            System.out.println("\t-threads <numThreads>: recommended size of thread pool for Job execution.");
            System.out.println("\t-logging <filePath>: log server events in a binary file");
            System.out.println("\t-socket <socket>: socket port for client/server interaction");
	        System.out.println("\t-batch: batch mode implies 'no GUI', and nothing more");
            System.out.println("\t-server: dump trace of snapshots");
            System.out.println("\t-client <machine name>: replay trace of snapshots");
	        System.out.println("\t-help: this message");

			System.exit(0);
		}
	*/
    // set applet size
    appSize = getSize();
    Toolkit tk = Toolkit.getDefaultToolkit();
    scrnSize = tk.getScreenSize();
    runMode = DEFAULT_MODE;
    String pipeOptions = "";
    String numThreadsString = null;
    int numThreads = 0;
    if (numThreadsString != null) {
        numThreads = TextUtils.atoi(numThreadsString);
        if (numThreads > 0)
            pipeOptions += " -threads " + numThreads;
        else
            System.out.println("Invalid option -threads " + numThreadsString);
    }
    String loggingFilePath = null;
    if (loggingFilePath != null) {
        pipeOptions += " -logging " + loggingFilePath;
    }
    String socketString = null;
    int socketPort = 0;
    if (socketString != null) {
        socketPort = TextUtils.atoi(socketString);
        if (socketPort > 0)
            pipeOptions += " -socket " + socketPort;
        else
            System.out.println("Invalid option -socket " + socketString);
    }
    ActivityLogger.initialize("electric", true, true, true, /*false*/
    User.isEnableLog(), User.isMultipleLog());
    Client.OS os = Client.getOperatingSystem();
    try {
        switch(os) {
            case WINDOWS:
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                break;
            case UNIX:
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                break;
            case MACINTOSH:
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.MacLookAndFeel");
                break;
        }
    } catch (Exception e) {
    }
    cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
    addComponentListener(new ReshapeComponentAdapter());
    // For 3D: LightWeight v/s heavy: mixing awt and swing
    try {
        javax.swing.JPopupMenu.setDefaultLightWeightPopupEnabled(false);
        javax.swing.ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }
    desktop = new JDesktopPane();
    desktop.setVisible(true);
    getContentPane().add(desktop);
    AbstractUserInterface ui;
    //switch ()
    //{
    //	case :
    //}
    //if (runMode == Mode.FULL_SCREEN_SAFE || runMode == Mode.CLIENT)
    //ui = new AppletUserInterface();
    ui = new UserInterfaceMain(argsList, mode, this);
    //else
    //    ui = new UserInterfaceDummy();
    MessagesStream.getMessagesStream();
    // initialize database
    TextDescriptor.cacheSize();
    Tool.initAllTools();
    Pref.lockCreation();
    EDatabase database = new EDatabase(IdManager.stdIdManager.getInitialSnapshot(), "clientDB");
    EDatabase.setClientDatabase(database);
    Job.setUserInterface(new UserInterfaceInitial(database));
    InitDatabase job = new InitDatabase(argsList);
    EDatabase.setServerDatabase(new EDatabase(IdManager.stdIdManager.getInitialSnapshot(), "serverDB"));
    EDatabase.setCheckExamine();
    Job.initJobManager(numThreads, loggingFilePath, socketPort, ui, job);
}
Example 63
Project: typica-master  File: QueryTool.java View source code
private void layoutGUI() {
    setLayout(new GridBagLayout());
    JButton runQuery = new JButton("run");
    runQuery.addActionListener(this);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    add(runQuery, gbc);
    JButton sponsor = new JButton("Sponsored by:", new ImageIcon("build/classes/dtlogo150.png"));
    sponsor.setHorizontalTextPosition(SwingConstants.LEFT);
    sponsor.setBorderPainted(false);
    sponsor.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            JOptionPane.showInternalMessageDialog(results, "<html><center>Work on QueryTool has been generously sponsored by directThought.<br>Please consider using them for your next project.<br>See <a href=\"http://directThought.com/\">directThought.com</a> for more information.</center></html>", dom.getName() + " metadata", JOptionPane.PLAIN_MESSAGE);
        }
    });
    gbc = new GridBagConstraints();
    add(sponsor, gbc);
    JLabel regLab = new JLabel("Region:");
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.EAST;
    gbc.weightx = 1.0;
    add(regLab, gbc);
    regionList = new JComboBox(new String[] { "US", "EU" });
    regionList.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            String endpoint = "sdb.amazonaws.com";
            if (regionList.getSelectedItem().equals("EU")) {
                endpoint = "sdb.eu-west-1.amazonaws.com";
            }
            sdb.setEndpoint(endpoint);
            populateDomainList();
            setDomain((String) domainList.getSelectedItem());
        }
    });
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.EAST;
    add(regionList, gbc);
    JLabel domLab = new JLabel("Domain:");
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.EAST;
    gbc.weightx = 1.0;
    add(domLab, gbc);
    domainList = new JComboBox();
    domainList.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            setDomain((String) domainList.getSelectedItem());
        }
    });
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.EAST;
    add(domainList, gbc);
    populateDomainList();
    setDomain((String) domainList.getSelectedItem());
    JButton metadata = new JButton("Get Metadata");
    metadata.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            try {
                DomainMetadata dm = dom.getMetadata().getResult();
                StringBuilder dmOutput = new StringBuilder();
                dmOutput.append("Item Count : ");
                dmOutput.append(dm.getItemCount());
                dmOutput.append("\nAttr Name Count : ");
                dmOutput.append(dm.getAttributeNameCount());
                dmOutput.append("\nAttr Value Count : ");
                dmOutput.append(dm.getAttributeValueCount());
                dmOutput.append("\nItem Names Size : ");
                dmOutput.append(dm.getItemNamesSizeBytes());
                dmOutput.append("\nAttribute Names Size : ");
                dmOutput.append(dm.getAttributeNamesSizeBytes());
                dmOutput.append("\nAttribute Value Size : ");
                dmOutput.append(dm.getAttributeValuesSizeBytes());
                int result = JOptionPane.showInternalOptionDialog(results, dmOutput.toString(), dom.getName() + " Domain", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, new String[] { "Delete", "Close" }, "Close");
                if (result == 0) {
                    result = JOptionPane.showInternalConfirmDialog(results, "Do you really want to delete domain : " + dom.getName(), "Delete " + dom.getName(), JOptionPane.YES_NO_OPTION);
                    if (result == JOptionPane.YES_OPTION) {
                        sdb.deleteDomain(dom);
                        dom = null;
                        populateDomainList();
                        setDomain((String) domainList.getSelectedItem());
                    }
                }
            } catch (SDBException ex) {
                System.err.println("Problem fetching metadata or deleting domain: " + ex.getMessage());
            }
        }
    });
    gbc = new GridBagConstraints();
    add(metadata, gbc);
    JButton newDom = new JButton("New Domain");
    newDom.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            try {
                String result = JOptionPane.showInternalInputDialog(results, "Enter the name of the domain you'd like to create.");
                if (result != null) {
                    dom = sdb.createDomain(result).getResult();
                    populateDomainList();
                }
            } catch (SDBException ex) {
                System.err.println("Problem creating domain : " + ex.getMessage());
            }
        }
    });
    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(newDom, gbc);
    querySpace = new JTextArea();
    querySpace.setFont(new Font("monospaced", Font.PLAIN, 14));
    querySpace.addKeyListener(new KeyAdapter() {

        public void keyTyped(KeyEvent evt) {
            if (evt.isControlDown() && evt.getKeyChar() == '\r') {
                executeQuery();
            }
        }
    });
    results = new JDesktopPane();
    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(querySpace), results);
    querySpace.setMinimumSize(new Dimension(100, 100));
    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    add(split, gbc);
}
Example 64
Project: typica-softwaremill-master  File: QueryTool.java View source code
private void layoutGUI() {
    setLayout(new GridBagLayout());
    JButton runQuery = new JButton("run");
    runQuery.addActionListener(this);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    add(runQuery, gbc);
    JButton sponsor = new JButton("Sponsored by:", new ImageIcon("build/classes/dtlogo150.png"));
    sponsor.setHorizontalTextPosition(SwingConstants.LEFT);
    sponsor.setBorderPainted(false);
    sponsor.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            JOptionPane.showInternalMessageDialog(results, "<html><center>Work on QueryTool has been generously sponsored by directThought.<br>Please consider using them for your next project.<br>See <a href=\"http://directThought.com/\">directThought.com</a> for more information.</center></html>", dom.getName() + " metadata", JOptionPane.PLAIN_MESSAGE);
        }
    });
    gbc = new GridBagConstraints();
    add(sponsor, gbc);
    JLabel regLab = new JLabel("Region:");
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.EAST;
    gbc.weightx = 1.0;
    add(regLab, gbc);
    regionList = new JComboBox(new String[] { "US", "EU" });
    regionList.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            String endpoint = "sdb.amazonaws.com";
            if (regionList.getSelectedItem().equals("EU")) {
                endpoint = "sdb.eu-west-1.amazonaws.com";
            }
            sdb.setEndpoint(endpoint);
            populateDomainList();
            setDomain((String) domainList.getSelectedItem());
        }
    });
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.EAST;
    add(regionList, gbc);
    JLabel domLab = new JLabel("Domain:");
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.EAST;
    gbc.weightx = 1.0;
    add(domLab, gbc);
    domainList = new JComboBox();
    domainList.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            setDomain((String) domainList.getSelectedItem());
        }
    });
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.EAST;
    add(domainList, gbc);
    populateDomainList();
    setDomain((String) domainList.getSelectedItem());
    JButton metadata = new JButton("Get Metadata");
    metadata.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            try {
                DomainMetadata dm = dom.getMetadata().getResult();
                StringBuilder dmOutput = new StringBuilder();
                dmOutput.append("Item Count : ");
                dmOutput.append(dm.getItemCount());
                dmOutput.append("\nAttr Name Count : ");
                dmOutput.append(dm.getAttributeNameCount());
                dmOutput.append("\nAttr Value Count : ");
                dmOutput.append(dm.getAttributeValueCount());
                dmOutput.append("\nItem Names Size : ");
                dmOutput.append(dm.getItemNamesSizeBytes());
                dmOutput.append("\nAttribute Names Size : ");
                dmOutput.append(dm.getAttributeNamesSizeBytes());
                dmOutput.append("\nAttribute Value Size : ");
                dmOutput.append(dm.getAttributeValuesSizeBytes());
                int result = JOptionPane.showInternalOptionDialog(results, dmOutput.toString(), dom.getName() + " Domain", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, new String[] { "Delete", "Close" }, "Close");
                if (result == 0) {
                    result = JOptionPane.showInternalConfirmDialog(results, "Do you really want to delete domain : " + dom.getName(), "Delete " + dom.getName(), JOptionPane.YES_NO_OPTION);
                    if (result == JOptionPane.YES_OPTION) {
                        sdb.deleteDomain(dom);
                        dom = null;
                        populateDomainList();
                        setDomain((String) domainList.getSelectedItem());
                    }
                }
            } catch (SDBException ex) {
                System.err.println("Problem fetching metadata or deleting domain: " + ex.getMessage());
            }
        }
    });
    gbc = new GridBagConstraints();
    add(metadata, gbc);
    JButton newDom = new JButton("New Domain");
    newDom.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            try {
                String result = JOptionPane.showInternalInputDialog(results, "Enter the name of the domain you'd like to create.");
                if (result != null) {
                    dom = sdb.createDomain(result).getResult();
                    populateDomainList();
                }
            } catch (SDBException ex) {
                System.err.println("Problem creating domain : " + ex.getMessage());
            }
        }
    });
    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(newDom, gbc);
    querySpace = new JTextArea();
    querySpace.setFont(new Font("monospaced", Font.PLAIN, 14));
    querySpace.addKeyListener(new KeyAdapter() {

        public void keyTyped(KeyEvent evt) {
            if (evt.isControlDown() && evt.getKeyChar() == '\r') {
                executeQuery();
            }
        }
    });
    results = new JDesktopPane();
    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(querySpace), results);
    querySpace.setMinimumSize(new Dimension(100, 100));
    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    add(split, gbc);
}
Example 65
Project: intellij-community-master  File: SwingBuilderNonCodeMemberContributor.java View source code
private void generateMethods() {
    // registerSupportNodes()
    methodObject("action", "javax.swing.Action", "groovy.swing.factory.ActionFactory");
    methodObject("actions", CommonClassNames.JAVA_UTIL_LIST, "groovy.swing.factory.CollectionFactory");
    methodObject("map", CommonClassNames.JAVA_UTIL_MAP, "groovy.swing.factory.MapFactory");
    methodObject("imageIcon", "javax.swing.ImageIcon", "groovy.swing.factory.ImageIconFactory", ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder().put("image", new TypeCondition(type("java.awt.Image"))).put("url", new TypeCondition(type("java.net.URL"))).put("file", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("resource", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("class", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("description", NamedArgumentDescriptor.TYPE_STRING).build());
    methodObject("buttonGroup", "javax.swing.BoxLayout", "groovy.swing.factory.ButtonGroupFactory");
    methodObject("noparent", CommonClassNames.JAVA_UTIL_LIST, "groovy.swing.factory.CollectionFactory");
    registerExplicitMethod("keyStrokeAction", "createKeyStrokeAction");
    //registerExplicitMethod("shortcut", "shortcut");
    // registerBinding()
    methodObject("bind", "org.codehaus.groovy.binding.FullBinding", "groovy.swing.factory.BindFactory", ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder().put("source", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("target", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("update", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("targetProperty", NamedArgumentDescriptor.TYPE_STRING).put("mutual", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("sourceEvent", NamedArgumentDescriptor.TYPE_STRING).put("sourceValue", NamedArgumentDescriptor.TYPE_CLOSURE).put("sourceProperty", NamedArgumentDescriptor.TYPE_STRING).put("value", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("bind", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("group", NamedArgumentDescriptor.SIMPLE_ON_TOP).build());
    methodObject("bindProxy", "org.codehaus.groovy.binding.BindingProxy", "groovy.swing.factory.BindProxyFactory", ImmutableMap.of("bind", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    methodObject("bindGroup", "org.codehaus.groovy.binding.AggregateBinding", "groovy.swing.factory.BindGroupFactory", ImmutableMap.of("bind", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    // registerPassThruNodes()
    methodObject("widget", "java.awt.Component", "groovy.swing.factory.WidgetFactory", ImmutableMap.of("widget", new TypeCondition(type("java.awt.Component"))));
    methodObject("container", "java.awt.Component", "groovy.swing.factory.WidgetFactory", ImmutableMap.of("container", new TypeCondition(type("java.awt.Component"))));
    methodObject("bean", CommonClassNames.JAVA_LANG_OBJECT, "groovy.swing.factory.WidgetFactory", ImmutableMap.of("bean", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    // registerWindows()
    methodObject("dialog", "javax.swing.JDialog", "groovy.swing.factory.DialogFactory", ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder().put("owner", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("defaultButtonProperty", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("pack", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("show", NamedArgumentDescriptor.SIMPLE_ON_TOP).build());
    methodObject("fileChooser", "javax.swing.JFileChooser", null);
    methodObject("frame", "javax.swing.JFrame", "groovy.swing.factory.FrameFactory", ImmutableMap.of("pack", NamedArgumentDescriptor.SIMPLE_ON_TOP, "show", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    methodObject("optionPane", "javax.swing.JOptionPane", null);
    methodObject("window", "javax.swing.JWindow", "groovy.swing.factory.WindowFactory", ImmutableMap.of("pack", NamedArgumentDescriptor.SIMPLE_ON_TOP, "show", NamedArgumentDescriptor.SIMPLE_ON_TOP, "owner", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    // registerActionButtonWidgets()
    methodObject("button", "javax.swing.JButton", "groovy.swing.factory.RichActionWidgetFactory");
    methodObject("checkBox", "javax.swing.JCheckBox", "groovy.swing.factory.RichActionWidgetFactory");
    methodObject("checkBoxMenuItem", "javax.swing.JCheckBoxMenuItem", "groovy.swing.factory.RichActionWidgetFactory");
    methodObject("menuItem", "javax.swing.JMenuItem", "groovy.swing.factory.RichActionWidgetFactory");
    methodObject("radioButton", "javax.swing.JRadioButton", "groovy.swing.factory.RichActionWidgetFactory");
    methodObject("radioButtonMenuItem", "javax.swing.JRadioButtonMenuItem", "groovy.swing.factory.RichActionWidgetFactory");
    methodObject("toggleButton", "javax.swing.JToggleButton", "groovy.swing.factory.RichActionWidgetFactory");
    // registerTextWidgets()
    methodObject("editorPane", "javax.swing.JEditorPane", "groovy.swing.factory.TextArgWidgetFactory");
    methodObject("label", "javax.swing.JLabel", "groovy.swing.factory.TextArgWidgetFactory");
    methodObject("passwordField", "javax.swing.JPasswordField", "groovy.swing.factory.TextArgWidgetFactory");
    methodObject("textArea", "javax.swing.JTextArea", "groovy.swing.factory.TextArgWidgetFactory");
    methodObject("textField", "javax.swing.JTextField", "groovy.swing.factory.TextArgWidgetFactory");
    methodObject("textPane", "javax.swing.JTextPane", "groovy.swing.factory.TextArgWidgetFactory");
    methodObject("formattedTextField", "javax.swing.JFormattedTextField", "groovy.swing.factory.FormattedTextFactory", ImmutableMap.of("format", new TypeCondition(type("java.text.Format")), "value", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    // registerMDIWidgets()
    methodObject("desktopPane", "javax.swing.JDesktopPane", null);
    methodObject("internalFrame", "javax.swing.JInternalFrame", "groovy.swing.factory.InternalFrameFactory");
    // registerBasicWidgets()
    methodObject("colorChooser", "javax.swing.JColorChooser", null);
    methodObject("comboBox", "javax.swing.JComboBox", "groovy.swing.factory.ComboBoxFactory", ImmutableMap.of("items", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    methodObject("list", "javax.swing.JList", "groovy.swing.factory.ListFactory", ImmutableMap.of("items", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    methodObject("progressBar", "javax.swing.JProgressBar", null);
    methodObject("separator", "javax.swing.JSeparator", "groovy.swing.factory.SeparatorFactory");
    methodObject("scrollBar", "javax.swing.JScrollBar", null);
    methodObject("slider", "javax.swing.JSlider", null);
    methodObject("spinner", "javax.swing.JSpinner", null);
    methodObject("tree", "javax.swing.JTree", null);
    //registerMenuWidgets()
    methodObject("menu", "javax.swing.JMenu", null);
    methodObject("menuBar", "javax.swing.JMenuBar", null);
    methodObject("popupMenu", "javax.swing.JPopupMenu", null);
    // registerContainers()
    methodObject("panel", "javax.swing.JPanel", null);
    methodObject("scrollPane", "javax.swing.JScrollPane", "groovy.swing.factory.ScrollPaneFactory");
    methodObject("splitPane", "javax.swing.JSplitPane", "groovy.swing.factory.SplitPaneFactory");
    methodObject("tabbedPane", "javax.swing.JTabbedPane", "groovy.swing.factory.TabbedPaneFactory");
    methodObject("toolBar", "javax.swing.JToolBar", null);
    methodObject("viewport", "javax.swing.JViewport", null);
    methodObject("layeredPane", "javax.swing.JLayeredPane", null);
    // registerDataModels()
    methodObject("boundedRangeModel", "javax.swing.DefaultBoundedRangeModel", null);
    methodObject("spinnerDateModel", "javax.swing.SpinnerDateModel", null);
    methodObject("spinnerListModel", "javax.swing.SpinnerListModel", null);
    methodObject("spinnerNumberModel", "javax.swing.SpinnerNumberModel", null);
    // registerTableComponents()
    methodObject("table", "javax.swing.JTable", "groovy.swing.factory.TableFactory");
    methodObject("tableColumn", "javax.swing.table.TableColumn", null);
    methodObject("tableModel", "javax.swing.table.TableModel", "groovy.swing.factory.TableModelFactory", ImmutableMap.of("tableModel", new TypeCondition(type("javax.swing.table.TableModel")), "model", new TypeCondition(type("groovy.model.ValueModel")), "list", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    methodObject("propertyColumn", "javax.swing.table.TableColumn", "groovy.swing.factory.PropertyColumnFactory", ImmutableMap.of("propertyName", NamedArgumentDescriptor.TYPE_STRING, "header", NamedArgumentDescriptor.SIMPLE_ON_TOP, "type", new TypeCondition(type(CommonClassNames.JAVA_LANG_CLASS)), "editable", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    methodObject("closureColumn", "javax.swing.table.TableColumn", "groovy.swing.factory.ClosureColumnFactory", ImmutableMap.of("header", NamedArgumentDescriptor.SIMPLE_ON_TOP, "read", new TypeCondition(type(GroovyCommonClassNames.GROOVY_LANG_CLOSURE)), "write", new TypeCondition(type(GroovyCommonClassNames.GROOVY_LANG_CLOSURE)), "type", new TypeCondition(type(CommonClassNames.JAVA_LANG_CLASS))));
    methodObject("columnModel", "javax.swing.table.TableColumnModel", "groovy.swing.factory.ColumnModelFactory");
    methodObject("column", "javax.swing.table.TableColumn", "groovy.swing.factory.ColumnFactory", ImmutableMap.of("width", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    // registerBasicLayouts()
    methodObject("borderLayout", "java.awt.BorderLayout", "groovy.swing.factory.LayoutFactory");
    methodObject("cardLayout", "java.awt.CardLayout", "groovy.swing.factory.LayoutFactory");
    methodObject("flowLayout", "java.awt.FlowLayout", "groovy.swing.factory.LayoutFactory");
    methodObject("gridLayout", "java.awt.GridLayout", "groovy.swing.factory.LayoutFactory");
    methodObject("overlayLayout", "javax.swing.OverlayLayout", "groovy.swing.factory.LayoutFactory");
    methodObject("springLayout", "javax.swing.SpringLayout", "groovy.swing.factory.LayoutFactory");
    methodObject("gridBagLayout", "java.awt.GridBagLayout", "groovy.swing.factory.LayoutFactory");
    methodObject("gridBagConstraints", "java.awt.GridBagConstraints", "groovy.swing.factory.LayoutFactory");
    methodObject("gbc", "java.awt.GridBagConstraints", "groovy.swing.factory.LayoutFactory");
    // registerBoxLayout()
    methodObject("boxLayout", "javax.swing.BoxLayout", "groovy.swing.factory.BoxLayoutFactory", ImmutableMap.of("axis", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    methodObject("box", "javax.swing.Box", "groovy.swing.factory.BoxFactory", ImmutableMap.of("axis", new TypeCondition(type("java.lang.Number"))));
    methodObject("hbox", "javax.swing.Box", "groovy.swing.factory.HBoxFactory");
    methodObject("hglue", "java.awt.Component", "groovy.swing.factory.HGlueFactory");
    methodObject("hstrut", "java.awt.Component", "groovy.swing.factory.HStrutFactory", ImmutableMap.of("width", new TypeCondition(type("java.lang.Number"))));
    methodObject("vbox", "javax.swing.Box", "groovy.swing.factory.VBoxFactory");
    methodObject("vglue", "java.awt.Component", "groovy.swing.factory.VGlueFactory");
    methodObject("vstrut", "java.awt.Component", "groovy.swing.factory.VStrutFactory", ImmutableMap.of("height", new TypeCondition(type("java.lang.Number"))));
    methodObject("glue", "java.awt.Component", "groovy.swing.factory.GlueFactory");
    methodObject("rigidArea", "java.awt.Component", "groovy.swing.factory.RigidAreaFactory", ImmutableMap.of("size", new TypeCondition(type("java.awt.Dimension")), "height", new TypeCondition(type("java.lang.Number")), "width", new TypeCondition(type("java.lang.Number"))));
    // registerTableLayout()
    methodObject("tableLayout", "groovy.swing.impl.TableLayout", "groovy.swing.factory.TableLayoutFactory");
    methodObject("tr", "groovy.swing.impl.TableLayoutRow", "groovy.swing.factory.TRFactory");
    methodObject("td", "groovy.swing.impl.TableLayoutCell", "groovy.swing.factory.TDFactory");
    // registerBorders()
    methodObject("lineBorder", "javax.swing.border.LineBorder", "groovy.swing.factory.LineBorderFactory", ImmutableMap.of("parent", NamedArgumentDescriptor.SIMPLE_ON_TOP, "color", NamedArgumentDescriptor.SIMPLE_ON_TOP, "thickness", NamedArgumentDescriptor.SIMPLE_ON_TOP, "roundedCorners", NamedArgumentDescriptor.SIMPLE_ON_TOP));
    NamedArgumentDescriptor namedArgColor = new TypeCondition(type("java.awt.Color"));
    Map<String, NamedArgumentDescriptor> m = ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder().put("parent", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("highlight", namedArgColor).put("shadow", namedArgColor).put("highlightOuter", namedArgColor).put("highlightInner", namedArgColor).put("shadowOuter", namedArgColor).put("shadowInner", namedArgColor).build();
    methodObject("loweredBevelBorder", "javax.swing.border.Border", "groovy.swing.factory.BevelBorderFactory", m);
    methodObject("raisedBevelBorder", "javax.swing.border.Border", "groovy.swing.factory.BevelBorderFactory", m);
    m = ImmutableMap.of("parent", NamedArgumentDescriptor.SIMPLE_ON_TOP, "highlight", namedArgColor, "shadow", namedArgColor);
    methodObject("etchedBorder", "javax.swing.border.Border", "groovy.swing.factory.EtchedBorderFactory", m);
    methodObject("loweredEtchedBorder", "javax.swing.border.Border", "groovy.swing.factory.EtchedBorderFactory", m);
    methodObject("raisedEtchedBorder", "javax.swing.border.Border", "groovy.swing.factory.EtchedBorderFactory", m);
    methodObject("titledBorder", "javax.swing.border.TitledBorder", "groovy.swing.factory.TitledBorderFactory", ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder().put("parent", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("title", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("position", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("justification", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("border", new TypeCondition(type("javax.swing.border.Border"))).put("color", namedArgColor).put("font", new TypeCondition(type("java.awt.Font"))).build());
    methodObject("emptyBorder", "javax.swing.border.Border", "groovy.swing.factory.EmptyBorderFactory");
    methodObject("emptyBorder", "javax.swing.border.Border", "groovy.swing.factory.EmptyBorderFactory");
    methodObject("emptyBorder", "javax.swing.border.Border", "groovy.swing.factory.EmptyBorderFactory", ImmutableMap.of("parent", NamedArgumentDescriptor.SIMPLE_ON_TOP, "top", NamedArgumentDescriptor.TYPE_INTEGER, "left", NamedArgumentDescriptor.TYPE_INTEGER, "bottom", NamedArgumentDescriptor.TYPE_INTEGER, "right", NamedArgumentDescriptor.TYPE_INTEGER));
    methodObject("compoundBorder", "javax.swing.border.CompoundBorder", "groovy.swing.factory.CompoundBorderFactory", ImmutableMap.of("parent", NamedArgumentDescriptor.SIMPLE_ON_TOP, "inner", new TypeCondition(type("javax.swing.border.Border")), "outer", new TypeCondition(type("javax.swing.border.Border"))));
    methodObject("matteBorder", "javax.swing.border.Border", "groovy.swing.factory.MatteBorderFactory", ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder().put("parent", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("icon", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("color", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("size", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("top", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("left", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("bottom", NamedArgumentDescriptor.SIMPLE_ON_TOP).put("right", NamedArgumentDescriptor.SIMPLE_ON_TOP).build());
    // registerRenderers()
    methodObject("tableCellRenderer", "groovy.swing.impl.ClosureRenderer", "groovy.swing.factory.RendererFactory");
    methodObject("listCellRenderer", "groovy.swing.impl.ClosureRenderer", "groovy.swing.factory.RendererFactory");
    methodObject("cellRenderer", "groovy.swing.impl.ClosureRenderer", "groovy.swing.factory.RendererFactory");
    methodObject("headerRenderer", "groovy.swing.impl.ClosureRenderer", "groovy.swing.factory.RendererFactory");
    methodObject("onRender", CommonClassNames.JAVA_UTIL_MAP, "groovy.swing.factory.RendererUpdateFactory");
    // registerEditors()
    methodObject("cellEditor", "groovy.swing.impl.ClosureCellEditor", "groovy.swing.factory.CellEditorFactory");
    methodObject("editorValue", CommonClassNames.JAVA_UTIL_MAP, "groovy.swing.factory.CellEditorGetValueFactory");
    methodObject("prepareEditor", CommonClassNames.JAVA_UTIL_MAP, "groovy.swing.factory.CellEditorPrepareFactory");
}
Example 66
Project: mondrian-master  File: Workbench.java View source code
/**
     * This method is called from within the constructor to
     * initialize the form.
     */
private void initComponents() {
    desktopPane = new javax.swing.JDesktopPane();
    jToolBar1 = new javax.swing.JToolBar();
    jToolBar2 = new javax.swing.JToolBar();
    toolbarNewPopupMenu = new JPopupMenu();
    toolbarNewButton = new javax.swing.JButton();
    toolbarOpenButton = new javax.swing.JButton();
    toolbarSaveButton = new javax.swing.JButton();
    toolbarSaveAsButton = new javax.swing.JButton();
    jPanel1 = new javax.swing.JPanel();
    jPanel2 = new javax.swing.JPanel();
    toolbarPreferencesButton = new javax.swing.JButton();
    requireSchemaCheckboxMenuItem = new javax.swing.JCheckBoxMenuItem();
    menuBar = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    newMenu = new javax.swing.JMenu();
    newSchemaMenuItem = new javax.swing.JMenuItem();
    newQueryMenuItem = new javax.swing.JMenuItem();
    newJDBCExplorerMenuItem = new javax.swing.JMenuItem();
    newSchemaMenuItem2 = new javax.swing.JMenuItem();
    newQueryMenuItem2 = new javax.swing.JMenuItem();
    newJDBCExplorerMenuItem2 = new javax.swing.JMenuItem();
    openMenuItem = new javax.swing.JMenuItem();
    preferencesMenuItem = new javax.swing.JMenuItem();
    lastUsed1MenuItem = new javax.swing.JMenuItem();
    lastUsed2MenuItem = new javax.swing.JMenuItem();
    lastUsed3MenuItem = new javax.swing.JMenuItem();
    lastUsed4MenuItem = new javax.swing.JMenuItem();
    saveMenuItem = new javax.swing.JMenuItem();
    saveAsMenuItem = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    jSeparator2 = new javax.swing.JSeparator();
    jSeparator3 = new javax.swing.JSeparator();
    exitMenuItem = new javax.swing.JMenuItem();
    windowMenu = new javax.swing.JMenu();
    helpMenu = new javax.swing.JMenu();
    editMenu = new javax.swing.JMenu();
    cutMenuItem = new javax.swing.JMenuItem(new DefaultEditorKit.CutAction());
    copyMenuItem = new javax.swing.JMenuItem(new DefaultEditorKit.CopyAction());
    pasteMenuItem = new javax.swing.JMenuItem(new DefaultEditorKit.PasteAction());
    deleteMenuItem = new javax.swing.JMenuItem(new AbstractAction(getResourceConverter().getString("workbench.menu.delete", "Delete")) {

        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            JInternalFrame jf = desktopPane.getSelectedFrame();
            if (jf != null && jf.getContentPane().getComponent(0) instanceof SchemaExplorer) {
                SchemaExplorer se = (SchemaExplorer) jf.getContentPane().getComponent(0);
                TreePath tpath = se.tree.getSelectionPath();
                se.delete(tpath);
            }
        }
    });
    aboutMenuItem = new javax.swing.JMenuItem();
    toolsMenu = new javax.swing.JMenu();
    viewMenu = new javax.swing.JMenu();
    viewXmlMenuItem = new javax.swing.JCheckBoxMenuItem();
    setTitle(getResourceConverter().getString("workbench.panel.title", "Schema Workbench"));
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent evt) {
            storeWorkbenchProperties();
            storeDatabaseMeta();
            closeAllSchemaFrames(true);
        }
    });
    getContentPane().add(desktopPane, java.awt.BorderLayout.CENTER);
    newSchemaMenuItem2.setText(getResourceConverter().getString("workbench.menu.newSchema", "Schema"));
    newSchemaMenuItem2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            newSchemaMenuItemActionPerformed(evt);
        }
    });
    newQueryMenuItem2.setText(getResourceConverter().getString("workbench.menu.newQuery", "MDX Query"));
    newQueryMenuItem2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            newQueryMenuItemActionPerformed(evt);
        }
    });
    newJDBCExplorerMenuItem2.setText(getResourceConverter().getString("workbench.menu.newJDBC", "JDBC Explorer"));
    newJDBCExplorerMenuItem2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            newJDBCExplorerMenuItemActionPerformed(evt);
        }
    });
    toolbarNewPopupMenu.add(newSchemaMenuItem2);
    toolbarNewPopupMenu.add(newQueryMenuItem2);
    toolbarNewPopupMenu.add(newJDBCExplorerMenuItem2);
    jPanel2.setLayout(new java.awt.BorderLayout());
    jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    jPanel2.setMaximumSize(new java.awt.Dimension(50, 28));
    toolbarNewButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("new"))));
    toolbarNewButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.new", "New"));
    toolbarNewButton.setBorderPainted(false);
    toolbarNewButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            toolbarNewPopupMenu.show(jPanel2, 0, jPanel2.getSize().height);
        }
    });
    jToolBar2.setFloatable(false);
    jToolBar2.add(toolbarNewButton);
    jPanel2.add(jToolBar2, java.awt.BorderLayout.CENTER);
    toolbarNewArrowButton = new BasicArrowButton(SwingConstants.SOUTH);
    toolbarNewArrowButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.newArrow", "New"));
    toolbarNewArrowButton.setBorderPainted(false);
    toolbarNewArrowButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            toolbarNewPopupMenu.show(jPanel2, 0, jPanel2.getSize().height);
        }
    });
    jPanel2.add(toolbarNewArrowButton, java.awt.BorderLayout.EAST);
    jToolBar1.add(jPanel2, 0);
    toolbarOpenButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("open"))));
    toolbarOpenButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.open", "Open"));
    toolbarOpenButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            openMenuItemActionPerformed(evt);
        }
    });
    jToolBar1.add(toolbarOpenButton);
    toolbarSaveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("save"))));
    toolbarSaveButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.save", "Save"));
    toolbarSaveButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            saveMenuItemActionPerformed(evt);
        }
    });
    jToolBar1.add(toolbarSaveButton);
    toolbarSaveAsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("saveAs"))));
    toolbarSaveAsButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.saveAs", "Save As"));
    toolbarSaveAsButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            saveAsMenuItemActionPerformed(evt);
        }
    });
    jToolBar1.add(toolbarSaveAsButton);
    jPanel1.setMaximumSize(new java.awt.Dimension(8, 8));
    jToolBar1.add(jPanel1);
    toolbarPreferencesButton.setIcon(new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("preferences"))));
    toolbarPreferencesButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.connection", "Connection"));
    toolbarPreferencesButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            connectionButtonActionPerformed(evt);
        }
    });
    jToolBar1.add(toolbarPreferencesButton);
    getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH);
    fileMenu.setText(getResourceConverter().getString("workbench.menu.file", "File"));
    fileMenu.setMnemonic(KeyEvent.VK_F);
    newMenu.setText(getResourceConverter().getString("workbench.menu.new", "New"));
    newSchemaMenuItem.setText(getResourceConverter().getString("workbench.menu.newSchema", "Schema"));
    newSchemaMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            newSchemaMenuItemActionPerformed(evt);
        }
    });
    newMenu.add(newSchemaMenuItem);
    newQueryMenuItem.setText(getResourceConverter().getString("workbench.menu.newQuery", "MDX Query"));
    newQueryMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            newQueryMenuItemActionPerformed(evt);
        }
    });
    newMenu.add(newQueryMenuItem);
    newJDBCExplorerMenuItem.setText(getResourceConverter().getString("workbench.menu.newJDBC", "JDBC Explorer"));
    newJDBCExplorerMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            newJDBCExplorerMenuItemActionPerformed(evt);
        }
    });
    newMenu.add(newJDBCExplorerMenuItem);
    fileMenu.add(newMenu);
    openMenuItem.setText(getResourceConverter().getString("workbench.menu.open", "Open"));
    openMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            openMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(openMenuItem);
    saveMenuItem.setText(getResourceConverter().getString("workbench.menu.save", "Save"));
    saveMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            saveMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(saveMenuItem);
    saveAsMenuItem.setText(getResourceConverter().getString("workbench.menu.saveAsDot", "Save As ..."));
    saveAsMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            saveAsMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(saveAsMenuItem);
    // add last used
    fileMenu.add(jSeparator2);
    lastUsed1MenuItem.setText(getWorkbenchProperty("lastUsed1"));
    lastUsed1MenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            lastUsed1MenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(lastUsed1MenuItem);
    lastUsed2MenuItem.setText(getWorkbenchProperty("lastUsed2"));
    lastUsed2MenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            lastUsed2MenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(lastUsed2MenuItem);
    lastUsed3MenuItem.setText(getWorkbenchProperty("lastUsed3"));
    lastUsed3MenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            lastUsed3MenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(lastUsed3MenuItem);
    lastUsed4MenuItem.setText(getWorkbenchProperty("lastUsed4"));
    lastUsed4MenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            lastUsed4MenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(lastUsed4MenuItem);
    updateLastUsedMenu();
    fileMenu.add(jSeparator1);
    exitMenuItem.setText(getResourceConverter().getString("workbench.menu.exit", "Exit"));
    exitMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            exitMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(exitMenuItem);
    menuBar.add(fileMenu);
    editMenu.setText(getResourceConverter().getString("workbench.menu.edit", "Edit"));
    editMenu.setMnemonic(KeyEvent.VK_E);
    cutMenuItem.setText(getResourceConverter().getString("workbench.menu.cut", "Cut"));
    editMenu.add(cutMenuItem);
    copyMenuItem.setText(getResourceConverter().getString("workbench.menu.copy", "Copy"));
    editMenu.add(copyMenuItem);
    pasteMenuItem.setText(getResourceConverter().getString("workbench.menu.paste", "Paste"));
    editMenu.add(pasteMenuItem);
    editMenu.add(deleteMenuItem);
    menuBar.add(editMenu);
    viewMenu.setText(getResourceConverter().getString("workbench.menu.view", "View"));
    viewMenu.setMnemonic(KeyEvent.VK_V);
    viewXmlMenuItem.setText(getResourceConverter().getString("workbench.menu.viewXML", "View XML"));
    viewXmlMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            viewXMLMenuItemActionPerformed(evt);
        }
    });
    viewMenu.add(viewXmlMenuItem);
    menuBar.add(viewMenu);
    toolsMenu.setText(getResourceConverter().getString("workbench.menu.options", "Options"));
    toolsMenu.setMnemonic(KeyEvent.VK_O);
    preferencesMenuItem.setText(getResourceConverter().getString("workbench.menu.connection", "Connection"));
    preferencesMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            connectionButtonActionPerformed(evt);
        }
    });
    toolsMenu.add(preferencesMenuItem);
    requireSchemaCheckboxMenuItem.setText(getResourceConverter().getString("workbench.menu.requireSchema", "Require Schema"));
    requireSchemaCheckboxMenuItem.setSelected(requireSchema);
    requireSchemaCheckboxMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            requireSchemaActionPerformed(e);
        }
    });
    toolsMenu.add(requireSchemaCheckboxMenuItem);
    menuBar.add(toolsMenu);
    windowMenu.setText(getResourceConverter().getString("workbench.menu.windows", "Windows"));
    windowMenu.setMnemonic(KeyEvent.VK_W);
    cascadeMenuItem = new javax.swing.JMenuItem();
    cascadeMenuItem.setText(getResourceConverter().getString("workbench.menu.cascadeWindows", "Cascade Windows"));
    cascadeMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            cascadeMenuItemActionPerformed(evt);
        }
    });
    tileMenuItem = new javax.swing.JMenuItem();
    tileMenuItem.setText(getResourceConverter().getString("workbench.menu.tileWindows", "Tile Windows"));
    tileMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            tileMenuItemActionPerformed(evt);
        }
    });
    closeAllMenuItem = new javax.swing.JMenuItem();
    closeAllMenuItem.setText(getResourceConverter().getString("workbench.menu.closeAll", "Close All"));
    closeAllMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            closeAllMenuItemActionPerformed(evt);
        }
    });
    minimizeMenuItem = new javax.swing.JMenuItem();
    minimizeMenuItem.setText(getResourceConverter().getString("workbench.menu.minimizeAll", "Minimize All"));
    minimizeMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            minimizeMenuItemActionPerformed(evt);
        }
    });
    maximizeMenuItem = new javax.swing.JMenuItem();
    maximizeMenuItem.setText(getResourceConverter().getString("workbench.menu.maximizeAll", "Maximize All"));
    maximizeMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            maximizeMenuItemActionPerformed(evt);
        }
    });
    menuBar.add(windowMenu);
    aboutMenuItem.setText(getResourceConverter().getString("workbench.menu.about", "About"));
    aboutMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            aboutMenuItemActionPerformed(evt);
        }
    });
    helpMenu.add(aboutMenuItem);
    helpMenu.setText(getResourceConverter().getString("workbench.menu.help", "Help"));
    helpMenu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(helpMenu);
    setJMenuBar(menuBar);
    pack();
}
Example 67
Project: gvtools-master  File: NewSkin.java View source code
/*
	 * @see
	 * com.iver.andami.ui.mdiManager.MDIManager#init(com.iver.andami.ui.mdiFrame
	 * .MDIFrame)
	 */
public void init(MDIFrame f) {
    // Inicializa el Frame y la consola
    mainFrame = f;
    mainFrame.setGlassPane(glassPane);
    panel.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    mainFrame.getContentPane().add(panel, BorderLayout.CENTER);
    panel.setDesktopManager(desktopManager);
    fws = new FrameWindowSupport(mainFrame);
    dss = new DialogStackSupport(mainFrame);
    sws = new SingletonWindowSupport(wis, fws);
    wis = new WindowInfoSupport(mainFrame, fws, sws);
    fws.setVis(wis);
    wss = new WindowStackSupport(wis);
    // TODO (jaume) esto no debería de estar aquí...
    // molaría más en un diálogo de preferencias
    // es sólo una prueba
    KeyStroke controlTab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.CTRL_MASK);
    PluginServices.registerKeyStroke(controlTab, new KeyEventDispatcher() {

        public boolean dispatchKeyEvent(KeyEvent e) {
            IWindow[] views = getAllWindows();
            if (views.length <= 0 || e.getID() == KeyEvent.KEY_PRESSED)
                return false;
            int current = 0;
            for (int i = 0; i < views.length; i++) {
                if (views[i].equals(getActiveWindow())) {
                    current = i;
                    break;
                }
            }
            addWindow(views[(current + 1) % views.length]);
            return true;
        }
    });
}
Example 68
Project: Henshin-Editor-master  File: CriticalPairOptionGUI.java View source code
private JPanel makePairSize() {
    JPanel optionPanel = makeInitialOptionPanel("");
    optionPanel.setBorder(new TitledBorder(" Set initial critical pair window size "));
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    JDesktopPane virtualDesktop = new JDesktopPane();
    this.virtualGraph = new JInternalFrame("Virtual Overlapping Graph", false, false, false, false);
    this.virtualGraph.setVisible(true);
    ImageIcon internalFrameIcon = IconResource.getIconFromURL(IconResource.getURLOverlapGraph());
    this.virtualGraph.setFrameIcon(internalFrameIcon);
    virtualDesktop.add(this.virtualGraph);
    try {
        this.virtualGraph.setSelected(true);
    } catch (java.beans.PropertyVetoException pve) {
    }
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.gridheight = 1;
    c.weighty = 1.0;
    c.weightx = 1.0;
    optionPanel.add(virtualDesktop, c);
    this.verticalSize = new JSlider(SwingConstants.VERTICAL, 80, 500, 200);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.weightx = 0.0;
    this.verticalSize.addChangeListener(this);
    this.verticalSize.setInverted(true);
    optionPanel.add(this.verticalSize, c);
    this.horizontalSize = new JSlider(SwingConstants.HORIZONTAL, 120, 800, 200);
    c.weightx = 1.0;
    c.weighty = 0.0;
    this.horizontalSize.addChangeListener(this);
    optionPanel.add(this.horizontalSize, c);
    this.virtualGraph.setSize(this.horizontalSize.getValue() / 2, this.verticalSize.getValue() / 2);
    optionPanel.add(new JLabel("Scale: 1:2"), c);
    return optionPanel;
}
Example 69
Project: Icy-Kernel-master  File: IcyFrame.java View source code
/**
     * Add the frame to the Icy desktop pane with specified constraint.
     */
public void addToDesktopPane(final Object constraints) {
    // AWT safe
    ThreadUtil.invoke(new Runnable() {

        @Override
        public void run() {
            final JDesktopPane desktop = Icy.getMainInterface().getDesktopPane();
            if (desktop != null)
                desktop.add(internalFrame, constraints);
        }
    }, syncProcess);
}
Example 70
Project: JavaX-master  File: ResourceManager.java View source code
private void initGUI() {
    topPanel = new JPanel();
    BorderLayout panelLayout = new BorderLayout();
    topPanel.setLayout(panelLayout);
    topPanel.setPreferredSize(new java.awt.Dimension(600, 400));
    {
        toolBarPanel = new JPanel();
        topPanel.add(toolBarPanel, BorderLayout.NORTH);
        BorderLayout jPanel1Layout = new BorderLayout();
        toolBarPanel.setLayout(jPanel1Layout);
        {
            CommandBar toolBar = new CommandBar();
            toolBar.setFloatable(true);
            toolBarPanel.add(toolBar, BorderLayout.CENTER);
            //				{
            //					newButton = new JideButton();
            //					toolBar.add(newButton);
            //					newButton.setAction(getAction("newFile"));
            //					newButton.setName("newButton");
            //					newButton.setFocusable(false);
            //				}
            {
                openButton = new JideButton();
                toolBar.add(openButton);
                openButton.setAction(getAction("open"));
                openButton.setName("openButton");
                openButton.setFocusable(false);
            }
            {
                openFolderButton = new JideButton();
                toolBar.add(openFolderButton);
                openFolderButton.setAction(getAction("openFolder"));
                openFolderButton.setName("openFolderButton");
                openFolderButton.setFocusable(false);
            }
            //				{
            //					saveButton = new JideButton();
            //					toolBar.add(saveButton);
            //					saveButton.setAction(getAction("save"));
            //					saveButton.setName("saveButton");
            //					saveButton.setFocusable(false);
            //				}
            {
                toolBar.addSeparator();
            }
            {
                JButton button = new JideButton();
                toolBar.add(button);
                button.setAction(getAction("exitApp"));
                button.setName("exitButton");
                button.setFocusable(false);
            }
        }
        {
            JSeparator jSeparator = new JSeparator();
            toolBarPanel.add(jSeparator, BorderLayout.SOUTH);
        }
    }
    {
        treePanel = new JScrollPane();
        desktop = new JDesktopPane();
        JSplitPane centerPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePanel, desktop);
        centerPane.setDividerLocation(150);
        topPanel.add(centerPane, BorderLayout.CENTER);
    }
    {
        statusBar = new StatusBar();
        topPanel.add(statusBar, BorderLayout.SOUTH);
        final LabelStatusBarItem label = new LabelStatusBarItem("Line");
        label.setText("Resource Manager for JavaXYQ.");
        statusBar.add(label, JideBoxLayout.FLEXIBLE);
        final MemoryStatusBarItem gc = new MemoryStatusBarItem();
        statusBar.add(gc, JideBoxLayout.FIX);
    }
    menuBar = new JMenuBar();
    {
        fileMenu = new JMenu();
        menuBar.add(fileMenu);
        fileMenu.setName("fileMenu");
        //			{
        //				JMenuItem menuItem = new JMenuItem();
        //				fileMenu.add(menuItem);
        //				menuItem.setAction(getAction("newFile"));
        //			}
        {
            JMenuItem menuItem = new JMenuItem();
            fileMenu.add(menuItem);
            menuItem.setAction(getAction("open"));
        }
        {
            JMenuItem menuItem = new JMenuItem();
            fileMenu.add(menuItem);
            menuItem.setAction(getAction("openFolder"));
        }
        //			{
        //				JMenuItem menuItem = new JMenuItem();
        //				fileMenu.add(menuItem);
        //				menuItem.setAction(getAction("save"));
        //			}
        fileMenu.addSeparator();
        {
            JMenuItem menuItem = new JMenuItem();
            fileMenu.add(menuItem);
            menuItem.setAction(getAction("exitApp"));
        }
    }
    {
        editMenu = new JMenu();
        menuBar.add(editMenu);
        editMenu.setName("editMenu");
        {
            JMenuItem menuItem = new JMenuItem();
            editMenu.add(menuItem);
            menuItem.setAction(getAction("copy"));
        }
        {
            JMenuItem menuItem = new JMenuItem();
            editMenu.add(menuItem);
            menuItem.setAction(getAction("cut"));
        }
        {
            JMenuItem menuItem = new JMenuItem();
            editMenu.add(menuItem);
            menuItem.setAction(getAction("paste"));
        }
        {
            JMenuItem menuItem = new JMenuItem();
            editMenu.add(menuItem);
            menuItem.setAction(getAction("delete"));
        }
    }
    {
        windowMenu = new JMenu("Window");
        windowMenu.setName("windowMenu");
        menuBar.add(windowMenu);
        windowMenu.addSeparator();
    }
    {
        helpMenu = new JMenu("Help");
        helpMenu.setName("helpMenu");
        menuBar.add(helpMenu);
        {
            JMenuItem menuItem = new JMenuItem();
            helpMenu.add(menuItem);
            menuItem.setAction(getAction("visitHome"));
        }
        {
            JMenuItem menuItem = new JMenuItem();
            helpMenu.add(menuItem);
            menuItem.setAction(getAction("showHelp"));
        }
        {
            JMenuItem menuItem = new JMenuItem();
            helpMenu.add(menuItem);
            menuItem.setAction(getAction("suggestion"));
        }
        //			{
        //				JMenuItem menuItem = new JMenuItem();
        //				helpMenu.add(menuItem);
        //				menuItem.setAction(getAction("donate"));
        //			}
        {
            JMenuItem menuItem = new JMenuItem();
            helpMenu.add(menuItem);
            menuItem.setAction(getAction("showAbout"));
        }
    }
    JFrame mainFrame = getMainFrame();
    mainFrame.setJMenuBar(menuBar);
    mainFrame.setContentPane(topPanel);
}
Example 71
Project: jspresso-ce-master  File: DefaultSwingController.java View source code
private void createControllerFrame() {
    controllerFrame = new JFrame();
    desktopPane = new JDesktopPane();
    controllerFrame.getContentPane().add(desktopPane, BorderLayout.CENTER);
    statusBar = new JLabel();
    statusBar.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    statusBar.setVisible(false);
    controllerFrame.getContentPane().add(statusBar, BorderLayout.SOUTH);
    controllerFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    controllerFrame.setGlassPane(createHermeticGlassPane());
    controllerFrame.addWindowListener(new WindowAdapter() {

        /**
       * {@inheritDoc}
       */
        @Override
        public void windowClosing(WindowEvent e) {
            execute(getExitAction(), new HashMap<String, Object>());
        }
    });
    controllerFrame.pack();
    int screenRes = Toolkit.getDefaultToolkit().getScreenResolution();
    int w = 12 * screenRes;
    int h = 8 * screenRes;
    if (getFrameWidth() != null) {
        w = getFrameWidth();
    }
    if (getFrameHeight() != null) {
        h = getFrameHeight();
    }
    controllerFrame.setSize(w, h);
    // controllerFrame.setSize(1100, 800);
    ImageIcon frameIcon = ((ImageIcon) getIconFactory().getIcon(getIcon(), getIconFactory().getSmallIconSize()));
    if (frameIcon != null) {
        controllerFrame.setIconImage(frameIcon.getImage());
    }
    SwingUtil.centerOnScreen(controllerFrame);
    updateFrameTitle();
    controllerFrame.setVisible(true);
}
Example 72
Project: jubula.core-master  File: AUTSwingHierarchy.java View source code
/**
     * Returns all descendants of the given <code>component</code>
     * @param c a <code>component</code> value
     * @return a <code>collection</code> of the component's descendants or an
     * empty <code>collection</code> if nothing was found or <code>c</code> is null.
     */
private Collection<Component> getComponents(Component c) {
    if (c instanceof Container) {
        Container cont = (Container) c;
        List<Component> list = new ArrayList<Component>();
        list.addAll(Arrays.asList(cont.getComponents()));
        if (c instanceof JMenu) {
            list.add(((JMenu) c).getPopupMenu());
        } else if (c instanceof Window) {
            list.addAll(Arrays.asList(((Window) c).getOwnedWindows()));
        } else if (c instanceof JDesktopPane) {
            // add iconified frames, which are otherwise unreachable
            // for consistency, they are still considered children of
            // the desktop pane.
            int count = cont.getComponentCount();
            for (int i = 0; i < count; i++) {
                Component child = cont.getComponent(i);
                if (child instanceof JInternalFrame.JDesktopIcon) {
                    JInternalFrame frame = ((JInternalFrame.JDesktopIcon) child).getInternalFrame();
                    if (frame != null) {
                        list.add(frame);
                    }
                }
            }
        }
        return list;
    }
    // an empty ArrayList
    return new ArrayList<Component>();
}
Example 73
Project: Meshia-master  File: SunflowGUI.java View source code
private void initGUI() {
    setTitle("Sunflow v" + SunflowAPI.VERSION);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    {
        desktop = new JDesktopPane();
        getContentPane().add(desktop, BorderLayout.CENTER);
        Dimension screenRes = Toolkit.getDefaultToolkit().getScreenSize();
        if (screenRes.getWidth() <= DEFAULT_WIDTH || screenRes.getHeight() <= DEFAULT_HEIGHT)
            desktop.setPreferredSize(new java.awt.Dimension(640, 480));
        else
            desktop.setPreferredSize(new java.awt.Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT));
        {
            imagePanelFrame = new JInternalFrame();
            desktop.add(imagePanelFrame);
            {
                jPanel1 = new JPanel();
                FlowLayout jPanel1Layout = new FlowLayout();
                jPanel1Layout.setAlignment(FlowLayout.LEFT);
                jPanel1.setLayout(jPanel1Layout);
                imagePanelFrame.getContentPane().add(jPanel1, BorderLayout.NORTH);
                {
                    renderButton = new JButton();
                    jPanel1.add(renderButton);
                    renderButton.setText("Render");
                    renderButton.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent evt) {
                            renderMenuItemActionPerformed(evt);
                        }
                    });
                }
                {
                    iprButton = new JButton();
                    jPanel1.add(iprButton);
                    iprButton.setText("IPR");
                    iprButton.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent evt) {
                            iprMenuItemActionPerformed(evt);
                        }
                    });
                }
            }
            {
                imagePanel = new ImagePanel();
                imagePanelFrame.getContentPane().add(imagePanel, BorderLayout.CENTER);
            }
            imagePanelFrame.pack();
            imagePanelFrame.setResizable(true);
            imagePanelFrame.setMaximizable(true);
            imagePanelFrame.setVisible(true);
            imagePanelFrame.setTitle("Image");
            imagePanelFrame.setIconifiable(true);
        }
        {
            editorFrame = new JInternalFrame();
            desktop.add(editorFrame);
            editorFrame.setTitle("Script Editor");
            editorFrame.setMaximizable(true);
            editorFrame.setResizable(true);
            editorFrame.setIconifiable(true);
            {
                jScrollPane1 = new JScrollPane();
                editorFrame.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
                jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
                jScrollPane1.setPreferredSize(new java.awt.Dimension(360, 280));
                {
                    editorTextArea = new JTextArea();
                    jScrollPane1.setViewportView(editorTextArea);
                    editorTextArea.setFont(new java.awt.Font("Monospaced", 0, 12));
                    // drag and drop
                    editorTextArea.setTransferHandler(new SceneTransferHandler());
                }
            }
            {
                jPanel3 = new JPanel();
                editorFrame.getContentPane().add(jPanel3, BorderLayout.SOUTH);
                FlowLayout jPanel3Layout = new FlowLayout();
                jPanel3Layout.setAlignment(FlowLayout.RIGHT);
                jPanel3.setLayout(jPanel3Layout);
                {
                    buildButton = new JButton();
                    jPanel3.add(buildButton);
                    buildButton.setText("Build Scene");
                    buildButton.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent evt) {
                            buildMenuItemActionPerformed(evt);
                        }
                    });
                }
            }
            editorFrame.pack();
            editorFrame.setVisible(true);
        }
        {
            consoleFrame = new JInternalFrame();
            desktop.add(consoleFrame);
            consoleFrame.setIconifiable(true);
            consoleFrame.setMaximizable(true);
            consoleFrame.setResizable(true);
            consoleFrame.setTitle("Console");
            {
                jScrollPane2 = new JScrollPane();
                consoleFrame.getContentPane().add(jScrollPane2, BorderLayout.CENTER);
                jScrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
                jScrollPane2.setPreferredSize(new java.awt.Dimension(360, 100));
                {
                    consoleTextArea = new JTextArea();
                    jScrollPane2.setViewportView(consoleTextArea);
                    consoleTextArea.setFont(new java.awt.Font("Monospaced", 0, 12));
                    consoleTextArea.setEditable(false);
                }
            }
            {
                jPanel4 = new JPanel();
                consoleFrame.getContentPane().add(jPanel4, BorderLayout.SOUTH);
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                {
                    jPanel6 = new JPanel();
                    BorderLayout jPanel6Layout = new BorderLayout();
                    jPanel6.setLayout(jPanel6Layout);
                    jPanel4.add(jPanel6, BorderLayout.CENTER);
                    jPanel6.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0));
                    {
                        taskProgressBar = new JProgressBar();
                        jPanel6.add(taskProgressBar);
                        taskProgressBar.setEnabled(false);
                        taskProgressBar.setString("");
                        taskProgressBar.setStringPainted(true);
                        taskProgressBar.setOpaque(false);
                    }
                }
                {
                    jPanel5 = new JPanel();
                    FlowLayout jPanel5Layout = new FlowLayout();
                    jPanel5Layout.setAlignment(FlowLayout.RIGHT);
                    jPanel5.setLayout(jPanel5Layout);
                    jPanel4.add(jPanel5, BorderLayout.EAST);
                    {
                        taskCancelButton = new JButton();
                        jPanel5.add(taskCancelButton);
                        taskCancelButton.setText("Cancel");
                        taskCancelButton.setEnabled(false);
                        taskCancelButton.addActionListener(new ActionListener() {

                            public void actionPerformed(ActionEvent evt) {
                                UI.taskCancel();
                            }
                        });
                    }
                    {
                        clearConsoleButton = new JButton();
                        jPanel5.add(clearConsoleButton);
                        clearConsoleButton.setText("Clear");
                        clearConsoleButton.addActionListener(new ActionListener() {

                            public void actionPerformed(ActionEvent evt) {
                                clearConsole();
                            }
                        });
                    }
                }
            }
            consoleFrame.pack();
            consoleFrame.setVisible(true);
        }
    }
    {
        jMenuBar1 = new JMenuBar();
        setJMenuBar(jMenuBar1);
        {
            fileMenu = new JMenu();
            jMenuBar1.add(fileMenu);
            fileMenu.setText("File");
            {
                newFileMenuItem = new JMenuItem();
                fileMenu.add(newFileMenuItem);
                newFileMenuItem.setText("New");
                newFileMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl N"));
                newFileMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        newFileMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                openFileMenuItem = new JMenuItem();
                fileMenu.add(openFileMenuItem);
                openFileMenuItem.setText("Open ...");
                openFileMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl O"));
                openFileMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        openFileMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                saveMenuItem = new JMenuItem();
                fileMenu.add(saveMenuItem);
                saveMenuItem.setText("Save");
                saveMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl S"));
                saveMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        saveCurrentFile(currentFile);
                    }
                });
            }
            {
                saveAsMenuItem = new JMenuItem();
                fileMenu.add(saveAsMenuItem);
                saveAsMenuItem.setText("Save As ...");
                saveAsMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        saveAsMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                jSeparator2 = new JSeparator();
                fileMenu.add(jSeparator2);
            }
            {
                exitMenuItem = new JMenuItem();
                fileMenu.add(exitMenuItem);
                exitMenuItem.setText("Exit");
                exitMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        System.exit(0);
                    }
                });
            }
        }
        {
            sceneMenu = new JMenu();
            jMenuBar1.add(sceneMenu);
            sceneMenu.setText("Scene");
            {
                buildMenuItem = new JMenuItem();
                sceneMenu.add(buildMenuItem);
                buildMenuItem.setText("Build");
                buildMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl B"));
                buildMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        if (sceneMenu.isEnabled())
                            buildMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                autoBuildMenuItem = new JCheckBoxMenuItem();
                sceneMenu.add(autoBuildMenuItem);
                autoBuildMenuItem.setText("Build on open");
                autoBuildMenuItem.setSelected(true);
            }
            {
                jSeparator3 = new JSeparator();
                sceneMenu.add(jSeparator3);
            }
            {
                renderMenuItem = new JMenuItem();
                sceneMenu.add(renderMenuItem);
                renderMenuItem.setText("Render");
                renderMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        renderMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                iprMenuItem = new JMenuItem();
                sceneMenu.add(iprMenuItem);
                iprMenuItem.setText("IPR");
                iprMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        iprMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                clearLogMenuItem = new JCheckBoxMenuItem();
                sceneMenu.add(clearLogMenuItem);
                clearLogMenuItem.setText("Auto Clear Log");
                clearLogMenuItem.setToolTipText("Clears the console before building or rendering");
                clearLogMenuItem.setSelected(true);
            }
            {
                jSeparator4 = new JSeparator();
                sceneMenu.add(jSeparator4);
            }
            {
                textureCacheClearMenuItem = new JMenuItem();
                sceneMenu.add(textureCacheClearMenuItem);
                textureCacheClearMenuItem.setText("Clear Texture Cache");
                textureCacheClearMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        textureCacheClearMenuItemActionPerformed(evt);
                    }
                });
            }
            {
                smallTrianglesMenuItem = new JCheckBoxMenuItem();
                sceneMenu.add(smallTrianglesMenuItem);
                smallTrianglesMenuItem.setText("Low Mem Triangles");
                smallTrianglesMenuItem.setToolTipText("Load future meshes using a low memory footprint triangle representation");
                smallTrianglesMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        smallTrianglesMenuItemActionPerformed(evt);
                    }
                });
            }
        }
        {
            imageMenu = new JMenu();
            jMenuBar1.add(imageMenu);
            imageMenu.setText("Image");
            {
                resetZoomMenuItem = new JMenuItem();
                imageMenu.add(resetZoomMenuItem);
                resetZoomMenuItem.setText("Reset Zoom");
                resetZoomMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        imagePanel.reset();
                    }
                });
            }
            {
                fitWindowMenuItem = new JMenuItem();
                imageMenu.add(fitWindowMenuItem);
                fitWindowMenuItem.setText("Fit to Window");
                fitWindowMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        imagePanel.fit();
                    }
                });
            }
            {
                jSeparator1 = new JSeparator();
                imageMenu.add(jSeparator1);
            }
            {
                jMenuItem4 = new JMenuItem();
                imageMenu.add(jMenuItem4);
                jMenuItem4.setText("Save Image ...");
                jMenuItem4.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        // imagePanel.image;
                        JFileChooser fc = new JFileChooser(".");
                        fc.setFileFilter(new FileFilter() {

                            @Override
                            public String getDescription() {
                                return "Image File";
                            }

                            @Override
                            public boolean accept(File f) {
                                return (f.isDirectory() || f.getName().endsWith(".png") || f.getName().endsWith(".tga"));
                            }
                        });
                        if (fc.showSaveDialog(SunflowGUI.this) == JFileChooser.APPROVE_OPTION) {
                            String filename = fc.getSelectedFile().getAbsolutePath();
                            imagePanel.save(filename);
                        }
                    }
                });
            }
        }
        {
            windowMenu = new JMenu();
            jMenuBar1.add(windowMenu);
            windowMenu.setText("Window");
        }
        {
            imageWindowMenuItem = new JMenuItem();
            windowMenu.add(imageWindowMenuItem);
            imageWindowMenuItem.setText("Image");
            imageWindowMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl 1"));
            imageWindowMenuItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    selectFrame(imagePanelFrame);
                }
            });
        }
        {
            editorWindowMenuItem = new JMenuItem();
            windowMenu.add(editorWindowMenuItem);
            editorWindowMenuItem.setText("Script Editor");
            editorWindowMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl 2"));
            editorWindowMenuItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    selectFrame(editorFrame);
                }
            });
        }
        {
            consoleWindowMenuItem = new JMenuItem();
            windowMenu.add(consoleWindowMenuItem);
            consoleWindowMenuItem.setText("Console");
            consoleWindowMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl 3"));
            consoleWindowMenuItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    selectFrame(consoleFrame);
                }
            });
        }
        {
            jSeparator5 = new JSeparator();
            windowMenu.add(jSeparator5);
        }
        {
            tileWindowMenuItem = new JMenuItem();
            windowMenu.add(tileWindowMenuItem);
            tileWindowMenuItem.setText("Tile");
            tileWindowMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl T"));
            tileWindowMenuItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    tileWindowMenuItemActionPerformed(evt);
                }
            });
        }
    }
}
Example 74
Project: nmedit-master  File: Modules.java View source code
public void rearangeModules(JDesktopPane desktopPane, Module module, boolean bPoly) {
    Module tempMod, tempMod2 = null;
    Vector modVector = new Vector();
    //		Nu alleen voor 1 geplaatste module
    for (int i = 0; i < desktopPane.getComponentCountInLayer(JLayeredPane.DEFAULT_LAYER.intValue()); i++) {
        // Zoek alle module in de zelfde colom
        tempMod = ((Module) desktopPane.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER.intValue())[i]);
        if (module.getModuleData().getGridX() == tempMod.getModuleData().getGridX()) {
            // We gaan net zolang null inserten todat we de Vector hebben gevult tot Verctor.size() == getGridY
            while (modVector.size() <= tempMod.getModuleData().getGridY()) modVector.add(null);
            if (modVector.get(tempMod.getModuleData().getGridY()) == null)
                modVector.set(tempMod.getModuleData().getGridY(), tempMod);
            else
                modVector.insertElementAt(tempMod, tempMod.getModuleData().getGridY());
        }
    }
    // Haal alle lege plaatsen uit de Vector (leuke oplossing eej!?)
    while (modVector.remove(null)) ;
    for (int j = 0; j < modVector.size() - 1; j++) {
        tempMod = (Module) modVector.get(j);
        tempMod2 = (Module) modVector.get(j + 1);
        if (tempMod2.getModuleData().getGridY() < (tempMod.getModuleData().getGridY() + tempMod.getModuleData().getGridHeight())) {
            module.setPixLocation(tempMod2, tempMod.getModuleData().getPixLocationX(), tempMod.getModuleData().getPixLocationY() + tempMod.getModuleData().getPixHeight());
        }
    }
    getCables().redrawCables(this, bPoly);
}
Example 75
Project: swingx-master  File: JTableIssues.java View source code
//----------------------- interactive
/**
     * Issue #1489-swingx: terminateEditOnFocusLost leads to unexpected focus behaviour 
     * in internalFrame.
     * 
     * This is a core-issue which shows up in SwingX because JxTable has the property
     * set to true by default, while core has not.
     * 
     */
public void interactiveInternalFrameTerminateEditOnFocusLost() {
    JDesktopPane jDesktopPane = new JDesktopPane();
    JInternalFrame jInternalFrame = new JInternalFrame();
    jDesktopPane.add(jInternalFrame);
    jInternalFrame.getContentPane().add(createPanel(true));
    JXFrame embddingFrame = wrapInFrame(jDesktopPane, "");
    try {
        jInternalFrame.setMaximum(true);
    } catch (PropertyVetoException ex) {
    }
    jInternalFrame.setVisible(true);
    show(embddingFrame, 400, 400);
    PropertyChangeListener pcl = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            Object oldValue = evt.getOldValue();
            Object newValue = evt.getNewValue();
            if (newValue == null || !JFrame.class.equals(newValue.getClass())) {
                int i = 1;
            }
            System.out.println(evt.getPropertyName() + " from " + (oldValue == null ? null : oldValue.getClass().getCanonicalName() + oldValue.hashCode()) + " to " + (newValue == null ? null : newValue.getClass().getCanonicalName() + newValue.hashCode()));
        }
    };
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener("permanentFocusOwner", pcl);
}
Example 76
Project: acs-master  File: CommandCenterGui.java View source code
public void prepare() {
    boolean setLookAndFeel = false;
    if (setLookAndFeel) {
        String lafName = UIManager.getSystemLookAndFeelClassName();
        try {
            UIManager.setLookAndFeel(lafName);
        } catch (Exception exc) {
            log.fine("Couldn't set look and feel " + lafName + " due to " + exc);
        }
    }
    // title added later in doFrameTitle()
    frame = new JFrame("");
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            controller.stop();
        }
    });
    dlgContainerSettings = new EditContainerSettingsDialog(this);
    frontPanel = new TabPanel(this);
    writeModelToFrontPanel();
    // Splitter between tree and the rest
    splitLeftRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitLeftRight.setOneTouchExpandable(true);
    JPanel p2 = new JPanel(new BorderLayout());
    p2.setBorder(new EmptyBorder(10, 10, 10, 10));
    p2.add(frontPanel, BorderLayout.NORTH);
    splitLeftRight.setLeftComponent(p2);
    // Deployment Tree
    deploymentInfoPanel = new JPanel(new BorderLayout());
    deploymentInfoPanel.setBorder(new CompoundBorder(new EmptyBorder(5, 7, 5, 7), new TitledBorder(LineBorder.createBlackLineBorder(), " Deployment Info ")));
    deployTree = new DeploymentTree(controller.deploymentTreeControllerImpl);
    JPanel addToDeployTree = new AddToDeployTree(this, deployTree);
    deploymentInfoPanel.add(addToDeployTree, BorderLayout.NORTH);
    deploymentInfoPanel.add(new JScrollPane(deployTree), BorderLayout.CENTER);
    splitLeftRight.setRightComponent(deploymentInfoPanel);
    // Feedback Area
    feedbackTabs = new FeedbackTabs(this, FeedbackTabs.BOTTOM);
    // Logo Panel
    JPanel logoPanel = new LogoPanel(COLOR_LogoBackground_A, COLOR_LogoBackground_B);
    logoPanel.setLayout(new BorderLayout());
    JLabel alma = new JLabel(new ImageIcon(controller.findResource("alma.jpg")));
    logoPanel.add(alma, BorderLayout.WEST);
    JLabel text = new JLabel("Acs Command Center");
    text.setForeground(COLOR_LogoForeground);
    text.setHorizontalTextPosition(SwingConstants.CENTER);
    text.setFont(text.getFont().deriveFont((float) (text.getFont().getSize() * 2.5)));
    text.setBorder(new EmptyBorder(5, 30, 5, 30));
    logoPanel.add(text, BorderLayout.CENTER);
    //		JLabel version = new JLabel(controller.version());
    //		version.setForeground(COLOR_LogoForeground);
    //		version.setBorder(new EmptyBorder(0, 0, 0, 4));
    //		JPanel pnl2 = new JPanel(new BorderLayout());
    //		pnl2.setOpaque(false);
    //		pnl2.add(version, BorderLayout.SOUTH);
    //		logoPanel.add(pnl2, BorderLayout.EAST);
    menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("Project");
    fileMenu.setMnemonic(KeyEvent.VK_P);
    {
        JMenu newMenu = new JMenu("New");
        newMenu.add(new ActionNewProject("Project"));
        fileMenu.add(newMenu);
    }
    fileMenu.add(new ActionOpenProject("Open..."));
    fileMenu.add(new ActionSaveProject("Save"));
    fileMenu.add(new ActionSaveAsProject("Save As..."));
    fileMenu.addSeparator();
    fileMenu.add(new ActionExit("Exit"));
    menuBar.add(fileMenu);
    toolsMenu = new JMenu("Tools");
    toolsMenu.setMnemonic(KeyEvent.VK_T);
    toolsMenu.add(new ActionConfigureTools("Configure Tools..."));
    toolsMenu.addSeparator();
    menuBar.add(toolsMenu);
    // ---
    JMenu extrasMenu = new JMenu("Expert");
    extrasMenu.setMnemonic(KeyEvent.VK_E);
    {
        //				JMenu sshMode = new JMenu("SSH Library");
        //				sshMode.add(new ActionSetSshMode("Platform-independent", false, false));
        //				sshMode.add(new ActionSetSshMode("Natively installed ssh", true, true));
        //				extrasMenu.add(sshMode);
        //				extrasMenu.add(new JSeparator());
        JMenu extraTools = new JMenu("Tools Menu");
        extraTools.add(new ActionShowExtraTools("View..."));
        extraTools.add(new ActionInstallExtraTools("Replace..."));
        extrasMenu.add(extraTools);
        JMenu builtinTools = new JMenu("Acs Scripts");
        builtinTools.add(new ActionShowBuiltinTools("View..."));
        builtinTools.add(new ActionLoadBuiltinTools("Replace..."));
        extrasMenu.add(builtinTools);
    }
    extrasMenu.add(new JSeparator());
    extrasMenu.add(new ActionShowVariables("Variables..."));
    menuBar.add(extrasMenu);
    // ---
    JMenuItem item;
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic(KeyEvent.VK_H);
    item = helpMenu.add(new ActionShowHelp("Online Help"));
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    item = helpMenu.add(new ActionShowAbout("About"));
    menuBar.add(Box.createHorizontalGlue());
    menuBar.add(helpMenu);
    // ---
    JPanel h = new JPanel(new SpringLayout());
    h.add(logoPanel);
    h.add(menuBar);
    SpringUtilities.makeCompactGrid(h, 0, 1);
    frame.getContentPane().add(h, BorderLayout.NORTH);
    // ---
    pnlManagerLocationForTools = new ManagerLocationPanel.ForTools();
    managerLocationDialog1 = new BasicDialog(this, "Specify Manager and Services for Tools", "Set", pnlManagerLocationForTools);
    // ---
    pnlManagerLocationForContainers = new ManagerLocationPanel.ForContainers();
    managerLocationDialog2 = new BasicDialog(this, "Specify Manager and Services for Containers", "Set", pnlManagerLocationForContainers);
    // ---
    splitTopBottom = new JSplitPane(JSplitPane.VERTICAL_SPLIT, splitLeftRight, feedbackTabs);
    splitTopBottom.setOneTouchExpandable(true);
    // --- 
    // 2009-04: Introducing a desktop layout so i can make the
    // progress dialog a lightweight window on top the front panel
    AccInternalFrame bigInternalFrame = new AccInternalFrame();
    bigInternalFrame.add(splitTopBottom);
    desktop = new JDesktopPane();
    bigInternalFrame.setVisible(true);
    desktop.add(bigInternalFrame);
    frame.getContentPane().add(desktop, BorderLayout.CENTER);
    try {
        bigInternalFrame.setSelected(true);
        bigInternalFrame.setMaximum(true);
    } catch (PropertyVetoException exc) {
    }
    // for mysterious swing reasons, the desktop has a preferred size
    // of (1,1) instead of picking up the preferred size of its child
    // component, so i'm doing this manually here.
    desktop.setPreferredSize(bigInternalFrame.getPreferredSize());
    doFrameTitle();
}
Example 77
Project: AIWekaProject-master  File: Main.java View source code
/**
   * initializes the GUI.
   */
protected void initGUI() {
    m_Self = this;
    try {
        // main window
        createTitle("");
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("weka/gui/weka_icon.gif")).getImage());
        // bits and pieces
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".bif", "BIF Files (*.bif)"));
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".xml", "XML Files (*.xml)"));
        m_FileChooserPlot.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        m_FileChooserPlot.setMultiSelectionEnabled(true);
        m_FileChooserROC.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        // Desktop
        if (m_GUIType == GUI_MDI) {
            jDesktopPane = new BackgroundDesktopPane("weka/gui/images/weka_background.gif");
            jDesktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
            setContentPane(jDesktopPane);
        } else {
            jDesktopPane = null;
        }
        // Menu
        jMenuBar = new JMenuBar();
        setJMenuBar(jMenuBar);
        // Program
        jMenuProgram = new JMenu();
        jMenuBar.add(jMenuProgram);
        jMenuProgram.setText("Program");
        jMenuProgram.setMnemonic('P');
        // Program/Preferences
        // TODO: read all properties from all props file and display them
        /*
        jMenuItemProgramPreferences = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramPreferences);
        jMenuItemProgramPreferences.setText("Preferences");
        jMenuItemProgramPreferences.setMnemonic('P');
        jMenuItemProgramPreferences.addActionListener(new ActionListener() {
  	  public void actionPerformed(ActionEvent evt) {
	    System.out.println("jMenuItemProgramPreferences.actionPerformed, event="+evt);
	    //TODO add your code for jMenuItemProgramPreferences.actionPerformed
  	  }
        });
       */
        // Program/LogWindow
        jMenuItemProgramLogWindow = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramLogWindow);
        jMenuItemProgramLogWindow.setText("LogWindow");
        jMenuItemProgramLogWindow.setMnemonic('L');
        jMenuItemProgramLogWindow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                m_LogWindow.setVisible(true);
            }
        });
        jMenuItemProgramMemoryUsage = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramMemoryUsage);
        jMenuItemProgramMemoryUsage.setText("Memory usage");
        jMenuItemProgramMemoryUsage.setMnemonic('M');
        jMenuItemProgramMemoryUsage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemProgramMemoryUsage.getText();
                if (!containsWindow(title)) {
                    final MemoryUsagePanel panel = new MemoryUsagePanel();
                    Container c = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 400, 50, null, true, true);
                    // optimize size
                    Dimension size = c.getPreferredSize();
                    c.setSize(new Dimension((int) size.getWidth(), (int) size.getHeight()));
                    // stop threads
                    if (m_GUIType == GUI_MDI) {
                        final ChildFrameMDI frame = (ChildFrameMDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    } else {
                        final ChildFrameSDI frame = (ChildFrameSDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuProgram.add(new JSeparator());
        // Program/Exit
        jMenuItemProgramExit = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramExit);
        jMenuItemProgramExit.setText("Exit");
        jMenuItemProgramExit.setMnemonic('E');
        jMenuItemProgramExit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // close all children
                Iterator iter = getWindowList();
                Vector<Container> list = new Vector<Container>();
                while (iter.hasNext()) list.add((Container) 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);
            }
        });
        // Applications
        jMenuApplications = new JMenu();
        jMenuBar.add(jMenuApplications);
        jMenuApplications.setText("Applications");
        jMenuApplications.setMnemonic('A');
        // Applications/Explorer
        jMenuItemApplicationsExplorer = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExplorer);
        jMenuItemApplicationsExplorer.setText("Explorer");
        jMenuItemApplicationsExplorer.setMnemonic('E');
        jMenuItemApplicationsExplorer.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/Experimenter
        jMenuItemApplicationsExperimenter = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExperimenter);
        jMenuItemApplicationsExperimenter.setText("Experimenter");
        jMenuItemApplicationsExperimenter.setMnemonic('X');
        jMenuItemApplicationsExperimenter.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/KnowledgeFlow
        jMenuItemApplicationsKnowledgeFlow = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsKnowledgeFlow);
        jMenuItemApplicationsKnowledgeFlow.setText("KnowledgeFlow");
        jMenuItemApplicationsKnowledgeFlow.setMnemonic('K');
        jMenuItemApplicationsKnowledgeFlow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsKnowledgeFlow.getText();
                if (!containsWindow(title)) {
                    KnowledgeFlowApp.createSingleton(new String[0]);
                    createFrame(m_Self, title, KnowledgeFlowApp.getSingleton(), new BorderLayout(), BorderLayout.CENTER, 900, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Applications/SimpleCLI
        jMenuItemApplicationsSimpleCLI = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsSimpleCLI);
        jMenuItemApplicationsSimpleCLI.setText("SimpleCLI");
        jMenuItemApplicationsSimpleCLI.setMnemonic('S');
        jMenuItemApplicationsSimpleCLI.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsSimpleCLI.getText();
                if (!containsWindow(title)) {
                    try {
                        createFrame(m_Self, title, new SimpleCLIPanel(), new BorderLayout(), BorderLayout.CENTER, 600, 500, null, true, true);
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error instantiating SimpleCLI:\n" + e.getMessage());
                        return;
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools
        jMenuTools = new JMenu();
        jMenuBar.add(jMenuTools);
        jMenuTools.setText("Tools");
        jMenuTools.setMnemonic('T');
        // Tools/ArffViewer
        jMenuItemToolsArffViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsArffViewer);
        jMenuItemToolsArffViewer.setText("ArffViewer");
        jMenuItemToolsArffViewer.setMnemonic('A');
        jMenuItemToolsArffViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsArffViewer.getText();
                if (!containsWindow(title)) {
                    ArffViewerMainPanel panel = new ArffViewerMainPanel(null);
                    panel.setConfirmExit(false);
                    Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenu(), true, true);
                    panel.setParent(frame);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/SqlViewer
        jMenuItemToolsSqlViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsSqlViewer);
        jMenuItemToolsSqlViewer.setText("SqlViewer");
        jMenuItemToolsSqlViewer.setMnemonic('S');
        jMenuItemToolsSqlViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsSqlViewer.getText();
                if (!containsWindow(title)) {
                    final SqlViewer sql = new SqlViewer(null);
                    final Container frame = createFrame(m_Self, title, sql, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, false, true);
                    // custom listener
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                sql.saveSize();
                                ((ChildFrameMDI) frame).dispose();
                            }
                        });
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                sql.saveSize();
                                ((ChildFrameSDI) frame).dispose();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/Bayes net editor
        // Tools/Bayes net editor
        final JMenuItem jMenuItemBayesNet = new JMenuItem();
        jMenuTools.add(jMenuItemBayesNet);
        jMenuItemBayesNet.setText("Bayes net editor");
        jMenuItemBayesNet.setMnemonic('N');
        jMenuItemBayesNet.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                String title = jMenuItemBayesNet.getText();
                if (!containsWindow(title)) {
                    final GUI bayesNetGUI = new GUI();
                    final Container frame = createFrame(m_Self, title, bayesNetGUI, new BorderLayout(), BorderLayout.CENTER, 800, 600, bayesNetGUI.getMenuBar(), false, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/EnsembleLibrary
        /* currently disabled due to bugs... FracPete
      jMenuItemToolsEnsembleLibrary = new JMenuItem();
      jMenuTools.add(jMenuItemToolsEnsembleLibrary);
      jMenuItemToolsEnsembleLibrary.setText("EnsembleLibrary");
      jMenuItemToolsEnsembleLibrary.setMnemonic('E');
      jMenuItemToolsEnsembleLibrary.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  String title = jMenuItemToolsEnsembleLibrary.getText();
	  if (!containsWindow(title)) {
	    EnsembleLibrary value = new EnsembleLibrary();
	    EnsembleLibraryEditor libraryEditor = new EnsembleLibraryEditor();
	    libraryEditor.setValue(value);
	    createFrame(
		m_Self, title, libraryEditor.getCustomEditor(), new BorderLayout(), 
		BorderLayout.CENTER, 800, 600, null, true, true);
	  }
	  else {
	    showWindow(getWindow(title));
	  }
	}
      });
      */
        // Visualization
        jMenuVisualization = new JMenu();
        jMenuBar.add(jMenuVisualization);
        jMenuVisualization.setText("Visualization");
        jMenuVisualization.setMnemonic('V');
        // Visualization/Plot
        jMenuItemVisualizationPlot = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationPlot);
        jMenuItemVisualizationPlot.setText("Plot");
        jMenuItemVisualizationPlot.setMnemonic('P');
        jMenuItemVisualizationPlot.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserPlot.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build plot
                VisualizePanel panel = new VisualizePanel();
                String filenames = "";
                File[] files = m_FileChooserPlot.getSelectedFiles();
                for (int j = 0; j < files.length; j++) {
                    String filename = files[j].getAbsolutePath();
                    if (j > 0)
                        filenames += ", ";
                    filenames += filename;
                    System.err.println("Loading instances from " + filename);
                    try {
                        Reader r = new java.io.BufferedReader(new FileReader(filename));
                        Instances i = new Instances(r);
                        i.setClassIndex(i.numAttributes() - 1);
                        PlotData2D pd1 = new PlotData2D(i);
                        if (j == 0) {
                            pd1.setPlotName("Master plot");
                            panel.setMasterPlot(pd1);
                        } else {
                            pd1.setPlotName("Plot " + (j + 1));
                            pd1.m_useCustomColour = true;
                            pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
                            panel.addPlot(pd1);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error loading file '" + files[j] + "':\n" + e.getMessage());
                        return;
                    }
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationPlot.getText() + " - " + filenames, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/ROC
        // based on this Wiki article:
        // http://weka.sourceforge.net/wiki/index.php/Visualizing_ROC_curve
        jMenuItemVisualizationROC = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationROC);
        jMenuItemVisualizationROC.setText("ROC");
        jMenuItemVisualizationROC.setMnemonic('R');
        jMenuItemVisualizationROC.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserROC.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // create plot
                String filename = m_FileChooserROC.getSelectedFile().getAbsolutePath();
                Instances result = null;
                try {
                    result = new Instances(new BufferedReader(new FileReader(filename)));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                result.setClassIndex(result.numAttributes() - 1);
                ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
                vmc.setROCString("(Area under ROC = " + Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
                vmc.setName(result.relationName());
                PlotData2D tempd = new PlotData2D(result);
                tempd.setPlotName(result.relationName());
                tempd.addInstanceNumberAttribute();
                try {
                    vmc.addPlot(tempd);
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error adding plot:\n" + e.getMessage());
                    return;
                }
                createFrame(m_Self, jMenuItemVisualizationROC.getText() + " - " + filename, vmc, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/TreeVisualizer
        jMenuItemVisualizationTreeVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationTreeVisualizer);
        jMenuItemVisualizationTreeVisualizer.setText("TreeVisualizer");
        jMenuItemVisualizationTreeVisualizer.setMnemonic('T');
        jMenuItemVisualizationTreeVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserTreeVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build tree
                String filename = m_FileChooserTreeVisualizer.getSelectedFile().getAbsolutePath();
                TreeBuild builder = new TreeBuild();
                Node top = null;
                NodePlace arrange = new PlaceNode2();
                try {
                    top = builder.create(new FileReader(filename));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationTreeVisualizer.getText() + " - " + filename, new TreeVisualizer(null, top, arrange), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/GraphVisualizer
        jMenuItemVisualizationGraphVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationGraphVisualizer);
        jMenuItemVisualizationGraphVisualizer.setText("GraphVisualizer");
        jMenuItemVisualizationGraphVisualizer.setMnemonic('G');
        jMenuItemVisualizationGraphVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserGraphVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build graph
                String filename = m_FileChooserGraphVisualizer.getSelectedFile().getAbsolutePath();
                GraphVisualizer panel = new GraphVisualizer();
                try {
                    if (filename.toLowerCase().endsWith(".xml") || filename.toLowerCase().endsWith(".bif")) {
                        panel.readBIF(new FileInputStream(filename));
                    } else {
                        panel.readDOT(new FileReader(filename));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationGraphVisualizer.getText() + " - " + filename, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/BoundaryVisualizer
        jMenuItemVisualizationBoundaryVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationBoundaryVisualizer);
        jMenuItemVisualizationBoundaryVisualizer.setText("BoundaryVisualizer");
        jMenuItemVisualizationBoundaryVisualizer.setMnemonic('B');
        jMenuItemVisualizationBoundaryVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemVisualizationBoundaryVisualizer.getText();
                if (!containsWindow(title)) {
                    createFrame(m_Self, title, new BoundaryVisualizer(), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                    // dont' do a System.exit after last window got closed!
                    BoundaryVisualizer.setExitIfNoWindowsOpen(false);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Extensions
        jMenuExtensions = new JMenu("Extensions");
        jMenuExtensions.setMnemonic(java.awt.event.KeyEvent.VK_E);
        jMenuBar.add(jMenuExtensions);
        jMenuExtensions.setVisible(false);
        String extensions = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "");
        if (extensions.length() > 0) {
            jMenuExtensions.setVisible(true);
            String[] classnames = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "").split(",");
            Hashtable<String, JMenu> submenus = new Hashtable<String, JMenu>();
            // add all extensions
            for (int i = 0; i < classnames.length; i++) {
                String classname = classnames[i];
                try {
                    MainMenuExtension ext = (MainMenuExtension) Class.forName(classname).newInstance();
                    // menuitem in a submenu?
                    JMenu submenu = null;
                    if (ext.getSubmenuTitle() != null) {
                        submenu = submenus.get(ext.getSubmenuTitle());
                        if (submenu == null) {
                            submenu = new JMenu(ext.getSubmenuTitle());
                            submenus.put(ext.getSubmenuTitle(), submenu);
                            insertMenuItem(jMenuExtensions, submenu);
                        }
                    }
                    // create menu item
                    JMenuItem menuitem = new JMenuItem();
                    menuitem.setText(ext.getMenuTitle());
                    // does the extension need a frame or does it have its own ActionListener?
                    ActionListener listener = ext.getActionListener(m_Self);
                    if (listener != null) {
                        menuitem.addActionListener(listener);
                    } else {
                        final JMenuItem finalMenuitem = menuitem;
                        final MainMenuExtension finalExt = ext;
                        menuitem.addActionListener(new ActionListener() {

                            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);
                            }
                        });
                    }
                    // sorted insert of menu item
                    if (submenu != null)
                        insertMenuItem(submenu, menuitem);
                    else
                        insertMenuItem(jMenuExtensions, menuitem);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        // Windows
        jMenuWindows = new JMenu("Windows");
        jMenuWindows.setMnemonic(java.awt.event.KeyEvent.VK_W);
        jMenuBar.add(jMenuWindows);
        // initially, there are no windows open
        jMenuWindows.setVisible(false);
        // Help
        jMenuHelp = new JMenu();
        jMenuBar.add(jMenuHelp);
        jMenuHelp.setText("Help");
        jMenuHelp.setMnemonic('H');
        // Help/Homepage
        jMenuItemHelpHomepage = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpHomepage);
        jMenuItemHelpHomepage.setText("Weka homepage");
        jMenuItemHelpHomepage.setMnemonic('H');
        jMenuItemHelpHomepage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://www.cs.waikato.ac.nz/~ml/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        /*      // Help/WekaDoc
      jMenuItemHelpWekaDoc = new JMenuItem();
      jMenuHelp.add(jMenuItemHelpWekaDoc);
      jMenuItemHelpWekaDoc.setText("Online documentation");
      jMenuItemHelpWekaDoc.setMnemonic('D');
      jMenuItemHelpWekaDoc.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  BrowserHelper.openURL(m_Self, "http://weka.sourceforge.net/wekadoc/");
	}
      }); */
        // Help/WekaWiki
        jMenuItemHelpWekaWiki = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpWekaWiki);
        jMenuItemHelpWekaWiki.setText("HOWTOs, code snippets, etc.");
        jMenuItemHelpWekaWiki.setMnemonic('W');
        jMenuItemHelpWekaWiki.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://weka.wikispaces.com/");
            }
        });
        // Help/Sourceforge
        jMenuItemHelpSourceforge = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSourceforge);
        jMenuItemHelpSourceforge.setText("Weka on SourceForge");
        jMenuItemHelpSourceforge.setMnemonic('F');
        jMenuItemHelpSourceforge.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://sourceforge.net/projects/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/SystemInfo
        jMenuItemHelpSystemInfo = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSystemInfo);
        jMenuItemHelpSystemInfo.setText("SystemInfo");
        jMenuItemHelpHomepage.setMnemonic('S');
        jMenuItemHelpSystemInfo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpSystemInfo.getText();
                if (!containsWindow(title)) {
                    // get info
                    Hashtable info = new SystemInfo().getSystemInfo();
                    // sort names
                    Vector names = new Vector();
                    Enumeration enm = info.keys();
                    while (enm.hasMoreElements()) names.add(enm.nextElement());
                    Collections.sort(names);
                    // generate table
                    String[][] data = new String[info.size()][2];
                    for (int i = 0; i < names.size(); i++) {
                        data[i][0] = names.get(i).toString();
                        data[i][1] = info.get(data[i][0]).toString();
                    }
                    String[] titles = new String[] { "Key", "Value" };
                    JTable table = new JTable(data, titles);
                    createFrame(m_Self, title, new JScrollPane(table), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/About
        jMenuItemHelpAbout = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpAbout);
        jMenuItemHelpAbout.setText("About");
        jMenuItemHelpAbout.setMnemonic('A');
        jMenuItemHelpAbout.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpAbout.getText();
                if (!containsWindow(title)) {
                    JPanel wekaPan = new JPanel();
                    wekaPan.setToolTipText("Weka, a native bird of New Zealand");
                    ImageIcon wii = new ImageIcon(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("weka/gui/weka3.gif")));
                    JLabel wekaLab = new JLabel(wii);
                    wekaPan.add(wekaLab);
                    Container frame = createFrame(m_Self, title, wekaPan, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, true, true);
                    JPanel titlePan = new JPanel();
                    titlePan.setLayout(new GridLayout(8, 1));
                    titlePan.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
                    titlePan.add(new JLabel("Waikato Environment for", SwingConstants.CENTER));
                    titlePan.add(new JLabel("Knowledge Analysis", SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("Version " + Version.VERSION, SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("(c) " + Copyright.getFromYear() + " - " + Copyright.getToYear(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getOwner(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getAddress(), SwingConstants.CENTER));
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameMDI) frame).pack();
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameSDI) frame).pack();
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // size + position
        int screenHeight = getGraphicsConfiguration().getBounds().height;
        int screenWidth = getGraphicsConfiguration().getBounds().width;
        if (m_GUIType == GUI_MDI) {
            int newHeight = (int) (((double) screenHeight) * 0.75);
            int newWidth = (int) (((double) screenWidth) * 0.75);
            setSize(1000 > newWidth ? newWidth : 1000, 800 > newHeight ? newHeight : 800);
            setLocation((screenWidth - getBounds().width) / 2, (screenHeight - getBounds().height) / 2);
        } else if (m_GUIType == GUI_SDI) {
            pack();
            setSize(screenWidth, getHeight());
            setLocation(0, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 78
Project: Electric-VLSI-master  File: Main.java View source code
public void init() {
    // convert args to array list
    List<String> argsList = new ArrayList<String>();
    //for (int i=0; i<args.length; i++) argsList.add(args[i]);
    /**
		// -v (short version)
		if (hasCommandLineOption(argsList, "-v"))
		{
			System.out.println(Version.getVersion());
			System.exit(0);
		}

		// -version
		if (hasCommandLineOption(argsList, "-version"))
		{
			System.out.println(Version.getApplicationInformation());
			System.out.println("\t"+Version.getVersionInformation());
			System.out.println("\t"+Version.getCopyrightInformation());
			System.out.println("\t"+Version.getWarrantyInformation());
			System.exit(0);
		}

        // -help
        if (hasCommandLineOption(argsList, "-help"))
		{
	        System.out.println("Usage (without plugins):");
	        System.out.println("\tjava -jar electric.jar [electric-options]");
	        System.out.println("Usage (with plugins):");
	        System.out.println("\tjava -classpath electric.jar<delim>{list of plugins} com.sun.electric.Launcher [electric-options]");
	        System.out.println("\t\twhere <delim> is OS-dependant separator (colon or semicolon)");
	        System.out.println("\nOptions:");
            System.out.println("\t-mdi: multiple document interface mode");
	        System.out.println("\t-sdi: single document interface mode");
	        System.out.println("\t-NOMINMEM: ignore minimum memory provided for JVM");
	        System.out.println("\t-s <script name>: bean shell script to execute");
	        System.out.println("\t-version: version information");
	        System.out.println("\t-v: brief version information");
	        System.out.println("\t-debug: debug mode. Extra information is available");
            System.out.println("\t-threads <numThreads>: recommended size of thread pool for Job execution.");
            System.out.println("\t-logging <filePath>: log server events in a binary file");
            System.out.println("\t-socket <socket>: socket port for client/server interaction");
	        System.out.println("\t-batch: batch mode implies 'no GUI', and nothing more");
            System.out.println("\t-server: dump trace of snapshots");
            System.out.println("\t-client <machine name>: replay trace of snapshots");
	        System.out.println("\t-help: this message");

			System.exit(0);
		}
**/
    appSize = getSize();
    Toolkit tk = Toolkit.getDefaultToolkit();
    scrnSize = tk.getScreenSize();
    // -debug for debugging
    runMode = DEFAULT_MODE;
    List<String> pipeOptions = new ArrayList<String>();
    if (hasCommandLineOption(argsList, "-debug")) {
        pipeOptions.add(" -debug");
        Job.setDebug(true);
    }
    if (hasCommandLineOption(argsList, "-extraDebug")) {
        pipeOptions.add("-extraDebug");
        Job.LOCALDEBUGFLAG = true;
    }
    String numThreadsString = getCommandLineOption(argsList, "-threads");
    int numThreads = 0;
    if (numThreadsString != null) {
        numThreads = TextUtils.atoi(numThreadsString);
        if (numThreads > 0) {
            pipeOptions.add("-threads");
            pipeOptions.add(String.valueOf(numThreads));
        } else
            System.out.println("Invalid option -threads " + numThreadsString);
    }
    String loggingFilePath = getCommandLineOption(argsList, "-logging");
    if (loggingFilePath != null) {
        pipeOptions.add("-logging");
        pipeOptions.add(loggingFilePath);
    }
    String socketString = getCommandLineOption(argsList, "-socket");
    int socketPort = 0;
    if (socketString != null) {
        socketPort = TextUtils.atoi(socketString);
        if (socketPort > 0) {
            pipeOptions.add("-socket");
            pipeOptions.add(String.valueOf(socketPort));
        } else
            System.out.println("Invalid option -socket " + socketString);
    }
    // do nothing, just consume option: handled in Launcher
    hasCommandLineOption(argsList, "-NOMINMEM");
    // The server runs in subprocess
    if (hasCommandLineOption(argsList, "-pipeserver")) {
        ActivityLogger.initialize("electricserver", true, true, true, /*false*/
        true, false);
        Job.pipeServer(numThreads, loggingFilePath, socketPort);
        return;
    }
    ActivityLogger.initialize("electric", true, true, true, /*false*/
    User.isEnableLog(), User.isMultipleLog());
    if (hasCommandLineOption(argsList, "-batch")) {
        //System.setProperty("java.awt.headless", "true");
        runMode = Mode.BATCH;
    }
    if (hasCommandLineOption(argsList, "-server")) {
        if (runMode != DEFAULT_MODE)
            System.out.println("Conflicting thread modes: " + runMode + " and " + Mode.SERVER);
        runMode = Mode.SERVER;
    }
    String serverMachineName = getCommandLineOption(argsList, "-client");
    if (serverMachineName != null) {
        if (runMode != DEFAULT_MODE)
            System.out.println("Conflicting thread modes: " + runMode + " and " + Mode.CLIENT);
        runMode = Mode.CLIENT;
    }
    if (hasCommandLineOption(argsList, "-pipe")) {
        if (runMode != DEFAULT_MODE)
            System.out.println("Conflicting thread modes: " + runMode + " and " + Mode.CLIENT);
        runMode = Mode.CLIENT;
    }
    if (hasCommandLineOption(argsList, "-pipedebug")) {
        if (runMode != DEFAULT_MODE)
            System.out.println("Conflicting thread modes: " + runMode + " and " + Mode.CLIENT);
        runMode = Mode.CLIENT;
    }
    desktop = new JDesktopPane();
    desktop.setVisible(true);
    getContentPane().add(desktop);
    AbstractUserInterface ui;
    ui = new UserInterfaceMain(argsList, this);
    MessagesStream.getMessagesStream();
    // initialize database
    TextDescriptor.cacheSize();
    Tool.initAllTools();
    Pref.lockCreation();
    EDatabase database = new EDatabase(IdManager.stdIdManager.getInitialSnapshot(), "clientDB");
    EDatabase.setClientDatabase(database);
    Job.setUserInterface(new UserInterfaceInitial(database));
    InitDatabase job = new InitDatabase(argsList);
    EDatabase.setServerDatabase(new EDatabase(IdManager.stdIdManager.getInitialSnapshot(), "serverDB"));
    EDatabase.setCheckExamine();
    Job.initJobManager(numThreads, loggingFilePath, socketPort, ui, job);
}
Example 79
Project: haskell-java-parser-master  File: BasicInternalFrameUI.java View source code
/**
     * This method is called when the JDesktopPane is resized.
     *
     * @param e The ComponentEvent fired.
     */
public void componentResized(ComponentEvent e) {
    if (frame.isMaximum()) {
        JDesktopPane pane = (JDesktopPane) e.getSource();
        Insets insets = pane.getInsets();
        Rectangle bounds = pane.getBounds();
        frame.setBounds(bounds.x + insets.left, bounds.y + insets.top, bounds.width - insets.left - insets.right, bounds.height - insets.top - insets.bottom);
        frame.revalidate();
        frame.repaint();
    }
// Sun also resizes the icons. but it doesn't seem to do anything.
}
Example 80
Project: LPmade-master  File: Main.java View source code
/**
   * initializes the GUI.
   */
protected void initGUI() {
    m_Self = this;
    try {
        // main window
        createTitle("");
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("weka/gui/weka_icon.gif")).getImage());
        // bits and pieces
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".bif", "BIF Files (*.bif)"));
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".xml", "XML Files (*.xml)"));
        m_FileChooserPlot.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        m_FileChooserPlot.setMultiSelectionEnabled(true);
        m_FileChooserROC.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        // Desktop
        if (m_GUIType == GUI_MDI) {
            jDesktopPane = new BackgroundDesktopPane("weka/gui/images/weka_background.gif");
            jDesktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
            setContentPane(jDesktopPane);
        } else {
            jDesktopPane = null;
        }
        // Menu
        jMenuBar = new JMenuBar();
        setJMenuBar(jMenuBar);
        // Program
        jMenuProgram = new JMenu();
        jMenuBar.add(jMenuProgram);
        jMenuProgram.setText("Program");
        jMenuProgram.setMnemonic('P');
        // Program/Preferences
        // TODO: read all properties from all props file and display them
        /*
        jMenuItemProgramPreferences = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramPreferences);
        jMenuItemProgramPreferences.setText("Preferences");
        jMenuItemProgramPreferences.setMnemonic('P');
        jMenuItemProgramPreferences.addActionListener(new ActionListener() {
  	  public void actionPerformed(ActionEvent evt) {
	    System.out.println("jMenuItemProgramPreferences.actionPerformed, event="+evt);
	    //TODO add your code for jMenuItemProgramPreferences.actionPerformed
  	  }
        });
       */
        // Program/LogWindow
        jMenuItemProgramLogWindow = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramLogWindow);
        jMenuItemProgramLogWindow.setText("LogWindow");
        jMenuItemProgramLogWindow.setMnemonic('L');
        jMenuItemProgramLogWindow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                m_LogWindow.setVisible(true);
            }
        });
        jMenuItemProgramMemoryUsage = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramMemoryUsage);
        jMenuItemProgramMemoryUsage.setText("Memory usage");
        jMenuItemProgramMemoryUsage.setMnemonic('M');
        jMenuItemProgramMemoryUsage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemProgramMemoryUsage.getText();
                if (!containsWindow(title)) {
                    final MemoryUsagePanel panel = new MemoryUsagePanel();
                    Container c = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 400, 50, null, true, true);
                    // optimize size
                    Dimension size = c.getPreferredSize();
                    c.setSize(new Dimension((int) size.getWidth(), (int) size.getHeight()));
                    // stop threads
                    if (m_GUIType == GUI_MDI) {
                        final ChildFrameMDI frame = (ChildFrameMDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    } else {
                        final ChildFrameSDI frame = (ChildFrameSDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuProgram.add(new JSeparator());
        // Program/Exit
        jMenuItemProgramExit = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramExit);
        jMenuItemProgramExit.setText("Exit");
        jMenuItemProgramExit.setMnemonic('E');
        jMenuItemProgramExit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // close all children
                Iterator iter = getWindowList();
                Vector<Container> list = new Vector<Container>();
                while (iter.hasNext()) list.add((Container) 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);
            }
        });
        // Applications
        jMenuApplications = new JMenu();
        jMenuBar.add(jMenuApplications);
        jMenuApplications.setText("Applications");
        jMenuApplications.setMnemonic('A');
        // Applications/Explorer
        jMenuItemApplicationsExplorer = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExplorer);
        jMenuItemApplicationsExplorer.setText("Explorer");
        jMenuItemApplicationsExplorer.setMnemonic('E');
        jMenuItemApplicationsExplorer.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/Experimenter
        jMenuItemApplicationsExperimenter = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExperimenter);
        jMenuItemApplicationsExperimenter.setText("Experimenter");
        jMenuItemApplicationsExperimenter.setMnemonic('X');
        jMenuItemApplicationsExperimenter.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/KnowledgeFlow
        jMenuItemApplicationsKnowledgeFlow = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsKnowledgeFlow);
        jMenuItemApplicationsKnowledgeFlow.setText("KnowledgeFlow");
        jMenuItemApplicationsKnowledgeFlow.setMnemonic('K');
        jMenuItemApplicationsKnowledgeFlow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsKnowledgeFlow.getText();
                if (!containsWindow(title)) {
                    KnowledgeFlowApp.createSingleton(new String[0]);
                    createFrame(m_Self, title, KnowledgeFlowApp.getSingleton(), new BorderLayout(), BorderLayout.CENTER, 900, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Applications/SimpleCLI
        jMenuItemApplicationsSimpleCLI = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsSimpleCLI);
        jMenuItemApplicationsSimpleCLI.setText("SimpleCLI");
        jMenuItemApplicationsSimpleCLI.setMnemonic('S');
        jMenuItemApplicationsSimpleCLI.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsSimpleCLI.getText();
                if (!containsWindow(title)) {
                    try {
                        createFrame(m_Self, title, new SimpleCLIPanel(), new BorderLayout(), BorderLayout.CENTER, 600, 500, null, true, true);
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error instantiating SimpleCLI:\n" + e.getMessage());
                        return;
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools
        jMenuTools = new JMenu();
        jMenuBar.add(jMenuTools);
        jMenuTools.setText("Tools");
        jMenuTools.setMnemonic('T');
        // Tools/ArffViewer
        jMenuItemToolsArffViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsArffViewer);
        jMenuItemToolsArffViewer.setText("ArffViewer");
        jMenuItemToolsArffViewer.setMnemonic('A');
        jMenuItemToolsArffViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsArffViewer.getText();
                if (!containsWindow(title)) {
                    ArffViewerMainPanel panel = new ArffViewerMainPanel(null);
                    panel.setConfirmExit(false);
                    Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenu(), true, true);
                    panel.setParent(frame);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/SqlViewer
        jMenuItemToolsSqlViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsSqlViewer);
        jMenuItemToolsSqlViewer.setText("SqlViewer");
        jMenuItemToolsSqlViewer.setMnemonic('S');
        jMenuItemToolsSqlViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsSqlViewer.getText();
                if (!containsWindow(title)) {
                    final SqlViewer sql = new SqlViewer(null);
                    final Container frame = createFrame(m_Self, title, sql, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, false, true);
                    // custom listener
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                sql.saveSize();
                                ((ChildFrameMDI) frame).dispose();
                            }
                        });
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                sql.saveSize();
                                ((ChildFrameSDI) frame).dispose();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/EnsembleLibrary
        /* currently disabled due to bugs... FracPete
      jMenuItemToolsEnsembleLibrary = new JMenuItem();
      jMenuTools.add(jMenuItemToolsEnsembleLibrary);
      jMenuItemToolsEnsembleLibrary.setText("EnsembleLibrary");
      jMenuItemToolsEnsembleLibrary.setMnemonic('E');
      jMenuItemToolsEnsembleLibrary.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  String title = jMenuItemToolsEnsembleLibrary.getText();
	  if (!containsWindow(title)) {
	    EnsembleLibrary value = new EnsembleLibrary();
	    EnsembleLibraryEditor libraryEditor = new EnsembleLibraryEditor();
	    libraryEditor.setValue(value);
	    createFrame(
		m_Self, title, libraryEditor.getCustomEditor(), new BorderLayout(), 
		BorderLayout.CENTER, 800, 600, null, true, true);
	  }
	  else {
	    showWindow(getWindow(title));
	  }
	}
      });
      */
        // Visualization
        jMenuVisualization = new JMenu();
        jMenuBar.add(jMenuVisualization);
        jMenuVisualization.setText("Visualization");
        jMenuVisualization.setMnemonic('V');
        // Visualization/Plot
        jMenuItemVisualizationPlot = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationPlot);
        jMenuItemVisualizationPlot.setText("Plot");
        jMenuItemVisualizationPlot.setMnemonic('P');
        jMenuItemVisualizationPlot.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserPlot.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build plot
                VisualizePanel panel = new VisualizePanel();
                String filenames = "";
                File[] files = m_FileChooserPlot.getSelectedFiles();
                for (int j = 0; j < files.length; j++) {
                    String filename = files[j].getAbsolutePath();
                    if (j > 0)
                        filenames += ", ";
                    filenames += filename;
                    System.err.println("Loading instances from " + filename);
                    try {
                        Reader r = new java.io.BufferedReader(new FileReader(filename));
                        Instances i = new Instances(r);
                        i.setClassIndex(i.numAttributes() - 1);
                        PlotData2D pd1 = new PlotData2D(i);
                        if (j == 0) {
                            pd1.setPlotName("Master plot");
                            panel.setMasterPlot(pd1);
                        } else {
                            pd1.setPlotName("Plot " + (j + 1));
                            pd1.m_useCustomColour = true;
                            pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
                            panel.addPlot(pd1);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error loading file '" + files[j] + "':\n" + e.getMessage());
                        return;
                    }
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationPlot.getText() + " - " + filenames, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/ROC
        // based on this Wiki article:
        // http://weka.sourceforge.net/wiki/index.php/Visualizing_ROC_curve
        jMenuItemVisualizationROC = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationROC);
        jMenuItemVisualizationROC.setText("ROC");
        jMenuItemVisualizationROC.setMnemonic('R');
        jMenuItemVisualizationROC.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserROC.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // create plot
                String filename = m_FileChooserROC.getSelectedFile().getAbsolutePath();
                Instances result = null;
                try {
                    result = new Instances(new BufferedReader(new FileReader(filename)));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                result.setClassIndex(result.numAttributes() - 1);
                ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
                vmc.setROCString("(Area under ROC = " + Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
                vmc.setName(result.relationName());
                PlotData2D tempd = new PlotData2D(result);
                tempd.setPlotName(result.relationName());
                tempd.addInstanceNumberAttribute();
                try {
                    vmc.addPlot(tempd);
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error adding plot:\n" + e.getMessage());
                    return;
                }
                createFrame(m_Self, jMenuItemVisualizationROC.getText() + " - " + filename, vmc, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/TreeVisualizer
        jMenuItemVisualizationTreeVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationTreeVisualizer);
        jMenuItemVisualizationTreeVisualizer.setText("TreeVisualizer");
        jMenuItemVisualizationTreeVisualizer.setMnemonic('T');
        jMenuItemVisualizationTreeVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserTreeVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build tree
                String filename = m_FileChooserTreeVisualizer.getSelectedFile().getAbsolutePath();
                TreeBuild builder = new TreeBuild();
                Node top = null;
                NodePlace arrange = new PlaceNode2();
                try {
                    top = builder.create(new FileReader(filename));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationTreeVisualizer.getText() + " - " + filename, new TreeVisualizer(null, top, arrange), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/GraphVisualizer
        jMenuItemVisualizationGraphVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationGraphVisualizer);
        jMenuItemVisualizationGraphVisualizer.setText("GraphVisualizer");
        jMenuItemVisualizationGraphVisualizer.setMnemonic('G');
        jMenuItemVisualizationGraphVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserGraphVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build graph
                String filename = m_FileChooserGraphVisualizer.getSelectedFile().getAbsolutePath();
                GraphVisualizer panel = new GraphVisualizer();
                try {
                    if (filename.toLowerCase().endsWith(".xml") || filename.toLowerCase().endsWith(".bif")) {
                        panel.readBIF(new FileInputStream(filename));
                    } else {
                        panel.readDOT(new FileReader(filename));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationGraphVisualizer.getText() + " - " + filename, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/BoundaryVisualizer
        jMenuItemVisualizationBoundaryVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationBoundaryVisualizer);
        jMenuItemVisualizationBoundaryVisualizer.setText("BoundaryVisualizer");
        jMenuItemVisualizationBoundaryVisualizer.setMnemonic('B');
        jMenuItemVisualizationBoundaryVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemVisualizationBoundaryVisualizer.getText();
                if (!containsWindow(title)) {
                    createFrame(m_Self, title, new BoundaryVisualizer(), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                    // dont' do a System.exit after last window got closed!
                    BoundaryVisualizer.setExitIfNoWindowsOpen(false);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Extensions
        jMenuExtensions = new JMenu("Extensions");
        jMenuExtensions.setMnemonic(java.awt.event.KeyEvent.VK_E);
        jMenuBar.add(jMenuExtensions);
        jMenuExtensions.setVisible(false);
        String extensions = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "");
        if (extensions.length() > 0) {
            jMenuExtensions.setVisible(true);
            String[] classnames = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "").split(",");
            Hashtable<String, JMenu> submenus = new Hashtable<String, JMenu>();
            // add all extensions
            for (int i = 0; i < classnames.length; i++) {
                String classname = classnames[i];
                try {
                    MainMenuExtension ext = (MainMenuExtension) Class.forName(classname).newInstance();
                    // menuitem in a submenu?
                    JMenu submenu = null;
                    if (ext.getSubmenuTitle() != null) {
                        submenu = submenus.get(ext.getSubmenuTitle());
                        if (submenu == null) {
                            submenu = new JMenu(ext.getSubmenuTitle());
                            submenus.put(ext.getSubmenuTitle(), submenu);
                            insertMenuItem(jMenuExtensions, submenu);
                        }
                    }
                    // create menu item
                    JMenuItem menuitem = new JMenuItem();
                    menuitem.setText(ext.getMenuTitle());
                    // does the extension need a frame or does it have its own ActionListener?
                    ActionListener listener = ext.getActionListener(m_Self);
                    if (listener != null) {
                        menuitem.addActionListener(listener);
                    } else {
                        final JMenuItem finalMenuitem = menuitem;
                        final MainMenuExtension finalExt = ext;
                        menuitem.addActionListener(new ActionListener() {

                            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);
                            }
                        });
                    }
                    // sorted insert of menu item
                    if (submenu != null)
                        insertMenuItem(submenu, menuitem);
                    else
                        insertMenuItem(jMenuExtensions, menuitem);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        // Windows
        jMenuWindows = new JMenu("Windows");
        jMenuWindows.setMnemonic(java.awt.event.KeyEvent.VK_W);
        jMenuBar.add(jMenuWindows);
        // initially, there are no windows open
        jMenuWindows.setVisible(false);
        // Help
        jMenuHelp = new JMenu();
        jMenuBar.add(jMenuHelp);
        jMenuHelp.setText("Help");
        jMenuHelp.setMnemonic('H');
        // Help/Homepage
        jMenuItemHelpHomepage = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpHomepage);
        jMenuItemHelpHomepage.setText("Weka homepage");
        jMenuItemHelpHomepage.setMnemonic('H');
        jMenuItemHelpHomepage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://www.cs.waikato.ac.nz/~ml/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/WekaDoc
        jMenuItemHelpWekaDoc = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpWekaDoc);
        jMenuItemHelpWekaDoc.setText("Online documentation");
        jMenuItemHelpWekaDoc.setMnemonic('D');
        jMenuItemHelpWekaDoc.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://weka.sourceforge.net/wekadoc/");
            }
        });
        // Help/WekaWiki
        jMenuItemHelpWekaWiki = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpWekaWiki);
        jMenuItemHelpWekaWiki.setText("HOWTOs, code snippets, etc.");
        jMenuItemHelpWekaWiki.setMnemonic('W');
        jMenuItemHelpWekaWiki.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://weka.sourceforge.net/wiki/");
            }
        });
        // Help/Sourceforge
        jMenuItemHelpSourceforge = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSourceforge);
        jMenuItemHelpSourceforge.setText("Weka on SourceForge");
        jMenuItemHelpSourceforge.setMnemonic('F');
        jMenuItemHelpSourceforge.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://sourceforge.net/projects/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/SystemInfo
        jMenuItemHelpSystemInfo = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSystemInfo);
        jMenuItemHelpSystemInfo.setText("SystemInfo");
        jMenuItemHelpHomepage.setMnemonic('S');
        jMenuItemHelpSystemInfo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpSystemInfo.getText();
                if (!containsWindow(title)) {
                    // get info
                    Hashtable info = new SystemInfo().getSystemInfo();
                    // sort names
                    Vector names = new Vector();
                    Enumeration enm = info.keys();
                    while (enm.hasMoreElements()) names.add(enm.nextElement());
                    Collections.sort(names);
                    // generate table
                    String[][] data = new String[info.size()][2];
                    for (int i = 0; i < names.size(); i++) {
                        data[i][0] = names.get(i).toString();
                        data[i][1] = info.get(data[i][0]).toString();
                    }
                    String[] titles = new String[] { "Key", "Value" };
                    JTable table = new JTable(data, titles);
                    createFrame(m_Self, title, new JScrollPane(table), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/About
        jMenuItemHelpAbout = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpAbout);
        jMenuItemHelpAbout.setText("About");
        jMenuItemHelpAbout.setMnemonic('A');
        jMenuItemHelpAbout.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpAbout.getText();
                if (!containsWindow(title)) {
                    JPanel wekaPan = new JPanel();
                    wekaPan.setToolTipText("Weka, a native bird of New Zealand");
                    ImageIcon wii = new ImageIcon(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("weka/gui/weka3.gif")));
                    JLabel wekaLab = new JLabel(wii);
                    wekaPan.add(wekaLab);
                    Container frame = createFrame(m_Self, title, wekaPan, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, true, true);
                    JPanel titlePan = new JPanel();
                    titlePan.setLayout(new GridLayout(8, 1));
                    titlePan.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
                    titlePan.add(new JLabel("Waikato Environment for", SwingConstants.CENTER));
                    titlePan.add(new JLabel("Knowledge Analysis", SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("Version " + Version.VERSION, SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("(c) " + Copyright.getFromYear() + " - " + Copyright.getToYear(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getOwner(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getAddress(), SwingConstants.CENTER));
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameMDI) frame).pack();
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameSDI) frame).pack();
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // size + position
        int screenHeight = getGraphicsConfiguration().getBounds().height;
        int screenWidth = getGraphicsConfiguration().getBounds().width;
        if (m_GUIType == GUI_MDI) {
            int newHeight = (int) (((double) screenHeight) * 0.75);
            int newWidth = (int) (((double) screenWidth) * 0.75);
            setSize(1000 > newWidth ? newWidth : 1000, 800 > newHeight ? newHeight : 800);
            setLocation((screenWidth - getBounds().width) / 2, (screenHeight - getBounds().height) / 2);
        } else if (m_GUIType == GUI_SDI) {
            pack();
            setSize(screenWidth, getHeight());
            setLocation(0, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 81
Project: platypus-master  File: JScalablePanel.java View source code
protected void autoScrollingStep(AutoScrollTimerTask asTask) {
    if (autoscrollingPane != null && autoscrollingDirection != null && asTask != null) {
        JScrollPane lautoscrollingPane = autoscrollingPane;
        Component lviewComp = lautoscrollingPane.getViewport().getView();
        if (lviewComp instanceof JComponent) {
            JComponent lview = (JComponent) lviewComp;
            Point lautoscrollingDirection = autoscrollingDirection;
            Rectangle viewRect = lautoscrollingPane.getViewport().getViewRect();
            Rectangle viewRectBeforeMovement = (Rectangle) viewRect.clone();
            viewRect.translate(lautoscrollingDirection.x, lautoscrollingDirection.y);
            lview.scrollRectToVisible(viewRect);
            Rectangle viewRectAfterMovement = lautoscrollingPane.getViewport().getViewRect();
            lautoscrollingDirection.x = viewRectAfterMovement.x - viewRectBeforeMovement.x;
            lautoscrollingDirection.y = viewRectAfterMovement.y - viewRectBeforeMovement.y;
            if (lautoscrollingDirection.x != 0 || lautoscrollingDirection.y != 0) {
                MouseEvent e = asTask.getEvent();
                if (e != null && dragTarget != null) {
                    JDesktopPane ldp = null;
                    DesktopManager ldm = null;
                    JInternalFrame lif = null;
                    JDesktopIcon ldi = null;
                    lif = iifInternalFrame(dragTarget);
                    if (lif != null && lif.getDesktopPane() != null) {
                        ldp = lif.getDesktopPane();
                        ldm = ldp.getDesktopManager();
                    } else {
                        ldi = iifDesktopIcon(dragTarget);
                        if (ldi != null && ldi.getDesktopPane() != null) {
                            ldp = ldi.getDesktopPane();
                            ldm = ldp.getDesktopManager();
                        }
                    }
                    if (ldp != null && ldm != null && (lif != null || ldi != null)) {
                        MouseListener[] mlisteners = dragTarget.getMouseListeners();
                        MouseMotionListener[] mmlisteners = dragTarget.getMouseMotionListeners();
                        if (mlisteners != null && mmlisteners != null) {
                            ldp.setDesktopManager(dummyDesktopManager);
                            try {
                                for (int i = 0; i < mlisteners.length; i++) {
                                    mlisteners[i].mousePressed(cloneMouseEvent(e, dragTarget, e.getID(), dragTargetInnerPt));
                                }
                            } finally {
                                ldp.setDesktopManager(ldm);
                            }
                            asTask.incEvent(lautoscrollingDirection);
                            MouseEvent afterMoveE = asTask.getEvent();
                            Point afterMovePt = convertPoint(afterMoveE.getPoint(), dragTarget);
                            Dimension beforeDragSize = dragTarget.getSize();
                            int lbeforeWidth = dragTarget.getWidth();
                            int lbeforeHeight = dragTarget.getHeight();
                            for (int i = 0; i < mmlisteners.length; i++) {
                                mmlisteners[i].mouseDragged(cloneMouseEvent(e, dragTarget, e.getID(), afterMovePt));
                            }
                            Dimension afterDragSize = dragTarget.getSize();
                            if (beforeDragSize != null && afterDragSize != null && !beforeDragSize.equals(afterDragSize) && dragTarget != null && dragTarget instanceof JComponent) {
                                int ldx = afterDragSize.width - beforeDragSize.width;
                                int ldy = afterDragSize.height - beforeDragSize.height;
                                JComponent jDragTarget = (JComponent) dragTarget;
                                Insets insts = jDragTarget.getInsets();
                                if (dragTargetInnerPt.x >= lbeforeWidth - insts.right) {
                                    dragTargetInnerPt.x += ldx;
                                }
                                if (dragTargetInnerPt.y >= lbeforeHeight - insts.bottom) {
                                    dragTargetInnerPt.y += ldy;
                                }
                            }
                        }
                    }
                }
            }
        } else {
            cancelAutoScrolling();
        }
    }
}
Example 82
Project: wekax-master  File: Main.java View source code
/**
   * initializes the GUI.
   */
protected void initGUI() {
    m_Self = this;
    try {
        // main window
        createTitle("");
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("weka/gui/weka_icon.gif")).getImage());
        // bits and pieces
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".bif", "BIF Files (*.bif)"));
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".xml", "XML Files (*.xml)"));
        m_FileChooserPlot.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        m_FileChooserPlot.setMultiSelectionEnabled(true);
        m_FileChooserROC.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        // Desktop
        if (m_GUIType == GUI_MDI) {
            jDesktopPane = new BackgroundDesktopPane("weka/gui/images/weka_background.gif");
            jDesktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
            setContentPane(jDesktopPane);
        } else {
            jDesktopPane = null;
        }
        // Menu
        jMenuBar = new JMenuBar();
        setJMenuBar(jMenuBar);
        // Program
        jMenuProgram = new JMenu();
        jMenuBar.add(jMenuProgram);
        jMenuProgram.setText("Program");
        jMenuProgram.setMnemonic('P');
        // Program/Preferences
        // TODO: read all properties from all props file and display them
        /*
        jMenuItemProgramPreferences = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramPreferences);
        jMenuItemProgramPreferences.setText("Preferences");
        jMenuItemProgramPreferences.setMnemonic('P');
        jMenuItemProgramPreferences.addActionListener(new ActionListener() {
  	  public void actionPerformed(ActionEvent evt) {
	    System.out.println("jMenuItemProgramPreferences.actionPerformed, event="+evt);
	    //TODO add your code for jMenuItemProgramPreferences.actionPerformed
  	  }
        });
       */
        // Program/LogWindow
        jMenuItemProgramLogWindow = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramLogWindow);
        jMenuItemProgramLogWindow.setText("LogWindow");
        jMenuItemProgramLogWindow.setMnemonic('L');
        jMenuItemProgramLogWindow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                m_LogWindow.setVisible(true);
            }
        });
        jMenuItemProgramMemoryUsage = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramMemoryUsage);
        jMenuItemProgramMemoryUsage.setText("Memory usage");
        jMenuItemProgramMemoryUsage.setMnemonic('M');
        jMenuItemProgramMemoryUsage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemProgramMemoryUsage.getText();
                if (!containsWindow(title)) {
                    final MemoryUsagePanel panel = new MemoryUsagePanel();
                    Container c = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 400, 50, null, true, true);
                    // optimize size
                    Dimension size = c.getPreferredSize();
                    c.setSize(new Dimension((int) size.getWidth(), (int) size.getHeight()));
                    // stop threads
                    if (m_GUIType == GUI_MDI) {
                        final ChildFrameMDI frame = (ChildFrameMDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    } else {
                        final ChildFrameSDI frame = (ChildFrameSDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuProgram.add(new JSeparator());
        // Program/Exit
        jMenuItemProgramExit = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramExit);
        jMenuItemProgramExit.setText("Exit");
        jMenuItemProgramExit.setMnemonic('E');
        jMenuItemProgramExit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // close all children
                Iterator iter = getWindowList();
                Vector<Container> list = new Vector<Container>();
                while (iter.hasNext()) list.add((Container) 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);
            }
        });
        // Applications
        jMenuApplications = new JMenu();
        jMenuBar.add(jMenuApplications);
        jMenuApplications.setText("Applications");
        jMenuApplications.setMnemonic('A');
        // Applications/Explorer
        jMenuItemApplicationsExplorer = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExplorer);
        jMenuItemApplicationsExplorer.setText("Explorer");
        jMenuItemApplicationsExplorer.setMnemonic('E');
        jMenuItemApplicationsExplorer.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/Experimenter
        jMenuItemApplicationsExperimenter = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExperimenter);
        jMenuItemApplicationsExperimenter.setText("Experimenter");
        jMenuItemApplicationsExperimenter.setMnemonic('X');
        jMenuItemApplicationsExperimenter.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/KnowledgeFlow
        jMenuItemApplicationsKnowledgeFlow = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsKnowledgeFlow);
        jMenuItemApplicationsKnowledgeFlow.setText("KnowledgeFlow");
        jMenuItemApplicationsKnowledgeFlow.setMnemonic('K');
        jMenuItemApplicationsKnowledgeFlow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsKnowledgeFlow.getText();
                if (!containsWindow(title)) {
                    KnowledgeFlowApp.createSingleton(new String[0]);
                    createFrame(m_Self, title, KnowledgeFlowApp.getSingleton(), new BorderLayout(), BorderLayout.CENTER, 900, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Applications/SimpleCLI
        jMenuItemApplicationsSimpleCLI = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsSimpleCLI);
        jMenuItemApplicationsSimpleCLI.setText("SimpleCLI");
        jMenuItemApplicationsSimpleCLI.setMnemonic('S');
        jMenuItemApplicationsSimpleCLI.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsSimpleCLI.getText();
                if (!containsWindow(title)) {
                    try {
                        createFrame(m_Self, title, new SimpleCLIPanel(), new BorderLayout(), BorderLayout.CENTER, 600, 500, null, true, true);
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error instantiating SimpleCLI:\n" + e.getMessage());
                        return;
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools
        jMenuTools = new JMenu();
        jMenuBar.add(jMenuTools);
        jMenuTools.setText("Tools");
        jMenuTools.setMnemonic('T');
        // Tools/ArffViewer
        jMenuItemToolsArffViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsArffViewer);
        jMenuItemToolsArffViewer.setText("ArffViewer");
        jMenuItemToolsArffViewer.setMnemonic('A');
        jMenuItemToolsArffViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsArffViewer.getText();
                if (!containsWindow(title)) {
                    ArffViewerMainPanel panel = new ArffViewerMainPanel(null);
                    panel.setConfirmExit(false);
                    Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenu(), true, true);
                    panel.setParent(frame);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/SqlViewer
        jMenuItemToolsSqlViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsSqlViewer);
        jMenuItemToolsSqlViewer.setText("SqlViewer");
        jMenuItemToolsSqlViewer.setMnemonic('S');
        jMenuItemToolsSqlViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsSqlViewer.getText();
                if (!containsWindow(title)) {
                    final SqlViewer sql = new SqlViewer(null);
                    final Container frame = createFrame(m_Self, title, sql, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, false, true);
                    // custom listener
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                sql.saveSize();
                                ((ChildFrameMDI) frame).dispose();
                            }
                        });
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                sql.saveSize();
                                ((ChildFrameSDI) frame).dispose();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/Bayes net editor
        // Tools/Bayes net editor
        final JMenuItem jMenuItemBayesNet = new JMenuItem();
        jMenuTools.add(jMenuItemBayesNet);
        jMenuItemBayesNet.setText("Bayes net editor");
        jMenuItemBayesNet.setMnemonic('N');
        jMenuItemBayesNet.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                String title = jMenuItemBayesNet.getText();
                if (!containsWindow(title)) {
                    final GUI bayesNetGUI = new GUI();
                    final Container frame = createFrame(m_Self, title, bayesNetGUI, new BorderLayout(), BorderLayout.CENTER, 800, 600, bayesNetGUI.getMenuBar(), false, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/EnsembleLibrary
        /* currently disabled due to bugs... FracPete
      jMenuItemToolsEnsembleLibrary = new JMenuItem();
      jMenuTools.add(jMenuItemToolsEnsembleLibrary);
      jMenuItemToolsEnsembleLibrary.setText("EnsembleLibrary");
      jMenuItemToolsEnsembleLibrary.setMnemonic('E');
      jMenuItemToolsEnsembleLibrary.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  String title = jMenuItemToolsEnsembleLibrary.getText();
	  if (!containsWindow(title)) {
	    EnsembleLibrary value = new EnsembleLibrary();
	    EnsembleLibraryEditor libraryEditor = new EnsembleLibraryEditor();
	    libraryEditor.setValue(value);
	    createFrame(
		m_Self, title, libraryEditor.getCustomEditor(), new BorderLayout(), 
		BorderLayout.CENTER, 800, 600, null, true, true);
	  }
	  else {
	    showWindow(getWindow(title));
	  }
	}
      });
      */
        // Visualization
        jMenuVisualization = new JMenu();
        jMenuBar.add(jMenuVisualization);
        jMenuVisualization.setText("Visualization");
        jMenuVisualization.setMnemonic('V');
        // Visualization/Plot
        jMenuItemVisualizationPlot = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationPlot);
        jMenuItemVisualizationPlot.setText("Plot");
        jMenuItemVisualizationPlot.setMnemonic('P');
        jMenuItemVisualizationPlot.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserPlot.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build plot
                VisualizePanel panel = new VisualizePanel();
                String filenames = "";
                File[] files = m_FileChooserPlot.getSelectedFiles();
                for (int j = 0; j < files.length; j++) {
                    String filename = files[j].getAbsolutePath();
                    if (j > 0)
                        filenames += ", ";
                    filenames += filename;
                    System.err.println("Loading instances from " + filename);
                    try {
                        Reader r = new java.io.BufferedReader(new FileReader(filename));
                        Instances i = new Instances(r);
                        i.setClassIndex(i.numAttributes() - 1);
                        PlotData2D pd1 = new PlotData2D(i);
                        if (j == 0) {
                            pd1.setPlotName("Master plot");
                            panel.setMasterPlot(pd1);
                        } else {
                            pd1.setPlotName("Plot " + (j + 1));
                            pd1.m_useCustomColour = true;
                            pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
                            panel.addPlot(pd1);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error loading file '" + files[j] + "':\n" + e.getMessage());
                        return;
                    }
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationPlot.getText() + " - " + filenames, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/ROC
        // based on this Wiki article:
        // http://weka.sourceforge.net/wiki/index.php/Visualizing_ROC_curve
        jMenuItemVisualizationROC = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationROC);
        jMenuItemVisualizationROC.setText("ROC");
        jMenuItemVisualizationROC.setMnemonic('R');
        jMenuItemVisualizationROC.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserROC.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // create plot
                String filename = m_FileChooserROC.getSelectedFile().getAbsolutePath();
                Instances result = null;
                try {
                    result = new Instances(new BufferedReader(new FileReader(filename)));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                result.setClassIndex(result.numAttributes() - 1);
                ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
                vmc.setROCString("(Area under ROC = " + Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
                vmc.setName(result.relationName());
                PlotData2D tempd = new PlotData2D(result);
                tempd.setPlotName(result.relationName());
                tempd.addInstanceNumberAttribute();
                try {
                    vmc.addPlot(tempd);
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error adding plot:\n" + e.getMessage());
                    return;
                }
                createFrame(m_Self, jMenuItemVisualizationROC.getText() + " - " + filename, vmc, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/TreeVisualizer
        jMenuItemVisualizationTreeVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationTreeVisualizer);
        jMenuItemVisualizationTreeVisualizer.setText("TreeVisualizer");
        jMenuItemVisualizationTreeVisualizer.setMnemonic('T');
        jMenuItemVisualizationTreeVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserTreeVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build tree
                String filename = m_FileChooserTreeVisualizer.getSelectedFile().getAbsolutePath();
                TreeBuild builder = new TreeBuild();
                Node top = null;
                NodePlace arrange = new PlaceNode2();
                try {
                    top = builder.create(new FileReader(filename));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationTreeVisualizer.getText() + " - " + filename, new TreeVisualizer(null, top, arrange), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/GraphVisualizer
        jMenuItemVisualizationGraphVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationGraphVisualizer);
        jMenuItemVisualizationGraphVisualizer.setText("GraphVisualizer");
        jMenuItemVisualizationGraphVisualizer.setMnemonic('G');
        jMenuItemVisualizationGraphVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserGraphVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build graph
                String filename = m_FileChooserGraphVisualizer.getSelectedFile().getAbsolutePath();
                GraphVisualizer panel = new GraphVisualizer();
                try {
                    if (filename.toLowerCase().endsWith(".xml") || filename.toLowerCase().endsWith(".bif")) {
                        panel.readBIF(new FileInputStream(filename));
                    } else {
                        panel.readDOT(new FileReader(filename));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationGraphVisualizer.getText() + " - " + filename, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/BoundaryVisualizer
        jMenuItemVisualizationBoundaryVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationBoundaryVisualizer);
        jMenuItemVisualizationBoundaryVisualizer.setText("BoundaryVisualizer");
        jMenuItemVisualizationBoundaryVisualizer.setMnemonic('B');
        jMenuItemVisualizationBoundaryVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemVisualizationBoundaryVisualizer.getText();
                if (!containsWindow(title)) {
                    createFrame(m_Self, title, new BoundaryVisualizer(), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                    // dont' do a System.exit after last window got closed!
                    BoundaryVisualizer.setExitIfNoWindowsOpen(false);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Extensions
        jMenuExtensions = new JMenu("Extensions");
        jMenuExtensions.setMnemonic(java.awt.event.KeyEvent.VK_E);
        jMenuBar.add(jMenuExtensions);
        jMenuExtensions.setVisible(false);
        String extensions = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "");
        if (extensions.length() > 0) {
            jMenuExtensions.setVisible(true);
            String[] classnames = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "").split(",");
            Hashtable<String, JMenu> submenus = new Hashtable<String, JMenu>();
            // add all extensions
            for (int i = 0; i < classnames.length; i++) {
                String classname = classnames[i];
                try {
                    MainMenuExtension ext = (MainMenuExtension) Class.forName(classname).newInstance();
                    // menuitem in a submenu?
                    JMenu submenu = null;
                    if (ext.getSubmenuTitle() != null) {
                        submenu = submenus.get(ext.getSubmenuTitle());
                        if (submenu == null) {
                            submenu = new JMenu(ext.getSubmenuTitle());
                            submenus.put(ext.getSubmenuTitle(), submenu);
                            insertMenuItem(jMenuExtensions, submenu);
                        }
                    }
                    // create menu item
                    JMenuItem menuitem = new JMenuItem();
                    menuitem.setText(ext.getMenuTitle());
                    // does the extension need a frame or does it have its own ActionListener?
                    ActionListener listener = ext.getActionListener(m_Self);
                    if (listener != null) {
                        menuitem.addActionListener(listener);
                    } else {
                        final JMenuItem finalMenuitem = menuitem;
                        final MainMenuExtension finalExt = ext;
                        menuitem.addActionListener(new ActionListener() {

                            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);
                            }
                        });
                    }
                    // sorted insert of menu item
                    if (submenu != null)
                        insertMenuItem(submenu, menuitem);
                    else
                        insertMenuItem(jMenuExtensions, menuitem);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        // Windows
        jMenuWindows = new JMenu("Windows");
        jMenuWindows.setMnemonic(java.awt.event.KeyEvent.VK_W);
        jMenuBar.add(jMenuWindows);
        // initially, there are no windows open
        jMenuWindows.setVisible(false);
        // Help
        jMenuHelp = new JMenu();
        jMenuBar.add(jMenuHelp);
        jMenuHelp.setText("Help");
        jMenuHelp.setMnemonic('H');
        // Help/Homepage
        jMenuItemHelpHomepage = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpHomepage);
        jMenuItemHelpHomepage.setText("Weka homepage");
        jMenuItemHelpHomepage.setMnemonic('H');
        jMenuItemHelpHomepage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://www.cs.waikato.ac.nz/~ml/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        /*      // Help/WekaDoc
      jMenuItemHelpWekaDoc = new JMenuItem();
      jMenuHelp.add(jMenuItemHelpWekaDoc);
      jMenuItemHelpWekaDoc.setText("Online documentation");
      jMenuItemHelpWekaDoc.setMnemonic('D');
      jMenuItemHelpWekaDoc.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  BrowserHelper.openURL(m_Self, "http://weka.sourceforge.net/wekadoc/");
	}
      }); */
        // Help/WekaWiki
        jMenuItemHelpWekaWiki = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpWekaWiki);
        jMenuItemHelpWekaWiki.setText("HOWTOs, code snippets, etc.");
        jMenuItemHelpWekaWiki.setMnemonic('W');
        jMenuItemHelpWekaWiki.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://weka.wikispaces.com/");
            }
        });
        // Help/Sourceforge
        jMenuItemHelpSourceforge = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSourceforge);
        jMenuItemHelpSourceforge.setText("Weka on SourceForge");
        jMenuItemHelpSourceforge.setMnemonic('F');
        jMenuItemHelpSourceforge.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://sourceforge.net/projects/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/SystemInfo
        jMenuItemHelpSystemInfo = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSystemInfo);
        jMenuItemHelpSystemInfo.setText("SystemInfo");
        jMenuItemHelpHomepage.setMnemonic('S');
        jMenuItemHelpSystemInfo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpSystemInfo.getText();
                if (!containsWindow(title)) {
                    // get info
                    Hashtable info = new SystemInfo().getSystemInfo();
                    // sort names
                    Vector names = new Vector();
                    Enumeration enm = info.keys();
                    while (enm.hasMoreElements()) names.add(enm.nextElement());
                    Collections.sort(names);
                    // generate table
                    String[][] data = new String[info.size()][2];
                    for (int i = 0; i < names.size(); i++) {
                        data[i][0] = names.get(i).toString();
                        data[i][1] = info.get(data[i][0]).toString();
                    }
                    String[] titles = new String[] { "Key", "Value" };
                    JTable table = new JTable(data, titles);
                    createFrame(m_Self, title, new JScrollPane(table), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/About
        jMenuItemHelpAbout = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpAbout);
        jMenuItemHelpAbout.setText("About");
        jMenuItemHelpAbout.setMnemonic('A');
        jMenuItemHelpAbout.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpAbout.getText();
                if (!containsWindow(title)) {
                    JPanel wekaPan = new JPanel();
                    wekaPan.setToolTipText("Weka, a native bird of New Zealand");
                    ImageIcon wii = new ImageIcon(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("weka/gui/weka3.gif")));
                    JLabel wekaLab = new JLabel(wii);
                    wekaPan.add(wekaLab);
                    Container frame = createFrame(m_Self, title, wekaPan, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, true, true);
                    JPanel titlePan = new JPanel();
                    titlePan.setLayout(new GridLayout(8, 1));
                    titlePan.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
                    titlePan.add(new JLabel("Waikato Environment for", SwingConstants.CENTER));
                    titlePan.add(new JLabel("Knowledge Analysis", SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("Version " + Version.VERSION, SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("(c) " + Copyright.getFromYear() + " - " + Copyright.getToYear(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getOwner(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getAddress(), SwingConstants.CENTER));
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameMDI) frame).pack();
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameSDI) frame).pack();
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // size + position
        int screenHeight = getGraphicsConfiguration().getBounds().height;
        int screenWidth = getGraphicsConfiguration().getBounds().width;
        if (m_GUIType == GUI_MDI) {
            int newHeight = (int) (((double) screenHeight) * 0.75);
            int newWidth = (int) (((double) screenWidth) * 0.75);
            setSize(1000 > newWidth ? newWidth : 1000, 800 > newHeight ? newHeight : 800);
            setLocation((screenWidth - getBounds().width) / 2, (screenHeight - getBounds().height) / 2);
        } else if (m_GUIType == GUI_SDI) {
            pack();
            setSize(screenWidth, getHeight());
            setLocation(0, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 83
Project: extweka-master  File: Main.java View source code
/**
   * initializes the GUI.
   */
protected void initGUI() {
    m_Self = this;
    try {
        // main window
        createTitle("");
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("weka/gui/weka_icon.gif")).getImage());
        // bits and pieces
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".bif", "BIF Files (*.bif)"));
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".xml", "XML Files (*.xml)"));
        m_FileChooserPlot.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        m_FileChooserPlot.setMultiSelectionEnabled(true);
        m_FileChooserROC.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        // Desktop
        if (m_GUIType == GUI_MDI) {
            jDesktopPane = new BackgroundDesktopPane("weka/gui/images/weka_background.gif");
            jDesktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
            setContentPane(jDesktopPane);
        } else {
            jDesktopPane = null;
        }
        // Menu
        jMenuBar = new JMenuBar();
        setJMenuBar(jMenuBar);
        // Program
        jMenuProgram = new JMenu();
        jMenuBar.add(jMenuProgram);
        jMenuProgram.setText("Program");
        jMenuProgram.setMnemonic('P');
        // Program/Preferences
        // TODO: read all properties from all props file and display them
        /*
        jMenuItemProgramPreferences = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramPreferences);
        jMenuItemProgramPreferences.setText("Preferences");
        jMenuItemProgramPreferences.setMnemonic('P');
        jMenuItemProgramPreferences.addActionListener(new ActionListener() {
  	  public void actionPerformed(ActionEvent evt) {
	    System.out.println("jMenuItemProgramPreferences.actionPerformed, event="+evt);
	    //TODO add your code for jMenuItemProgramPreferences.actionPerformed
  	  }
        });
       */
        // Program/LogWindow
        jMenuItemProgramLogWindow = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramLogWindow);
        jMenuItemProgramLogWindow.setText("LogWindow");
        jMenuItemProgramLogWindow.setMnemonic('L');
        jMenuItemProgramLogWindow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                m_LogWindow.setVisible(true);
            }
        });
        jMenuItemProgramMemoryUsage = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramMemoryUsage);
        jMenuItemProgramMemoryUsage.setText("Memory usage");
        jMenuItemProgramMemoryUsage.setMnemonic('M');
        jMenuItemProgramMemoryUsage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemProgramMemoryUsage.getText();
                if (!containsWindow(title)) {
                    final MemoryUsagePanel panel = new MemoryUsagePanel();
                    Container c = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 400, 50, null, true, true);
                    // optimize size
                    Dimension size = c.getPreferredSize();
                    c.setSize(new Dimension((int) size.getWidth(), (int) size.getHeight()));
                    // stop threads
                    if (m_GUIType == GUI_MDI) {
                        final ChildFrameMDI frame = (ChildFrameMDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    } else {
                        final ChildFrameSDI frame = (ChildFrameSDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuProgram.add(new JSeparator());
        // Program/Exit
        jMenuItemProgramExit = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramExit);
        jMenuItemProgramExit.setText("Exit");
        jMenuItemProgramExit.setMnemonic('E');
        jMenuItemProgramExit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // close all children
                Iterator iter = getWindowList();
                Vector<Container> list = new Vector<Container>();
                while (iter.hasNext()) list.add((Container) 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);
            }
        });
        // Applications
        jMenuApplications = new JMenu();
        jMenuBar.add(jMenuApplications);
        jMenuApplications.setText("Applications");
        jMenuApplications.setMnemonic('A');
        // Applications/Explorer
        jMenuItemApplicationsExplorer = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExplorer);
        jMenuItemApplicationsExplorer.setText("Explorer");
        jMenuItemApplicationsExplorer.setMnemonic('E');
        jMenuItemApplicationsExplorer.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/Experimenter
        jMenuItemApplicationsExperimenter = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExperimenter);
        jMenuItemApplicationsExperimenter.setText("Experimenter");
        jMenuItemApplicationsExperimenter.setMnemonic('X');
        jMenuItemApplicationsExperimenter.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/KnowledgeFlow
        jMenuItemApplicationsKnowledgeFlow = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsKnowledgeFlow);
        jMenuItemApplicationsKnowledgeFlow.setText("KnowledgeFlow");
        jMenuItemApplicationsKnowledgeFlow.setMnemonic('K');
        jMenuItemApplicationsKnowledgeFlow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsKnowledgeFlow.getText();
                if (!containsWindow(title)) {
                    KnowledgeFlowApp.createSingleton(new String[0]);
                    createFrame(m_Self, title, KnowledgeFlowApp.getSingleton(), new BorderLayout(), BorderLayout.CENTER, 900, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Applications/SimpleCLI
        jMenuItemApplicationsSimpleCLI = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsSimpleCLI);
        jMenuItemApplicationsSimpleCLI.setText("SimpleCLI");
        jMenuItemApplicationsSimpleCLI.setMnemonic('S');
        jMenuItemApplicationsSimpleCLI.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsSimpleCLI.getText();
                if (!containsWindow(title)) {
                    try {
                        createFrame(m_Self, title, new SimpleCLIPanel(), new BorderLayout(), BorderLayout.CENTER, 600, 500, null, true, true);
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error instantiating SimpleCLI:\n" + e.getMessage());
                        return;
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools
        jMenuTools = new JMenu();
        jMenuBar.add(jMenuTools);
        jMenuTools.setText("Tools");
        jMenuTools.setMnemonic('T');
        // Tools/ArffViewer
        jMenuItemToolsArffViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsArffViewer);
        jMenuItemToolsArffViewer.setText("ArffViewer");
        jMenuItemToolsArffViewer.setMnemonic('A');
        jMenuItemToolsArffViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsArffViewer.getText();
                if (!containsWindow(title)) {
                    ArffViewerMainPanel panel = new ArffViewerMainPanel(null);
                    panel.setConfirmExit(false);
                    Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenu(), true, true);
                    panel.setParent(frame);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/SqlViewer
        jMenuItemToolsSqlViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsSqlViewer);
        jMenuItemToolsSqlViewer.setText("SqlViewer");
        jMenuItemToolsSqlViewer.setMnemonic('S');
        jMenuItemToolsSqlViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsSqlViewer.getText();
                if (!containsWindow(title)) {
                    final SqlViewer sql = new SqlViewer(null);
                    final Container frame = createFrame(m_Self, title, sql, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, false, true);
                    // custom listener
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                sql.saveSize();
                                ((ChildFrameMDI) frame).dispose();
                            }
                        });
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                sql.saveSize();
                                ((ChildFrameSDI) frame).dispose();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/Bayes net editor
        // Tools/Bayes net editor
        final JMenuItem jMenuItemBayesNet = new JMenuItem();
        jMenuTools.add(jMenuItemBayesNet);
        jMenuItemBayesNet.setText("Bayes net editor");
        jMenuItemBayesNet.setMnemonic('N');
        jMenuItemBayesNet.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                String title = jMenuItemBayesNet.getText();
                if (!containsWindow(title)) {
                    final GUI bayesNetGUI = new GUI();
                    final Container frame = createFrame(m_Self, title, bayesNetGUI, new BorderLayout(), BorderLayout.CENTER, 800, 600, bayesNetGUI.getMenuBar(), false, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/Groovy console
        if (Groovy.isPresent()) {
            jMenuItemToolsGroovyConsole = new JMenuItem();
            jMenuTools.add(jMenuItemToolsGroovyConsole);
            jMenuItemToolsGroovyConsole.setText("Groovy console");
            jMenuItemToolsGroovyConsole.setMnemonic('G');
            jMenuItemToolsGroovyConsole.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    String title = jMenuItemToolsGroovyConsole.getText();
                    if (!containsWindow(title)) {
                        final GroovyPanel panel = new GroovyPanel();
                        final Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenuBar(), false, true);
                        // custom listener
                        if (frame instanceof ChildFrameMDI) {
                            ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                                public void internalFrameClosing(InternalFrameEvent e) {
                                    ((ChildFrameMDI) frame).dispose();
                                }
                            });
                        } else if (frame instanceof ChildFrameSDI) {
                            ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                                public void windowClosing(WindowEvent e) {
                                    ((ChildFrameSDI) frame).dispose();
                                }
                            });
                        }
                    } else {
                        showWindow(getWindow(title));
                    }
                }
            });
        }
        // Tools/Jython console
        if (Jython.isPresent()) {
            jMenuItemToolsJythonConsole = new JMenuItem();
            jMenuTools.add(jMenuItemToolsJythonConsole);
            jMenuItemToolsJythonConsole.setText("Jython console");
            jMenuItemToolsJythonConsole.setMnemonic('J');
            jMenuItemToolsJythonConsole.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    String title = jMenuItemToolsJythonConsole.getText();
                    if (!containsWindow(title)) {
                        final JythonPanel panel = new JythonPanel();
                        final Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenuBar(), false, true);
                        // custom listener
                        if (frame instanceof ChildFrameMDI) {
                            ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                                public void internalFrameClosing(InternalFrameEvent e) {
                                    ((ChildFrameMDI) frame).dispose();
                                }
                            });
                        } else if (frame instanceof ChildFrameSDI) {
                            ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                                public void windowClosing(WindowEvent e) {
                                    ((ChildFrameSDI) frame).dispose();
                                }
                            });
                        }
                    } else {
                        showWindow(getWindow(title));
                    }
                }
            });
        }
        // Tools/EnsembleLibrary
        /* currently disabled due to bugs... FracPete
      jMenuItemToolsEnsembleLibrary = new JMenuItem();
      jMenuTools.add(jMenuItemToolsEnsembleLibrary);
      jMenuItemToolsEnsembleLibrary.setText("EnsembleLibrary");
      jMenuItemToolsEnsembleLibrary.setMnemonic('E');
      jMenuItemToolsEnsembleLibrary.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  String title = jMenuItemToolsEnsembleLibrary.getText();
	  if (!containsWindow(title)) {
	    EnsembleLibrary value = new EnsembleLibrary();
	    EnsembleLibraryEditor libraryEditor = new EnsembleLibraryEditor();
	    libraryEditor.setValue(value);
	    createFrame(
		m_Self, title, libraryEditor.getCustomEditor(), new BorderLayout(), 
		BorderLayout.CENTER, 800, 600, null, true, true);
	  }
	  else {
	    showWindow(getWindow(title));
	  }
	}
      });
      */
        // Visualization
        jMenuVisualization = new JMenu();
        jMenuBar.add(jMenuVisualization);
        jMenuVisualization.setText("Visualization");
        jMenuVisualization.setMnemonic('V');
        // Visualization/Plot
        jMenuItemVisualizationPlot = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationPlot);
        jMenuItemVisualizationPlot.setText("Plot");
        jMenuItemVisualizationPlot.setMnemonic('P');
        jMenuItemVisualizationPlot.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserPlot.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build plot
                VisualizePanel panel = new VisualizePanel();
                String filenames = "";
                File[] files = m_FileChooserPlot.getSelectedFiles();
                for (int j = 0; j < files.length; j++) {
                    String filename = files[j].getAbsolutePath();
                    if (j > 0)
                        filenames += ", ";
                    filenames += filename;
                    System.err.println("Loading instances from " + filename);
                    try {
                        Reader r = new java.io.BufferedReader(new FileReader(filename));
                        Instances i = new Instances(r);
                        i.setClassIndex(i.numAttributes() - 1);
                        PlotData2D pd1 = new PlotData2D(i);
                        if (j == 0) {
                            pd1.setPlotName("Master plot");
                            panel.setMasterPlot(pd1);
                        } else {
                            pd1.setPlotName("Plot " + (j + 1));
                            pd1.m_useCustomColour = true;
                            pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
                            panel.addPlot(pd1);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error loading file '" + files[j] + "':\n" + e.getMessage());
                        return;
                    }
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationPlot.getText() + " - " + filenames, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/ROC
        // based on this Wiki article:
        // http://weka.sourceforge.net/wiki/index.php/Visualizing_ROC_curve
        jMenuItemVisualizationROC = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationROC);
        jMenuItemVisualizationROC.setText("ROC");
        jMenuItemVisualizationROC.setMnemonic('R');
        jMenuItemVisualizationROC.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserROC.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // create plot
                String filename = m_FileChooserROC.getSelectedFile().getAbsolutePath();
                Instances result = null;
                try {
                    result = new Instances(new BufferedReader(new FileReader(filename)));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                result.setClassIndex(result.numAttributes() - 1);
                ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
                vmc.setROCString("(Area under ROC = " + Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
                vmc.setName(result.relationName());
                PlotData2D tempd = new PlotData2D(result);
                tempd.setPlotName(result.relationName());
                tempd.addInstanceNumberAttribute();
                try {
                    vmc.addPlot(tempd);
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error adding plot:\n" + e.getMessage());
                    return;
                }
                createFrame(m_Self, jMenuItemVisualizationROC.getText() + " - " + filename, vmc, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/TreeVisualizer
        jMenuItemVisualizationTreeVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationTreeVisualizer);
        jMenuItemVisualizationTreeVisualizer.setText("TreeVisualizer");
        jMenuItemVisualizationTreeVisualizer.setMnemonic('T');
        jMenuItemVisualizationTreeVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserTreeVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build tree
                String filename = m_FileChooserTreeVisualizer.getSelectedFile().getAbsolutePath();
                TreeBuild builder = new TreeBuild();
                Node top = null;
                NodePlace arrange = new PlaceNode2();
                try {
                    top = builder.create(new FileReader(filename));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationTreeVisualizer.getText() + " - " + filename, new TreeVisualizer(null, top, arrange), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/GraphVisualizer
        jMenuItemVisualizationGraphVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationGraphVisualizer);
        jMenuItemVisualizationGraphVisualizer.setText("GraphVisualizer");
        jMenuItemVisualizationGraphVisualizer.setMnemonic('G');
        jMenuItemVisualizationGraphVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserGraphVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build graph
                String filename = m_FileChooserGraphVisualizer.getSelectedFile().getAbsolutePath();
                GraphVisualizer panel = new GraphVisualizer();
                try {
                    if (filename.toLowerCase().endsWith(".xml") || filename.toLowerCase().endsWith(".bif")) {
                        panel.readBIF(new FileInputStream(filename));
                    } else {
                        panel.readDOT(new FileReader(filename));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationGraphVisualizer.getText() + " - " + filename, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/BoundaryVisualizer
        jMenuItemVisualizationBoundaryVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationBoundaryVisualizer);
        jMenuItemVisualizationBoundaryVisualizer.setText("BoundaryVisualizer");
        jMenuItemVisualizationBoundaryVisualizer.setMnemonic('B');
        jMenuItemVisualizationBoundaryVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemVisualizationBoundaryVisualizer.getText();
                if (!containsWindow(title)) {
                    createFrame(m_Self, title, new BoundaryVisualizer(), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                    // dont' do a System.exit after last window got closed!
                    BoundaryVisualizer.setExitIfNoWindowsOpen(false);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Extensions
        jMenuExtensions = new JMenu("Extensions");
        jMenuExtensions.setMnemonic(java.awt.event.KeyEvent.VK_E);
        jMenuBar.add(jMenuExtensions);
        jMenuExtensions.setVisible(false);
        String extensions = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "");
        if (extensions.length() > 0) {
            jMenuExtensions.setVisible(true);
            String[] classnames = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "").split(",");
            Hashtable<String, JMenu> submenus = new Hashtable<String, JMenu>();
            // add all extensions
            for (int i = 0; i < classnames.length; i++) {
                String classname = classnames[i];
                try {
                    MainMenuExtension ext = (MainMenuExtension) Class.forName(classname).newInstance();
                    // menuitem in a submenu?
                    JMenu submenu = null;
                    if (ext.getSubmenuTitle() != null) {
                        submenu = submenus.get(ext.getSubmenuTitle());
                        if (submenu == null) {
                            submenu = new JMenu(ext.getSubmenuTitle());
                            submenus.put(ext.getSubmenuTitle(), submenu);
                            insertMenuItem(jMenuExtensions, submenu);
                        }
                    }
                    // create menu item
                    JMenuItem menuitem = new JMenuItem();
                    menuitem.setText(ext.getMenuTitle());
                    // does the extension need a frame or does it have its own ActionListener?
                    ActionListener listener = ext.getActionListener(m_Self);
                    if (listener != null) {
                        menuitem.addActionListener(listener);
                    } else {
                        final JMenuItem finalMenuitem = menuitem;
                        final MainMenuExtension finalExt = ext;
                        menuitem.addActionListener(new ActionListener() {

                            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);
                            }
                        });
                    }
                    // sorted insert of menu item
                    if (submenu != null)
                        insertMenuItem(submenu, menuitem);
                    else
                        insertMenuItem(jMenuExtensions, menuitem);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        // Windows
        jMenuWindows = new JMenu("Windows");
        jMenuWindows.setMnemonic(java.awt.event.KeyEvent.VK_W);
        jMenuBar.add(jMenuWindows);
        // initially, there are no windows open
        jMenuWindows.setVisible(false);
        // Help
        jMenuHelp = new JMenu();
        jMenuBar.add(jMenuHelp);
        jMenuHelp.setText("Help");
        jMenuHelp.setMnemonic('H');
        // Help/Homepage
        jMenuItemHelpHomepage = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpHomepage);
        jMenuItemHelpHomepage.setText("Weka homepage");
        jMenuItemHelpHomepage.setMnemonic('H');
        jMenuItemHelpHomepage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://www.cs.waikato.ac.nz/~ml/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        /*      // Help/WekaDoc
      jMenuItemHelpWekaDoc = new JMenuItem();
      jMenuHelp.add(jMenuItemHelpWekaDoc);
      jMenuItemHelpWekaDoc.setText("Online documentation");
      jMenuItemHelpWekaDoc.setMnemonic('D');
      jMenuItemHelpWekaDoc.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  BrowserHelper.openURL(m_Self, "http://weka.sourceforge.net/wekadoc/");
	}
      }); */
        // Help/WekaWiki
        jMenuItemHelpWekaWiki = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpWekaWiki);
        jMenuItemHelpWekaWiki.setText("HOWTOs, code snippets, etc.");
        jMenuItemHelpWekaWiki.setMnemonic('W');
        jMenuItemHelpWekaWiki.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://weka.wikispaces.com/");
            }
        });
        // Help/Sourceforge
        jMenuItemHelpSourceforge = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSourceforge);
        jMenuItemHelpSourceforge.setText("Weka on SourceForge");
        jMenuItemHelpSourceforge.setMnemonic('F');
        jMenuItemHelpSourceforge.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://sourceforge.net/projects/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/SystemInfo
        jMenuItemHelpSystemInfo = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSystemInfo);
        jMenuItemHelpSystemInfo.setText("SystemInfo");
        jMenuItemHelpHomepage.setMnemonic('S');
        jMenuItemHelpSystemInfo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpSystemInfo.getText();
                if (!containsWindow(title)) {
                    // get info
                    Hashtable info = new SystemInfo().getSystemInfo();
                    // sort names
                    Vector names = new Vector();
                    Enumeration enm = info.keys();
                    while (enm.hasMoreElements()) names.add(enm.nextElement());
                    Collections.sort(names);
                    // generate table
                    String[][] data = new String[info.size()][2];
                    for (int i = 0; i < names.size(); i++) {
                        data[i][0] = names.get(i).toString();
                        data[i][1] = info.get(data[i][0]).toString();
                    }
                    String[] titles = new String[] { "Key", "Value" };
                    JTable table = new JTable(data, titles);
                    createFrame(m_Self, title, new JScrollPane(table), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/About
        jMenuItemHelpAbout = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpAbout);
        jMenuItemHelpAbout.setText("About");
        jMenuItemHelpAbout.setMnemonic('A');
        jMenuItemHelpAbout.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpAbout.getText();
                if (!containsWindow(title)) {
                    JPanel wekaPan = new JPanel();
                    wekaPan.setToolTipText("Weka, a native bird of New Zealand");
                    ImageIcon wii = new ImageIcon(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("weka/gui/weka3.gif")));
                    JLabel wekaLab = new JLabel(wii);
                    wekaPan.add(wekaLab);
                    Container frame = createFrame(m_Self, title, wekaPan, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, true, true);
                    JPanel titlePan = new JPanel();
                    titlePan.setLayout(new GridLayout(8, 1));
                    titlePan.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
                    titlePan.add(new JLabel("Waikato Environment for", SwingConstants.CENTER));
                    titlePan.add(new JLabel("Knowledge Analysis", SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("Version " + Version.VERSION, SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("(c) " + Copyright.getFromYear() + " - " + Copyright.getToYear(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getOwner(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getAddress(), SwingConstants.CENTER));
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameMDI) frame).pack();
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameSDI) frame).pack();
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // size + position
        int screenHeight = getGraphicsConfiguration().getBounds().height;
        int screenWidth = getGraphicsConfiguration().getBounds().width;
        if (m_GUIType == GUI_MDI) {
            int newHeight = (int) (((double) screenHeight) * 0.75);
            int newWidth = (int) (((double) screenWidth) * 0.75);
            setSize(1000 > newWidth ? newWidth : 1000, 800 > newHeight ? newHeight : 800);
            setLocation((screenWidth - getBounds().width) / 2, (screenHeight - getBounds().height) / 2);
        } else if (m_GUIType == GUI_SDI) {
            pack();
            setSize(screenWidth, getHeight());
            setLocation(0, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 84
Project: freedomotic-master  File: MainWindow.java View source code
private void setWindowedMode() {
    this.setVisible(false);
    this.dispose();
    this.setUndecorated(false);
    this.setResizable(true);
    try {
        this.getContentPane().removeAll();
    } catch (Exception e) {
    }
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException ex) {
        LOG.error("Cannot find system look&feel\n", ex.toString());
    } catch (InstantiationException ex) {
        LOG.error("Cannot instantiate system look&feel\n", ex.toString());
    } catch (IllegalAccessException ex) {
        LOG.error("Illegal access to system look&feel\n", ex.toString());
    } catch (UnsupportedLookAndFeelException ex) {
        LOG.error("Unsupported system look&feel\n", ex.toString());
    }
    setDefaultLookAndFeelDecorated(true);
    initComponents();
    this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    setLayout(new BorderLayout());
    desktopPane = new JDesktopPane();
    lstClients = new PluginJList(this);
    frameClient = new JInternalFrame();
    frameClient.setLayout(new BorderLayout());
    JScrollPane clientScroll = new JScrollPane(lstClients);
    frameClient.add(clientScroll, BorderLayout.CENTER);
    frameClient.setTitle(i18n.msg("loaded_plugins"));
    frameClient.setResizable(true);
    frameClient.setMaximizable(true);
    frameMap = new JInternalFrame();
    setMapTitle("");
    frameMap.setMaximizable(true);
    frameMap.setResizable(true);
    desktopPane.add(frameMap);
    desktopPane.add(frameClient);
    frameClient.moveToFront();
    frameClient.setVisible(Auth.isPermitted("plugins:read"));
    desktopPane.moveToFront(this);
    this.getContentPane().add(desktopPane);
    try {
        frameClient.setSelected(true);
    } catch (PropertyVetoException ex) {
        LOG.error(Freedomotic.getStackTraceInfo(ex));
    }
    EnvironmentLogic previousEnv = api.environments().findAll().get(0);
    if (drawer != null) {
        previousEnv = drawer.getCurrEnv();
    }
    initializeRenderer(previousEnv);
    drawer = master.createRenderer(previousEnv);
    if (drawer != null) {
        setDrawer(drawer);
        ResourcesManager.clear();
    } else {
        LOG.error("Unable to create a drawer to render the environment on the desktop frontend");
    }
    this.setTitle("Freedomotic " + Info.getLicense() + " - www.freedomotic.com");
    this.setSize(1100, 700);
    centerFrame(this);
    frameClient.moveToFront();
    frameMap.moveToFront();
    optimizeFramesDimension();
    drawer.repaint();
    lstClients.update();
    frameClient.setVisible(Auth.isPermitted("plugins:read"));
    frameMap.setVisible(Auth.isPermitted("environments:read"));
    setEditMode(false);
    this.setVisible(true);
    isFullscreen = false;
}
Example 85
Project: mdrill-master  File: Main.java View source code
/**
   * initializes the GUI.
   */
protected void initGUI() {
    m_Self = this;
    try {
        // main window
        createTitle("");
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("weka/gui/weka_icon_new_48.png")).getImage());
        // bits and pieces
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".bif", "BIF Files (*.bif)"));
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".xml", "XML Files (*.xml)"));
        m_FileChooserPlot.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        m_FileChooserPlot.setMultiSelectionEnabled(true);
        m_FileChooserROC.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        // Desktop
        if (m_GUIType == GUI_MDI) {
            jDesktopPane = new BackgroundDesktopPane("weka/gui/images/weka_background.gif");
            jDesktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
            setContentPane(jDesktopPane);
        } else {
            jDesktopPane = null;
        }
        // Menu
        jMenuBar = new JMenuBar();
        setJMenuBar(jMenuBar);
        // Program
        jMenuProgram = new JMenu();
        jMenuBar.add(jMenuProgram);
        jMenuProgram.setText("Program");
        jMenuProgram.setMnemonic('P');
        // Program/Preferences
        // TODO: read all properties from all props file and display them
        /*
        jMenuItemProgramPreferences = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramPreferences);
        jMenuItemProgramPreferences.setText("Preferences");
        jMenuItemProgramPreferences.setMnemonic('P');
        jMenuItemProgramPreferences.addActionListener(new ActionListener() {
  	  public void actionPerformed(ActionEvent evt) {
	    System.out.println("jMenuItemProgramPreferences.actionPerformed, event="+evt);
	    //TODO add your code for jMenuItemProgramPreferences.actionPerformed
  	  }
        });
       */
        // Program/LogWindow
        jMenuItemProgramLogWindow = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramLogWindow);
        jMenuItemProgramLogWindow.setText("LogWindow");
        jMenuItemProgramLogWindow.setMnemonic('L');
        jMenuItemProgramLogWindow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                m_LogWindow.setVisible(true);
            }
        });
        jMenuItemProgramMemoryUsage = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramMemoryUsage);
        jMenuItemProgramMemoryUsage.setText("Memory usage");
        jMenuItemProgramMemoryUsage.setMnemonic('M');
        jMenuItemProgramMemoryUsage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemProgramMemoryUsage.getText();
                if (!containsWindow(title)) {
                    final MemoryUsagePanel panel = new MemoryUsagePanel();
                    Container c = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 400, 50, null, true, true);
                    // optimize size
                    Dimension size = c.getPreferredSize();
                    c.setSize(new Dimension((int) size.getWidth(), (int) size.getHeight()));
                    // stop threads
                    if (m_GUIType == GUI_MDI) {
                        final ChildFrameMDI frame = (ChildFrameMDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    } else {
                        final ChildFrameSDI frame = (ChildFrameSDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuProgram.add(new JSeparator());
        // Program/Exit
        jMenuItemProgramExit = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramExit);
        jMenuItemProgramExit.setText("Exit");
        jMenuItemProgramExit.setMnemonic('E');
        jMenuItemProgramExit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // close all children
                Iterator iter = getWindowList();
                Vector<Container> list = new Vector<Container>();
                while (iter.hasNext()) list.add((Container) 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);
            }
        });
        // Applications
        jMenuApplications = new JMenu();
        jMenuBar.add(jMenuApplications);
        jMenuApplications.setText("Applications");
        jMenuApplications.setMnemonic('A');
        // Applications/Explorer
        jMenuItemApplicationsExplorer = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExplorer);
        jMenuItemApplicationsExplorer.setText("Explorer");
        jMenuItemApplicationsExplorer.setMnemonic('E');
        jMenuItemApplicationsExplorer.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/Experimenter
        jMenuItemApplicationsExperimenter = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExperimenter);
        jMenuItemApplicationsExperimenter.setText("Experimenter");
        jMenuItemApplicationsExperimenter.setMnemonic('X');
        jMenuItemApplicationsExperimenter.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/KnowledgeFlow
        jMenuItemApplicationsKnowledgeFlow = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsKnowledgeFlow);
        jMenuItemApplicationsKnowledgeFlow.setText("KnowledgeFlow");
        jMenuItemApplicationsKnowledgeFlow.setMnemonic('K');
        jMenuItemApplicationsKnowledgeFlow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsKnowledgeFlow.getText();
                if (!containsWindow(title)) {
                    KnowledgeFlowApp.createSingleton(new String[0]);
                    createFrame(m_Self, title, KnowledgeFlowApp.getSingleton(), new BorderLayout(), BorderLayout.CENTER, 900, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Applications/SimpleCLI
        jMenuItemApplicationsSimpleCLI = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsSimpleCLI);
        jMenuItemApplicationsSimpleCLI.setText("SimpleCLI");
        jMenuItemApplicationsSimpleCLI.setMnemonic('S');
        jMenuItemApplicationsSimpleCLI.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsSimpleCLI.getText();
                if (!containsWindow(title)) {
                    try {
                        createFrame(m_Self, title, new SimpleCLIPanel(), new BorderLayout(), BorderLayout.CENTER, 600, 500, null, true, true);
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error instantiating SimpleCLI:\n" + e.getMessage());
                        return;
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools
        jMenuTools = new JMenu();
        jMenuBar.add(jMenuTools);
        jMenuTools.setText("Tools");
        jMenuTools.setMnemonic('T');
        // Tools/ArffViewer
        jMenuItemToolsArffViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsArffViewer);
        jMenuItemToolsArffViewer.setText("ArffViewer");
        jMenuItemToolsArffViewer.setMnemonic('A');
        jMenuItemToolsArffViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsArffViewer.getText();
                if (!containsWindow(title)) {
                    ArffViewerMainPanel panel = new ArffViewerMainPanel(null);
                    panel.setConfirmExit(false);
                    Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenu(), true, true);
                    panel.setParent(frame);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/SqlViewer
        jMenuItemToolsSqlViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsSqlViewer);
        jMenuItemToolsSqlViewer.setText("SqlViewer");
        jMenuItemToolsSqlViewer.setMnemonic('S');
        jMenuItemToolsSqlViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsSqlViewer.getText();
                if (!containsWindow(title)) {
                    final SqlViewer sql = new SqlViewer(null);
                    final Container frame = createFrame(m_Self, title, sql, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, false, true);
                    // custom listener
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                sql.saveSize();
                                ((ChildFrameMDI) frame).dispose();
                            }
                        });
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                sql.saveSize();
                                ((ChildFrameSDI) frame).dispose();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/Bayes net editor
        // Tools/Bayes net editor
        final JMenuItem jMenuItemBayesNet = new JMenuItem();
        jMenuTools.add(jMenuItemBayesNet);
        jMenuItemBayesNet.setText("Bayes net editor");
        jMenuItemBayesNet.setMnemonic('N');
        jMenuItemBayesNet.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                String title = jMenuItemBayesNet.getText();
                if (!containsWindow(title)) {
                    final GUI bayesNetGUI = new GUI();
                    final Container frame = createFrame(m_Self, title, bayesNetGUI, new BorderLayout(), BorderLayout.CENTER, 800, 600, bayesNetGUI.getMenuBar(), false, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/Groovy console
        if (Groovy.isPresent()) {
            jMenuItemToolsGroovyConsole = new JMenuItem();
            jMenuTools.add(jMenuItemToolsGroovyConsole);
            jMenuItemToolsGroovyConsole.setText("Groovy console");
            jMenuItemToolsGroovyConsole.setMnemonic('G');
            jMenuItemToolsGroovyConsole.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    String title = jMenuItemToolsGroovyConsole.getText();
                    if (!containsWindow(title)) {
                        final GroovyPanel panel = new GroovyPanel();
                        final Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenuBar(), false, true);
                        // custom listener
                        if (frame instanceof ChildFrameMDI) {
                            ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                                public void internalFrameClosing(InternalFrameEvent e) {
                                    ((ChildFrameMDI) frame).dispose();
                                }
                            });
                        } else if (frame instanceof ChildFrameSDI) {
                            ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                                public void windowClosing(WindowEvent e) {
                                    ((ChildFrameSDI) frame).dispose();
                                }
                            });
                        }
                    } else {
                        showWindow(getWindow(title));
                    }
                }
            });
        }
        // Tools/Jython console
        if (Jython.isPresent()) {
            jMenuItemToolsJythonConsole = new JMenuItem();
            jMenuTools.add(jMenuItemToolsJythonConsole);
            jMenuItemToolsJythonConsole.setText("Jython console");
            jMenuItemToolsJythonConsole.setMnemonic('J');
            jMenuItemToolsJythonConsole.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    String title = jMenuItemToolsJythonConsole.getText();
                    if (!containsWindow(title)) {
                        final JythonPanel panel = new JythonPanel();
                        final Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenuBar(), false, true);
                        // custom listener
                        if (frame instanceof ChildFrameMDI) {
                            ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                                public void internalFrameClosing(InternalFrameEvent e) {
                                    ((ChildFrameMDI) frame).dispose();
                                }
                            });
                        } else if (frame instanceof ChildFrameSDI) {
                            ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                                public void windowClosing(WindowEvent e) {
                                    ((ChildFrameSDI) frame).dispose();
                                }
                            });
                        }
                    } else {
                        showWindow(getWindow(title));
                    }
                }
            });
        }
        // Tools/EnsembleLibrary
        /* currently disabled due to bugs... FracPete
      jMenuItemToolsEnsembleLibrary = new JMenuItem();
      jMenuTools.add(jMenuItemToolsEnsembleLibrary);
      jMenuItemToolsEnsembleLibrary.setText("EnsembleLibrary");
      jMenuItemToolsEnsembleLibrary.setMnemonic('E');
      jMenuItemToolsEnsembleLibrary.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  String title = jMenuItemToolsEnsembleLibrary.getText();
	  if (!containsWindow(title)) {
	    EnsembleLibrary value = new EnsembleLibrary();
	    EnsembleLibraryEditor libraryEditor = new EnsembleLibraryEditor();
	    libraryEditor.setValue(value);
	    createFrame(
		m_Self, title, libraryEditor.getCustomEditor(), new BorderLayout(), 
		BorderLayout.CENTER, 800, 600, null, true, true);
	  }
	  else {
	    showWindow(getWindow(title));
	  }
	}
      });
      */
        // Visualization
        jMenuVisualization = new JMenu();
        jMenuBar.add(jMenuVisualization);
        jMenuVisualization.setText("Visualization");
        jMenuVisualization.setMnemonic('V');
        // Visualization/Plot
        jMenuItemVisualizationPlot = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationPlot);
        jMenuItemVisualizationPlot.setText("Plot");
        jMenuItemVisualizationPlot.setMnemonic('P');
        jMenuItemVisualizationPlot.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserPlot.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build plot
                VisualizePanel panel = new VisualizePanel();
                String filenames = "";
                File[] files = m_FileChooserPlot.getSelectedFiles();
                for (int j = 0; j < files.length; j++) {
                    String filename = files[j].getAbsolutePath();
                    if (j > 0)
                        filenames += ", ";
                    filenames += filename;
                    System.err.println("Loading instances from " + filename);
                    try {
                        Reader r = new java.io.BufferedReader(new FileReader(filename));
                        Instances i = new Instances(r);
                        i.setClassIndex(i.numAttributes() - 1);
                        PlotData2D pd1 = new PlotData2D(i);
                        if (j == 0) {
                            pd1.setPlotName("Master plot");
                            panel.setMasterPlot(pd1);
                        } else {
                            pd1.setPlotName("Plot " + (j + 1));
                            pd1.m_useCustomColour = true;
                            pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
                            panel.addPlot(pd1);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error loading file '" + files[j] + "':\n" + e.getMessage());
                        return;
                    }
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationPlot.getText() + " - " + filenames, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/ROC
        // based on this Wiki article:
        // http://weka.sourceforge.net/wiki/index.php/Visualizing_ROC_curve
        jMenuItemVisualizationROC = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationROC);
        jMenuItemVisualizationROC.setText("ROC");
        jMenuItemVisualizationROC.setMnemonic('R');
        jMenuItemVisualizationROC.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserROC.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // create plot
                String filename = m_FileChooserROC.getSelectedFile().getAbsolutePath();
                Instances result = null;
                try {
                    result = new Instances(new BufferedReader(new FileReader(filename)));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                result.setClassIndex(result.numAttributes() - 1);
                ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
                vmc.setROCString("(Area under ROC = " + Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
                vmc.setName(result.relationName());
                PlotData2D tempd = new PlotData2D(result);
                tempd.setPlotName(result.relationName());
                tempd.addInstanceNumberAttribute();
                try {
                    vmc.addPlot(tempd);
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error adding plot:\n" + e.getMessage());
                    return;
                }
                createFrame(m_Self, jMenuItemVisualizationROC.getText() + " - " + filename, vmc, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/TreeVisualizer
        jMenuItemVisualizationTreeVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationTreeVisualizer);
        jMenuItemVisualizationTreeVisualizer.setText("TreeVisualizer");
        jMenuItemVisualizationTreeVisualizer.setMnemonic('T');
        jMenuItemVisualizationTreeVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserTreeVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build tree
                String filename = m_FileChooserTreeVisualizer.getSelectedFile().getAbsolutePath();
                TreeBuild builder = new TreeBuild();
                Node top = null;
                NodePlace arrange = new PlaceNode2();
                try {
                    top = builder.create(new FileReader(filename));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationTreeVisualizer.getText() + " - " + filename, new TreeVisualizer(null, top, arrange), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/GraphVisualizer
        jMenuItemVisualizationGraphVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationGraphVisualizer);
        jMenuItemVisualizationGraphVisualizer.setText("GraphVisualizer");
        jMenuItemVisualizationGraphVisualizer.setMnemonic('G');
        jMenuItemVisualizationGraphVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserGraphVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build graph
                String filename = m_FileChooserGraphVisualizer.getSelectedFile().getAbsolutePath();
                GraphVisualizer panel = new GraphVisualizer();
                try {
                    if (filename.toLowerCase().endsWith(".xml") || filename.toLowerCase().endsWith(".bif")) {
                        panel.readBIF(new FileInputStream(filename));
                    } else {
                        panel.readDOT(new FileReader(filename));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationGraphVisualizer.getText() + " - " + filename, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/BoundaryVisualizer
        jMenuItemVisualizationBoundaryVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationBoundaryVisualizer);
        jMenuItemVisualizationBoundaryVisualizer.setText("BoundaryVisualizer");
        jMenuItemVisualizationBoundaryVisualizer.setMnemonic('B');
        jMenuItemVisualizationBoundaryVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemVisualizationBoundaryVisualizer.getText();
                if (!containsWindow(title)) {
                    createFrame(m_Self, title, new BoundaryVisualizer(), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                    // dont' do a System.exit after last window got closed!
                    BoundaryVisualizer.setExitIfNoWindowsOpen(false);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Extensions
        jMenuExtensions = new JMenu("Extensions");
        jMenuExtensions.setMnemonic(java.awt.event.KeyEvent.VK_E);
        jMenuBar.add(jMenuExtensions);
        jMenuExtensions.setVisible(false);
        String extensions = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "");
        if (extensions.length() > 0) {
            jMenuExtensions.setVisible(true);
            String[] classnames = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "").split(",");
            Hashtable<String, JMenu> submenus = new Hashtable<String, JMenu>();
            // add all extensions
            for (int i = 0; i < classnames.length; i++) {
                String classname = classnames[i];
                try {
                    MainMenuExtension ext = (MainMenuExtension) Class.forName(classname).newInstance();
                    // menuitem in a submenu?
                    JMenu submenu = null;
                    if (ext.getSubmenuTitle() != null) {
                        submenu = submenus.get(ext.getSubmenuTitle());
                        if (submenu == null) {
                            submenu = new JMenu(ext.getSubmenuTitle());
                            submenus.put(ext.getSubmenuTitle(), submenu);
                            insertMenuItem(jMenuExtensions, submenu);
                        }
                    }
                    // create menu item
                    JMenuItem menuitem = new JMenuItem();
                    menuitem.setText(ext.getMenuTitle());
                    // does the extension need a frame or does it have its own ActionListener?
                    ActionListener listener = ext.getActionListener(m_Self);
                    if (listener != null) {
                        menuitem.addActionListener(listener);
                    } else {
                        final JMenuItem finalMenuitem = menuitem;
                        final MainMenuExtension finalExt = ext;
                        menuitem.addActionListener(new ActionListener() {

                            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);
                            }
                        });
                    }
                    // sorted insert of menu item
                    if (submenu != null)
                        insertMenuItem(submenu, menuitem);
                    else
                        insertMenuItem(jMenuExtensions, menuitem);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        // Windows
        jMenuWindows = new JMenu("Windows");
        jMenuWindows.setMnemonic(java.awt.event.KeyEvent.VK_W);
        jMenuBar.add(jMenuWindows);
        // initially, there are no windows open
        jMenuWindows.setVisible(false);
        // Help
        jMenuHelp = new JMenu();
        jMenuBar.add(jMenuHelp);
        jMenuHelp.setText("Help");
        jMenuHelp.setMnemonic('H');
        // Help/Homepage
        jMenuItemHelpHomepage = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpHomepage);
        jMenuItemHelpHomepage.setText("Weka homepage");
        jMenuItemHelpHomepage.setMnemonic('H');
        jMenuItemHelpHomepage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://www.cs.waikato.ac.nz/~ml/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        /*      // Help/WekaDoc
      jMenuItemHelpWekaDoc = new JMenuItem();
      jMenuHelp.add(jMenuItemHelpWekaDoc);
      jMenuItemHelpWekaDoc.setText("Online documentation");
      jMenuItemHelpWekaDoc.setMnemonic('D');
      jMenuItemHelpWekaDoc.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  BrowserHelper.openURL(m_Self, "http://weka.sourceforge.net/wekadoc/");
	}
      }); */
        // Help/WekaWiki
        jMenuItemHelpWekaWiki = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpWekaWiki);
        jMenuItemHelpWekaWiki.setText("HOWTOs, code snippets, etc.");
        jMenuItemHelpWekaWiki.setMnemonic('W');
        jMenuItemHelpWekaWiki.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://weka.wikispaces.com/");
            }
        });
        // Help/Sourceforge
        jMenuItemHelpSourceforge = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSourceforge);
        jMenuItemHelpSourceforge.setText("Weka on SourceForge");
        jMenuItemHelpSourceforge.setMnemonic('F');
        jMenuItemHelpSourceforge.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://sourceforge.net/projects/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/SystemInfo
        jMenuItemHelpSystemInfo = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSystemInfo);
        jMenuItemHelpSystemInfo.setText("SystemInfo");
        jMenuItemHelpHomepage.setMnemonic('S');
        jMenuItemHelpSystemInfo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpSystemInfo.getText();
                if (!containsWindow(title)) {
                    // get info
                    Hashtable info = new SystemInfo().getSystemInfo();
                    // sort names
                    Vector names = new Vector();
                    Enumeration enm = info.keys();
                    while (enm.hasMoreElements()) names.add(enm.nextElement());
                    Collections.sort(names);
                    // generate table
                    String[][] data = new String[info.size()][2];
                    for (int i = 0; i < names.size(); i++) {
                        data[i][0] = names.get(i).toString();
                        data[i][1] = info.get(data[i][0]).toString();
                    }
                    String[] titles = new String[] { "Key", "Value" };
                    JTable table = new JTable(data, titles);
                    createFrame(m_Self, title, new JScrollPane(table), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/About
        jMenuItemHelpAbout = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpAbout);
        jMenuItemHelpAbout.setText("About");
        jMenuItemHelpAbout.setMnemonic('A');
        jMenuItemHelpAbout.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpAbout.getText();
                if (!containsWindow(title)) {
                    JPanel wekaPan = new JPanel();
                    wekaPan.setToolTipText("Weka, a native bird of New Zealand");
                    ImageIcon wii = new ImageIcon(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("weka/gui/weka3.gif")));
                    JLabel wekaLab = new JLabel(wii);
                    wekaPan.add(wekaLab);
                    Container frame = createFrame(m_Self, title, wekaPan, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, true, true);
                    JPanel titlePan = new JPanel();
                    titlePan.setLayout(new GridLayout(8, 1));
                    titlePan.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
                    titlePan.add(new JLabel("Waikato Environment for", SwingConstants.CENTER));
                    titlePan.add(new JLabel("Knowledge Analysis", SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("Version " + Version.VERSION, SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("(c) " + Copyright.getFromYear() + " - " + Copyright.getToYear(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getOwner(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getAddress(), SwingConstants.CENTER));
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameMDI) frame).pack();
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameSDI) frame).pack();
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // size + position
        int screenHeight = getGraphicsConfiguration().getBounds().height;
        int screenWidth = getGraphicsConfiguration().getBounds().width;
        if (m_GUIType == GUI_MDI) {
            int newHeight = (int) (((double) screenHeight) * 0.75);
            int newWidth = (int) (((double) screenWidth) * 0.75);
            setSize(1000 > newWidth ? newWidth : 1000, 800 > newHeight ? newHeight : 800);
            setLocation((screenWidth - getBounds().width) / 2, (screenHeight - getBounds().height) / 2);
        } else if (m_GUIType == GUI_SDI) {
            pack();
            setSize(screenWidth, getHeight());
            setLocation(0, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 86
Project: MGPWeka-master  File: Main.java View source code
/**
   * initializes the GUI.
   */
protected void initGUI() {
    m_Self = this;
    try {
        // main window
        createTitle("");
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("weka/gui/weka_icon_new_48.png")).getImage());
        // bits and pieces
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".bif", "BIF Files (*.bif)"));
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".xml", "XML Files (*.xml)"));
        m_FileChooserPlot.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        m_FileChooserPlot.setMultiSelectionEnabled(true);
        m_FileChooserROC.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        // Desktop
        if (m_GUIType == GUI_MDI) {
            jDesktopPane = new BackgroundDesktopPane("weka/gui/images/weka_background.gif");
            jDesktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
            setContentPane(jDesktopPane);
        } else {
            jDesktopPane = null;
        }
        // Menu
        jMenuBar = new JMenuBar();
        setJMenuBar(jMenuBar);
        // Program
        jMenuProgram = new JMenu();
        jMenuBar.add(jMenuProgram);
        jMenuProgram.setText("Program");
        jMenuProgram.setMnemonic('P');
        // Program/Preferences
        // TODO: read all properties from all props file and display them
        /*
        jMenuItemProgramPreferences = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramPreferences);
        jMenuItemProgramPreferences.setText("Preferences");
        jMenuItemProgramPreferences.setMnemonic('P');
        jMenuItemProgramPreferences.addActionListener(new ActionListener() {
  	  public void actionPerformed(ActionEvent evt) {
	    System.out.println("jMenuItemProgramPreferences.actionPerformed, event="+evt);
	    //TODO add your code for jMenuItemProgramPreferences.actionPerformed
  	  }
        });
       */
        // Program/LogWindow
        jMenuItemProgramLogWindow = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramLogWindow);
        jMenuItemProgramLogWindow.setText("LogWindow");
        jMenuItemProgramLogWindow.setMnemonic('L');
        jMenuItemProgramLogWindow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                m_LogWindow.setVisible(true);
            }
        });
        jMenuItemProgramMemoryUsage = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramMemoryUsage);
        jMenuItemProgramMemoryUsage.setText("Memory usage");
        jMenuItemProgramMemoryUsage.setMnemonic('M');
        jMenuItemProgramMemoryUsage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemProgramMemoryUsage.getText();
                if (!containsWindow(title)) {
                    final MemoryUsagePanel panel = new MemoryUsagePanel();
                    Container c = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 400, 50, null, true, true);
                    // optimize size
                    Dimension size = c.getPreferredSize();
                    c.setSize(new Dimension((int) size.getWidth(), (int) size.getHeight()));
                    // stop threads
                    if (m_GUIType == GUI_MDI) {
                        final ChildFrameMDI frame = (ChildFrameMDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    } else {
                        final ChildFrameSDI frame = (ChildFrameSDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuProgram.add(new JSeparator());
        // Program/Exit
        jMenuItemProgramExit = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramExit);
        jMenuItemProgramExit.setText("Exit");
        jMenuItemProgramExit.setMnemonic('E');
        jMenuItemProgramExit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // close all children
                Iterator iter = getWindowList();
                Vector<Container> list = new Vector<Container>();
                while (iter.hasNext()) list.add((Container) 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);
            }
        });
        // Applications
        jMenuApplications = new JMenu();
        jMenuBar.add(jMenuApplications);
        jMenuApplications.setText("Applications");
        jMenuApplications.setMnemonic('A');
        // Applications/Explorer
        jMenuItemApplicationsExplorer = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExplorer);
        jMenuItemApplicationsExplorer.setText("Explorer");
        jMenuItemApplicationsExplorer.setMnemonic('E');
        jMenuItemApplicationsExplorer.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/Experimenter
        jMenuItemApplicationsExperimenter = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExperimenter);
        jMenuItemApplicationsExperimenter.setText("Experimenter");
        jMenuItemApplicationsExperimenter.setMnemonic('X');
        jMenuItemApplicationsExperimenter.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/KnowledgeFlow
        jMenuItemApplicationsKnowledgeFlow = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsKnowledgeFlow);
        jMenuItemApplicationsKnowledgeFlow.setText("KnowledgeFlow");
        jMenuItemApplicationsKnowledgeFlow.setMnemonic('K');
        jMenuItemApplicationsKnowledgeFlow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsKnowledgeFlow.getText();
                if (!containsWindow(title)) {
                    KnowledgeFlowApp.createSingleton(new String[0]);
                    createFrame(m_Self, title, KnowledgeFlowApp.getSingleton(), new BorderLayout(), BorderLayout.CENTER, 900, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Applications/SimpleCLI
        jMenuItemApplicationsSimpleCLI = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsSimpleCLI);
        jMenuItemApplicationsSimpleCLI.setText("SimpleCLI");
        jMenuItemApplicationsSimpleCLI.setMnemonic('S');
        jMenuItemApplicationsSimpleCLI.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsSimpleCLI.getText();
                if (!containsWindow(title)) {
                    try {
                        createFrame(m_Self, title, new SimpleCLIPanel(), new BorderLayout(), BorderLayout.CENTER, 600, 500, null, true, true);
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error instantiating SimpleCLI:\n" + e.getMessage());
                        return;
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools
        jMenuTools = new JMenu();
        jMenuBar.add(jMenuTools);
        jMenuTools.setText("Tools");
        jMenuTools.setMnemonic('T');
        // Tools/ArffViewer
        jMenuItemToolsArffViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsArffViewer);
        jMenuItemToolsArffViewer.setText("ArffViewer");
        jMenuItemToolsArffViewer.setMnemonic('A');
        jMenuItemToolsArffViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsArffViewer.getText();
                if (!containsWindow(title)) {
                    ArffViewerMainPanel panel = new ArffViewerMainPanel(null);
                    panel.setConfirmExit(false);
                    Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenu(), true, true);
                    panel.setParent(frame);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/SqlViewer
        jMenuItemToolsSqlViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsSqlViewer);
        jMenuItemToolsSqlViewer.setText("SqlViewer");
        jMenuItemToolsSqlViewer.setMnemonic('S');
        jMenuItemToolsSqlViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsSqlViewer.getText();
                if (!containsWindow(title)) {
                    final SqlViewer sql = new SqlViewer(null);
                    final Container frame = createFrame(m_Self, title, sql, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, false, true);
                    // custom listener
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                sql.saveSize();
                                ((ChildFrameMDI) frame).dispose();
                            }
                        });
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                sql.saveSize();
                                ((ChildFrameSDI) frame).dispose();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/Bayes net editor
        // Tools/Bayes net editor
        final JMenuItem jMenuItemBayesNet = new JMenuItem();
        jMenuTools.add(jMenuItemBayesNet);
        jMenuItemBayesNet.setText("Bayes net editor");
        jMenuItemBayesNet.setMnemonic('N');
        jMenuItemBayesNet.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                String title = jMenuItemBayesNet.getText();
                if (!containsWindow(title)) {
                    final GUI bayesNetGUI = new GUI();
                    final Container frame = createFrame(m_Self, title, bayesNetGUI, new BorderLayout(), BorderLayout.CENTER, 800, 600, bayesNetGUI.getMenuBar(), false, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/Groovy console
        if (Groovy.isPresent()) {
            jMenuItemToolsGroovyConsole = new JMenuItem();
            jMenuTools.add(jMenuItemToolsGroovyConsole);
            jMenuItemToolsGroovyConsole.setText("Groovy console");
            jMenuItemToolsGroovyConsole.setMnemonic('G');
            jMenuItemToolsGroovyConsole.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    String title = jMenuItemToolsGroovyConsole.getText();
                    if (!containsWindow(title)) {
                        final GroovyPanel panel = new GroovyPanel();
                        final Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenuBar(), false, true);
                        // custom listener
                        if (frame instanceof ChildFrameMDI) {
                            ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                                public void internalFrameClosing(InternalFrameEvent e) {
                                    ((ChildFrameMDI) frame).dispose();
                                }
                            });
                        } else if (frame instanceof ChildFrameSDI) {
                            ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                                public void windowClosing(WindowEvent e) {
                                    ((ChildFrameSDI) frame).dispose();
                                }
                            });
                        }
                    } else {
                        showWindow(getWindow(title));
                    }
                }
            });
        }
        // Tools/Jython console
        if (Jython.isPresent()) {
            jMenuItemToolsJythonConsole = new JMenuItem();
            jMenuTools.add(jMenuItemToolsJythonConsole);
            jMenuItemToolsJythonConsole.setText("Jython console");
            jMenuItemToolsJythonConsole.setMnemonic('J');
            jMenuItemToolsJythonConsole.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    String title = jMenuItemToolsJythonConsole.getText();
                    if (!containsWindow(title)) {
                        final JythonPanel panel = new JythonPanel();
                        final Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenuBar(), false, true);
                        // custom listener
                        if (frame instanceof ChildFrameMDI) {
                            ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                                public void internalFrameClosing(InternalFrameEvent e) {
                                    ((ChildFrameMDI) frame).dispose();
                                }
                            });
                        } else if (frame instanceof ChildFrameSDI) {
                            ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                                public void windowClosing(WindowEvent e) {
                                    ((ChildFrameSDI) frame).dispose();
                                }
                            });
                        }
                    } else {
                        showWindow(getWindow(title));
                    }
                }
            });
        }
        // Tools/EnsembleLibrary
        /* currently disabled due to bugs... FracPete
      jMenuItemToolsEnsembleLibrary = new JMenuItem();
      jMenuTools.add(jMenuItemToolsEnsembleLibrary);
      jMenuItemToolsEnsembleLibrary.setText("EnsembleLibrary");
      jMenuItemToolsEnsembleLibrary.setMnemonic('E');
      jMenuItemToolsEnsembleLibrary.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  String title = jMenuItemToolsEnsembleLibrary.getText();
	  if (!containsWindow(title)) {
	    EnsembleLibrary value = new EnsembleLibrary();
	    EnsembleLibraryEditor libraryEditor = new EnsembleLibraryEditor();
	    libraryEditor.setValue(value);
	    createFrame(
		m_Self, title, libraryEditor.getCustomEditor(), new BorderLayout(), 
		BorderLayout.CENTER, 800, 600, null, true, true);
	  }
	  else {
	    showWindow(getWindow(title));
	  }
	}
      });
      */
        // Visualization
        jMenuVisualization = new JMenu();
        jMenuBar.add(jMenuVisualization);
        jMenuVisualization.setText("Visualization");
        jMenuVisualization.setMnemonic('V');
        // Visualization/Plot
        jMenuItemVisualizationPlot = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationPlot);
        jMenuItemVisualizationPlot.setText("Plot");
        jMenuItemVisualizationPlot.setMnemonic('P');
        jMenuItemVisualizationPlot.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserPlot.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build plot
                VisualizePanel panel = new VisualizePanel();
                String filenames = "";
                File[] files = m_FileChooserPlot.getSelectedFiles();
                for (int j = 0; j < files.length; j++) {
                    String filename = files[j].getAbsolutePath();
                    if (j > 0)
                        filenames += ", ";
                    filenames += filename;
                    System.err.println("Loading instances from " + filename);
                    try {
                        Reader r = new java.io.BufferedReader(new FileReader(filename));
                        Instances i = new Instances(r);
                        i.setClassIndex(i.numAttributes() - 1);
                        PlotData2D pd1 = new PlotData2D(i);
                        if (j == 0) {
                            pd1.setPlotName("Master plot");
                            panel.setMasterPlot(pd1);
                        } else {
                            pd1.setPlotName("Plot " + (j + 1));
                            pd1.m_useCustomColour = true;
                            pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
                            panel.addPlot(pd1);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error loading file '" + files[j] + "':\n" + e.getMessage());
                        return;
                    }
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationPlot.getText() + " - " + filenames, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/ROC
        // based on this Wiki article:
        // http://weka.sourceforge.net/wiki/index.php/Visualizing_ROC_curve
        jMenuItemVisualizationROC = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationROC);
        jMenuItemVisualizationROC.setText("ROC");
        jMenuItemVisualizationROC.setMnemonic('R');
        jMenuItemVisualizationROC.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserROC.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // create plot
                String filename = m_FileChooserROC.getSelectedFile().getAbsolutePath();
                Instances result = null;
                try {
                    result = new Instances(new BufferedReader(new FileReader(filename)));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                result.setClassIndex(result.numAttributes() - 1);
                ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
                vmc.setROCString("(Area under ROC = " + Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
                vmc.setName(result.relationName());
                PlotData2D tempd = new PlotData2D(result);
                tempd.setPlotName(result.relationName());
                tempd.addInstanceNumberAttribute();
                try {
                    vmc.addPlot(tempd);
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error adding plot:\n" + e.getMessage());
                    return;
                }
                createFrame(m_Self, jMenuItemVisualizationROC.getText() + " - " + filename, vmc, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/TreeVisualizer
        jMenuItemVisualizationTreeVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationTreeVisualizer);
        jMenuItemVisualizationTreeVisualizer.setText("TreeVisualizer");
        jMenuItemVisualizationTreeVisualizer.setMnemonic('T');
        jMenuItemVisualizationTreeVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserTreeVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build tree
                String filename = m_FileChooserTreeVisualizer.getSelectedFile().getAbsolutePath();
                TreeBuild builder = new TreeBuild();
                Node top = null;
                NodePlace arrange = new PlaceNode2();
                try {
                    top = builder.create(new FileReader(filename));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationTreeVisualizer.getText() + " - " + filename, new TreeVisualizer(null, top, arrange), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/GraphVisualizer
        jMenuItemVisualizationGraphVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationGraphVisualizer);
        jMenuItemVisualizationGraphVisualizer.setText("GraphVisualizer");
        jMenuItemVisualizationGraphVisualizer.setMnemonic('G');
        jMenuItemVisualizationGraphVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserGraphVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build graph
                String filename = m_FileChooserGraphVisualizer.getSelectedFile().getAbsolutePath();
                GraphVisualizer panel = new GraphVisualizer();
                try {
                    if (filename.toLowerCase().endsWith(".xml") || filename.toLowerCase().endsWith(".bif")) {
                        panel.readBIF(new FileInputStream(filename));
                    } else {
                        panel.readDOT(new FileReader(filename));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationGraphVisualizer.getText() + " - " + filename, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/BoundaryVisualizer
        jMenuItemVisualizationBoundaryVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationBoundaryVisualizer);
        jMenuItemVisualizationBoundaryVisualizer.setText("BoundaryVisualizer");
        jMenuItemVisualizationBoundaryVisualizer.setMnemonic('B');
        jMenuItemVisualizationBoundaryVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemVisualizationBoundaryVisualizer.getText();
                if (!containsWindow(title)) {
                    createFrame(m_Self, title, new BoundaryVisualizer(), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                    // dont' do a System.exit after last window got closed!
                    BoundaryVisualizer.setExitIfNoWindowsOpen(false);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Extensions
        jMenuExtensions = new JMenu("Extensions");
        jMenuExtensions.setMnemonic(java.awt.event.KeyEvent.VK_E);
        jMenuBar.add(jMenuExtensions);
        jMenuExtensions.setVisible(false);
        String extensions = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "");
        if (extensions.length() > 0) {
            jMenuExtensions.setVisible(true);
            String[] classnames = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "").split(",");
            Hashtable<String, JMenu> submenus = new Hashtable<String, JMenu>();
            // add all extensions
            for (int i = 0; i < classnames.length; i++) {
                String classname = classnames[i];
                try {
                    MainMenuExtension ext = (MainMenuExtension) Class.forName(classname).newInstance();
                    // menuitem in a submenu?
                    JMenu submenu = null;
                    if (ext.getSubmenuTitle() != null) {
                        submenu = submenus.get(ext.getSubmenuTitle());
                        if (submenu == null) {
                            submenu = new JMenu(ext.getSubmenuTitle());
                            submenus.put(ext.getSubmenuTitle(), submenu);
                            insertMenuItem(jMenuExtensions, submenu);
                        }
                    }
                    // create menu item
                    JMenuItem menuitem = new JMenuItem();
                    menuitem.setText(ext.getMenuTitle());
                    // does the extension need a frame or does it have its own ActionListener?
                    ActionListener listener = ext.getActionListener(m_Self);
                    if (listener != null) {
                        menuitem.addActionListener(listener);
                    } else {
                        final JMenuItem finalMenuitem = menuitem;
                        final MainMenuExtension finalExt = ext;
                        menuitem.addActionListener(new ActionListener() {

                            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);
                            }
                        });
                    }
                    // sorted insert of menu item
                    if (submenu != null)
                        insertMenuItem(submenu, menuitem);
                    else
                        insertMenuItem(jMenuExtensions, menuitem);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        // Windows
        jMenuWindows = new JMenu("Windows");
        jMenuWindows.setMnemonic(java.awt.event.KeyEvent.VK_W);
        jMenuBar.add(jMenuWindows);
        // initially, there are no windows open
        jMenuWindows.setVisible(false);
        // Help
        jMenuHelp = new JMenu();
        jMenuBar.add(jMenuHelp);
        jMenuHelp.setText("Help");
        jMenuHelp.setMnemonic('H');
        // Help/Homepage
        jMenuItemHelpHomepage = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpHomepage);
        jMenuItemHelpHomepage.setText("Weka homepage");
        jMenuItemHelpHomepage.setMnemonic('H');
        jMenuItemHelpHomepage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://www.cs.waikato.ac.nz/~ml/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        /*      // Help/WekaDoc
      jMenuItemHelpWekaDoc = new JMenuItem();
      jMenuHelp.add(jMenuItemHelpWekaDoc);
      jMenuItemHelpWekaDoc.setText("Online documentation");
      jMenuItemHelpWekaDoc.setMnemonic('D');
      jMenuItemHelpWekaDoc.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  BrowserHelper.openURL(m_Self, "http://weka.sourceforge.net/wekadoc/");
	}
      }); */
        // Help/WekaWiki
        jMenuItemHelpWekaWiki = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpWekaWiki);
        jMenuItemHelpWekaWiki.setText("HOWTOs, code snippets, etc.");
        jMenuItemHelpWekaWiki.setMnemonic('W');
        jMenuItemHelpWekaWiki.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://weka.wikispaces.com/");
            }
        });
        // Help/Sourceforge
        jMenuItemHelpSourceforge = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSourceforge);
        jMenuItemHelpSourceforge.setText("Weka on SourceForge");
        jMenuItemHelpSourceforge.setMnemonic('F');
        jMenuItemHelpSourceforge.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://sourceforge.net/projects/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/SystemInfo
        jMenuItemHelpSystemInfo = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSystemInfo);
        jMenuItemHelpSystemInfo.setText("SystemInfo");
        jMenuItemHelpHomepage.setMnemonic('S');
        jMenuItemHelpSystemInfo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpSystemInfo.getText();
                if (!containsWindow(title)) {
                    // get info
                    Hashtable info = new SystemInfo().getSystemInfo();
                    // sort names
                    Vector names = new Vector();
                    Enumeration enm = info.keys();
                    while (enm.hasMoreElements()) names.add(enm.nextElement());
                    Collections.sort(names);
                    // generate table
                    String[][] data = new String[info.size()][2];
                    for (int i = 0; i < names.size(); i++) {
                        data[i][0] = names.get(i).toString();
                        data[i][1] = info.get(data[i][0]).toString();
                    }
                    String[] titles = new String[] { "Key", "Value" };
                    JTable table = new JTable(data, titles);
                    createFrame(m_Self, title, new JScrollPane(table), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/About
        jMenuItemHelpAbout = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpAbout);
        jMenuItemHelpAbout.setText("About");
        jMenuItemHelpAbout.setMnemonic('A');
        jMenuItemHelpAbout.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpAbout.getText();
                if (!containsWindow(title)) {
                    JPanel wekaPan = new JPanel();
                    wekaPan.setToolTipText("Weka, a native bird of New Zealand");
                    ImageIcon wii = new ImageIcon(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("weka/gui/weka3.gif")));
                    JLabel wekaLab = new JLabel(wii);
                    wekaPan.add(wekaLab);
                    Container frame = createFrame(m_Self, title, wekaPan, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, true, true);
                    JPanel titlePan = new JPanel();
                    titlePan.setLayout(new GridLayout(8, 1));
                    titlePan.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
                    titlePan.add(new JLabel("Waikato Environment for", SwingConstants.CENTER));
                    titlePan.add(new JLabel("Knowledge Analysis", SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("Version " + Version.VERSION, SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("(c) " + Copyright.getFromYear() + " - " + Copyright.getToYear(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getOwner(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getAddress(), SwingConstants.CENTER));
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameMDI) frame).pack();
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameSDI) frame).pack();
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // size + position
        int screenHeight = getGraphicsConfiguration().getBounds().height;
        int screenWidth = getGraphicsConfiguration().getBounds().width;
        if (m_GUIType == GUI_MDI) {
            int newHeight = (int) (((double) screenHeight) * 0.75);
            int newWidth = (int) (((double) screenWidth) * 0.75);
            setSize(1000 > newWidth ? newWidth : 1000, 800 > newHeight ? newHeight : 800);
            setLocation((screenWidth - getBounds().width) / 2, (screenHeight - getBounds().height) / 2);
        } else if (m_GUIType == GUI_SDI) {
            pack();
            setSize(screenWidth, getHeight());
            setLocation(0, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 87
Project: sad-analyzer-master  File: Main.java View source code
/**
   * initializes the GUI.
   */
protected void initGUI() {
    m_Self = this;
    try {
        // main window
        createTitle("");
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("weka/gui/weka_icon_new_48.png")).getImage());
        // bits and pieces
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".bif", "BIF Files (*.bif)"));
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".xml", "XML Files (*.xml)"));
        m_FileChooserPlot.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        m_FileChooserPlot.setMultiSelectionEnabled(true);
        m_FileChooserROC.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        // Desktop
        if (m_GUIType == GUI_MDI) {
            jDesktopPane = new BackgroundDesktopPane("weka/gui/images/weka_background.gif");
            jDesktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
            setContentPane(jDesktopPane);
        } else {
            jDesktopPane = null;
        }
        // Menu
        jMenuBar = new JMenuBar();
        setJMenuBar(jMenuBar);
        // Program
        jMenuProgram = new JMenu();
        jMenuBar.add(jMenuProgram);
        jMenuProgram.setText("Program");
        jMenuProgram.setMnemonic('P');
        // Program/Preferences
        // TODO: read all properties from all props file and display them
        /*
        jMenuItemProgramPreferences = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramPreferences);
        jMenuItemProgramPreferences.setText("Preferences");
        jMenuItemProgramPreferences.setMnemonic('P');
        jMenuItemProgramPreferences.addActionListener(new ActionListener() {
  	  public void actionPerformed(ActionEvent evt) {
	    System.out.println("jMenuItemProgramPreferences.actionPerformed, event="+evt);
	    //TODO add your code for jMenuItemProgramPreferences.actionPerformed
  	  }
        });
       */
        // Program/LogWindow
        jMenuItemProgramLogWindow = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramLogWindow);
        jMenuItemProgramLogWindow.setText("LogWindow");
        jMenuItemProgramLogWindow.setMnemonic('L');
        jMenuItemProgramLogWindow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                m_LogWindow.setVisible(true);
            }
        });
        jMenuItemProgramMemoryUsage = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramMemoryUsage);
        jMenuItemProgramMemoryUsage.setText("Memory usage");
        jMenuItemProgramMemoryUsage.setMnemonic('M');
        jMenuItemProgramMemoryUsage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemProgramMemoryUsage.getText();
                if (!containsWindow(title)) {
                    final MemoryUsagePanel panel = new MemoryUsagePanel();
                    Container c = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 400, 50, null, true, true);
                    // optimize size
                    Dimension size = c.getPreferredSize();
                    c.setSize(new Dimension((int) size.getWidth(), (int) size.getHeight()));
                    // stop threads
                    if (m_GUIType == GUI_MDI) {
                        final ChildFrameMDI frame = (ChildFrameMDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    } else {
                        final ChildFrameSDI frame = (ChildFrameSDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuProgram.add(new JSeparator());
        // Program/Exit
        jMenuItemProgramExit = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramExit);
        jMenuItemProgramExit.setText("Exit");
        jMenuItemProgramExit.setMnemonic('E');
        jMenuItemProgramExit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // close all children
                Iterator iter = getWindowList();
                Vector<Container> list = new Vector<Container>();
                while (iter.hasNext()) list.add((Container) 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);
            }
        });
        // Applications
        jMenuApplications = new JMenu();
        jMenuBar.add(jMenuApplications);
        jMenuApplications.setText("Applications");
        jMenuApplications.setMnemonic('A');
        // Applications/Explorer
        jMenuItemApplicationsExplorer = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExplorer);
        jMenuItemApplicationsExplorer.setText("Explorer");
        jMenuItemApplicationsExplorer.setMnemonic('E');
        jMenuItemApplicationsExplorer.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/Experimenter
        jMenuItemApplicationsExperimenter = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExperimenter);
        jMenuItemApplicationsExperimenter.setText("Experimenter");
        jMenuItemApplicationsExperimenter.setMnemonic('X');
        jMenuItemApplicationsExperimenter.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/KnowledgeFlow
        jMenuItemApplicationsKnowledgeFlow = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsKnowledgeFlow);
        jMenuItemApplicationsKnowledgeFlow.setText("KnowledgeFlow");
        jMenuItemApplicationsKnowledgeFlow.setMnemonic('K');
        jMenuItemApplicationsKnowledgeFlow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsKnowledgeFlow.getText();
                if (!containsWindow(title)) {
                    KnowledgeFlowApp.createSingleton(new String[0]);
                    createFrame(m_Self, title, KnowledgeFlowApp.getSingleton(), new BorderLayout(), BorderLayout.CENTER, 900, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Applications/SimpleCLI
        jMenuItemApplicationsSimpleCLI = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsSimpleCLI);
        jMenuItemApplicationsSimpleCLI.setText("SimpleCLI");
        jMenuItemApplicationsSimpleCLI.setMnemonic('S');
        jMenuItemApplicationsSimpleCLI.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsSimpleCLI.getText();
                if (!containsWindow(title)) {
                    try {
                        createFrame(m_Self, title, new SimpleCLIPanel(), new BorderLayout(), BorderLayout.CENTER, 600, 500, null, true, true);
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error instantiating SimpleCLI:\n" + e.getMessage());
                        return;
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools
        jMenuTools = new JMenu();
        jMenuBar.add(jMenuTools);
        jMenuTools.setText("Tools");
        jMenuTools.setMnemonic('T');
        // Tools/ArffViewer
        jMenuItemToolsArffViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsArffViewer);
        jMenuItemToolsArffViewer.setText("ArffViewer");
        jMenuItemToolsArffViewer.setMnemonic('A');
        jMenuItemToolsArffViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsArffViewer.getText();
                if (!containsWindow(title)) {
                    ArffViewerMainPanel panel = new ArffViewerMainPanel(null);
                    panel.setConfirmExit(false);
                    Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenu(), true, true);
                    panel.setParent(frame);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/SqlViewer
        jMenuItemToolsSqlViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsSqlViewer);
        jMenuItemToolsSqlViewer.setText("SqlViewer");
        jMenuItemToolsSqlViewer.setMnemonic('S');
        jMenuItemToolsSqlViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsSqlViewer.getText();
                if (!containsWindow(title)) {
                    final SqlViewer sql = new SqlViewer(null);
                    final Container frame = createFrame(m_Self, title, sql, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, false, true);
                    // custom listener
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                sql.saveSize();
                                ((ChildFrameMDI) frame).dispose();
                            }
                        });
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                sql.saveSize();
                                ((ChildFrameSDI) frame).dispose();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/Bayes net editor
        // Tools/Bayes net editor
        final JMenuItem jMenuItemBayesNet = new JMenuItem();
        jMenuTools.add(jMenuItemBayesNet);
        jMenuItemBayesNet.setText("Bayes net editor");
        jMenuItemBayesNet.setMnemonic('N');
        jMenuItemBayesNet.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                String title = jMenuItemBayesNet.getText();
                if (!containsWindow(title)) {
                    final GUI bayesNetGUI = new GUI();
                    final Container frame = createFrame(m_Self, title, bayesNetGUI, new BorderLayout(), BorderLayout.CENTER, 800, 600, bayesNetGUI.getMenuBar(), false, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/Groovy console
        if (Groovy.isPresent()) {
            jMenuItemToolsGroovyConsole = new JMenuItem();
            jMenuTools.add(jMenuItemToolsGroovyConsole);
            jMenuItemToolsGroovyConsole.setText("Groovy console");
            jMenuItemToolsGroovyConsole.setMnemonic('G');
            jMenuItemToolsGroovyConsole.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    String title = jMenuItemToolsGroovyConsole.getText();
                    if (!containsWindow(title)) {
                        final GroovyPanel panel = new GroovyPanel();
                        final Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenuBar(), false, true);
                        // custom listener
                        if (frame instanceof ChildFrameMDI) {
                            ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                                public void internalFrameClosing(InternalFrameEvent e) {
                                    ((ChildFrameMDI) frame).dispose();
                                }
                            });
                        } else if (frame instanceof ChildFrameSDI) {
                            ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                                public void windowClosing(WindowEvent e) {
                                    ((ChildFrameSDI) frame).dispose();
                                }
                            });
                        }
                    } else {
                        showWindow(getWindow(title));
                    }
                }
            });
        }
        // Tools/Jython console
        if (Jython.isPresent()) {
            jMenuItemToolsJythonConsole = new JMenuItem();
            jMenuTools.add(jMenuItemToolsJythonConsole);
            jMenuItemToolsJythonConsole.setText("Jython console");
            jMenuItemToolsJythonConsole.setMnemonic('J');
            jMenuItemToolsJythonConsole.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    String title = jMenuItemToolsJythonConsole.getText();
                    if (!containsWindow(title)) {
                        final JythonPanel panel = new JythonPanel();
                        final Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenuBar(), false, true);
                        // custom listener
                        if (frame instanceof ChildFrameMDI) {
                            ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                                public void internalFrameClosing(InternalFrameEvent e) {
                                    ((ChildFrameMDI) frame).dispose();
                                }
                            });
                        } else if (frame instanceof ChildFrameSDI) {
                            ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                                public void windowClosing(WindowEvent e) {
                                    ((ChildFrameSDI) frame).dispose();
                                }
                            });
                        }
                    } else {
                        showWindow(getWindow(title));
                    }
                }
            });
        }
        // Tools/EnsembleLibrary
        /* currently disabled due to bugs... FracPete
      jMenuItemToolsEnsembleLibrary = new JMenuItem();
      jMenuTools.add(jMenuItemToolsEnsembleLibrary);
      jMenuItemToolsEnsembleLibrary.setText("EnsembleLibrary");
      jMenuItemToolsEnsembleLibrary.setMnemonic('E');
      jMenuItemToolsEnsembleLibrary.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  String title = jMenuItemToolsEnsembleLibrary.getText();
	  if (!containsWindow(title)) {
	    EnsembleLibrary value = new EnsembleLibrary();
	    EnsembleLibraryEditor libraryEditor = new EnsembleLibraryEditor();
	    libraryEditor.setValue(value);
	    createFrame(
		m_Self, title, libraryEditor.getCustomEditor(), new BorderLayout(), 
		BorderLayout.CENTER, 800, 600, null, true, true);
	  }
	  else {
	    showWindow(getWindow(title));
	  }
	}
      });
      */
        // Visualization
        jMenuVisualization = new JMenu();
        jMenuBar.add(jMenuVisualization);
        jMenuVisualization.setText("Visualization");
        jMenuVisualization.setMnemonic('V');
        // Visualization/Plot
        jMenuItemVisualizationPlot = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationPlot);
        jMenuItemVisualizationPlot.setText("Plot");
        jMenuItemVisualizationPlot.setMnemonic('P');
        jMenuItemVisualizationPlot.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserPlot.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build plot
                VisualizePanel panel = new VisualizePanel();
                String filenames = "";
                File[] files = m_FileChooserPlot.getSelectedFiles();
                for (int j = 0; j < files.length; j++) {
                    String filename = files[j].getAbsolutePath();
                    if (j > 0)
                        filenames += ", ";
                    filenames += filename;
                    System.err.println("Loading instances from " + filename);
                    try {
                        Reader r = new java.io.BufferedReader(new FileReader(filename));
                        Instances i = new Instances(r);
                        i.setClassIndex(i.numAttributes() - 1);
                        PlotData2D pd1 = new PlotData2D(i);
                        if (j == 0) {
                            pd1.setPlotName("Master plot");
                            panel.setMasterPlot(pd1);
                        } else {
                            pd1.setPlotName("Plot " + (j + 1));
                            pd1.m_useCustomColour = true;
                            pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
                            panel.addPlot(pd1);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error loading file '" + files[j] + "':\n" + e.getMessage());
                        return;
                    }
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationPlot.getText() + " - " + filenames, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/ROC
        // based on this Wiki article:
        // http://weka.sourceforge.net/wiki/index.php/Visualizing_ROC_curve
        jMenuItemVisualizationROC = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationROC);
        jMenuItemVisualizationROC.setText("ROC");
        jMenuItemVisualizationROC.setMnemonic('R');
        jMenuItemVisualizationROC.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserROC.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // create plot
                String filename = m_FileChooserROC.getSelectedFile().getAbsolutePath();
                Instances result = null;
                try {
                    result = new Instances(new BufferedReader(new FileReader(filename)));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                result.setClassIndex(result.numAttributes() - 1);
                ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
                vmc.setROCString("(Area under ROC = " + Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
                vmc.setName(result.relationName());
                PlotData2D tempd = new PlotData2D(result);
                tempd.setPlotName(result.relationName());
                tempd.addInstanceNumberAttribute();
                try {
                    vmc.addPlot(tempd);
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error adding plot:\n" + e.getMessage());
                    return;
                }
                createFrame(m_Self, jMenuItemVisualizationROC.getText() + " - " + filename, vmc, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/TreeVisualizer
        jMenuItemVisualizationTreeVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationTreeVisualizer);
        jMenuItemVisualizationTreeVisualizer.setText("TreeVisualizer");
        jMenuItemVisualizationTreeVisualizer.setMnemonic('T');
        jMenuItemVisualizationTreeVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserTreeVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build tree
                String filename = m_FileChooserTreeVisualizer.getSelectedFile().getAbsolutePath();
                TreeBuild builder = new TreeBuild();
                Node top = null;
                NodePlace arrange = new PlaceNode2();
                try {
                    top = builder.create(new FileReader(filename));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationTreeVisualizer.getText() + " - " + filename, new TreeVisualizer(null, top, arrange), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/GraphVisualizer
        jMenuItemVisualizationGraphVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationGraphVisualizer);
        jMenuItemVisualizationGraphVisualizer.setText("GraphVisualizer");
        jMenuItemVisualizationGraphVisualizer.setMnemonic('G');
        jMenuItemVisualizationGraphVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserGraphVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build graph
                String filename = m_FileChooserGraphVisualizer.getSelectedFile().getAbsolutePath();
                GraphVisualizer panel = new GraphVisualizer();
                try {
                    if (filename.toLowerCase().endsWith(".xml") || filename.toLowerCase().endsWith(".bif")) {
                        panel.readBIF(new FileInputStream(filename));
                    } else {
                        panel.readDOT(new FileReader(filename));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationGraphVisualizer.getText() + " - " + filename, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/BoundaryVisualizer
        jMenuItemVisualizationBoundaryVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationBoundaryVisualizer);
        jMenuItemVisualizationBoundaryVisualizer.setText("BoundaryVisualizer");
        jMenuItemVisualizationBoundaryVisualizer.setMnemonic('B');
        jMenuItemVisualizationBoundaryVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemVisualizationBoundaryVisualizer.getText();
                if (!containsWindow(title)) {
                    createFrame(m_Self, title, new BoundaryVisualizer(), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                    // dont' do a System.exit after last window got closed!
                    BoundaryVisualizer.setExitIfNoWindowsOpen(false);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Extensions
        jMenuExtensions = new JMenu("Extensions");
        jMenuExtensions.setMnemonic(java.awt.event.KeyEvent.VK_E);
        jMenuBar.add(jMenuExtensions);
        jMenuExtensions.setVisible(false);
        String extensions = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "");
        if (extensions.length() > 0) {
            jMenuExtensions.setVisible(true);
            String[] classnames = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "").split(",");
            Hashtable<String, JMenu> submenus = new Hashtable<String, JMenu>();
            // add all extensions
            for (int i = 0; i < classnames.length; i++) {
                String classname = classnames[i];
                try {
                    MainMenuExtension ext = (MainMenuExtension) Class.forName(classname).newInstance();
                    // menuitem in a submenu?
                    JMenu submenu = null;
                    if (ext.getSubmenuTitle() != null) {
                        submenu = submenus.get(ext.getSubmenuTitle());
                        if (submenu == null) {
                            submenu = new JMenu(ext.getSubmenuTitle());
                            submenus.put(ext.getSubmenuTitle(), submenu);
                            insertMenuItem(jMenuExtensions, submenu);
                        }
                    }
                    // create menu item
                    JMenuItem menuitem = new JMenuItem();
                    menuitem.setText(ext.getMenuTitle());
                    // does the extension need a frame or does it have its own ActionListener?
                    ActionListener listener = ext.getActionListener(m_Self);
                    if (listener != null) {
                        menuitem.addActionListener(listener);
                    } else {
                        final JMenuItem finalMenuitem = menuitem;
                        final MainMenuExtension finalExt = ext;
                        menuitem.addActionListener(new ActionListener() {

                            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);
                            }
                        });
                    }
                    // sorted insert of menu item
                    if (submenu != null)
                        insertMenuItem(submenu, menuitem);
                    else
                        insertMenuItem(jMenuExtensions, menuitem);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        // Windows
        jMenuWindows = new JMenu("Windows");
        jMenuWindows.setMnemonic(java.awt.event.KeyEvent.VK_W);
        jMenuBar.add(jMenuWindows);
        // initially, there are no windows open
        jMenuWindows.setVisible(false);
        // Help
        jMenuHelp = new JMenu();
        jMenuBar.add(jMenuHelp);
        jMenuHelp.setText("Help");
        jMenuHelp.setMnemonic('H');
        // Help/Homepage
        jMenuItemHelpHomepage = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpHomepage);
        jMenuItemHelpHomepage.setText("Weka homepage");
        jMenuItemHelpHomepage.setMnemonic('H');
        jMenuItemHelpHomepage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://www.cs.waikato.ac.nz/~ml/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        /*      // Help/WekaDoc
      jMenuItemHelpWekaDoc = new JMenuItem();
      jMenuHelp.add(jMenuItemHelpWekaDoc);
      jMenuItemHelpWekaDoc.setText("Online documentation");
      jMenuItemHelpWekaDoc.setMnemonic('D');
      jMenuItemHelpWekaDoc.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  BrowserHelper.openURL(m_Self, "http://weka.sourceforge.net/wekadoc/");
	}
      }); */
        // Help/WekaWiki
        jMenuItemHelpWekaWiki = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpWekaWiki);
        jMenuItemHelpWekaWiki.setText("HOWTOs, code snippets, etc.");
        jMenuItemHelpWekaWiki.setMnemonic('W');
        jMenuItemHelpWekaWiki.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://weka.wikispaces.com/");
            }
        });
        // Help/Sourceforge
        jMenuItemHelpSourceforge = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSourceforge);
        jMenuItemHelpSourceforge.setText("Weka on SourceForge");
        jMenuItemHelpSourceforge.setMnemonic('F');
        jMenuItemHelpSourceforge.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://sourceforge.net/projects/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/SystemInfo
        jMenuItemHelpSystemInfo = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSystemInfo);
        jMenuItemHelpSystemInfo.setText("SystemInfo");
        jMenuItemHelpHomepage.setMnemonic('S');
        jMenuItemHelpSystemInfo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpSystemInfo.getText();
                if (!containsWindow(title)) {
                    // get info
                    Hashtable info = new SystemInfo().getSystemInfo();
                    // sort names
                    Vector names = new Vector();
                    Enumeration enm = info.keys();
                    while (enm.hasMoreElements()) names.add(enm.nextElement());
                    Collections.sort(names);
                    // generate table
                    String[][] data = new String[info.size()][2];
                    for (int i = 0; i < names.size(); i++) {
                        data[i][0] = names.get(i).toString();
                        data[i][1] = info.get(data[i][0]).toString();
                    }
                    String[] titles = new String[] { "Key", "Value" };
                    JTable table = new JTable(data, titles);
                    createFrame(m_Self, title, new JScrollPane(table), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/About
        jMenuItemHelpAbout = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpAbout);
        jMenuItemHelpAbout.setText("About");
        jMenuItemHelpAbout.setMnemonic('A');
        jMenuItemHelpAbout.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpAbout.getText();
                if (!containsWindow(title)) {
                    JPanel wekaPan = new JPanel();
                    wekaPan.setToolTipText("Weka, a native bird of New Zealand");
                    ImageIcon wii = new ImageIcon(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("weka/gui/weka3.gif")));
                    JLabel wekaLab = new JLabel(wii);
                    wekaPan.add(wekaLab);
                    Container frame = createFrame(m_Self, title, wekaPan, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, true, true);
                    JPanel titlePan = new JPanel();
                    titlePan.setLayout(new GridLayout(8, 1));
                    titlePan.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
                    titlePan.add(new JLabel("Waikato Environment for", SwingConstants.CENTER));
                    titlePan.add(new JLabel("Knowledge Analysis", SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("Version " + Version.VERSION, SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("(c) " + Copyright.getFromYear() + " - " + Copyright.getToYear(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getOwner(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getAddress(), SwingConstants.CENTER));
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameMDI) frame).pack();
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameSDI) frame).pack();
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // size + position
        int screenHeight = getGraphicsConfiguration().getBounds().height;
        int screenWidth = getGraphicsConfiguration().getBounds().width;
        if (m_GUIType == GUI_MDI) {
            int newHeight = (int) (((double) screenHeight) * 0.75);
            int newWidth = (int) (((double) screenWidth) * 0.75);
            setSize(1000 > newWidth ? newWidth : 1000, 800 > newHeight ? newHeight : 800);
            setLocation((screenWidth - getBounds().width) / 2, (screenHeight - getBounds().height) / 2);
        } else if (m_GUIType == GUI_SDI) {
            pack();
            setSize(screenWidth, getHeight());
            setLocation(0, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 88
Project: weka-master  File: Main.java View source code
/**
   * initializes the GUI.
   */
protected void initGUI() {
    m_Self = this;
    try {
        // main window
        createTitle("");
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("weka/gui/weka_icon.gif")).getImage());
        // bits and pieces
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".bif", "BIF Files (*.bif)"));
        m_FileChooserGraphVisualizer.addChoosableFileFilter(new ExtensionFileFilter(".xml", "XML Files (*.xml)"));
        m_FileChooserPlot.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        m_FileChooserPlot.setMultiSelectionEnabled(true);
        m_FileChooserROC.addChoosableFileFilter(new ExtensionFileFilter(Instances.FILE_EXTENSION, "ARFF Files (*" + Instances.FILE_EXTENSION + ")"));
        // Desktop
        if (m_GUIType == GUI_MDI) {
            jDesktopPane = new BackgroundDesktopPane("weka/gui/images/weka_background.gif");
            jDesktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
            setContentPane(jDesktopPane);
        } else {
            jDesktopPane = null;
        }
        // Menu
        jMenuBar = new JMenuBar();
        setJMenuBar(jMenuBar);
        // Program
        jMenuProgram = new JMenu();
        jMenuBar.add(jMenuProgram);
        jMenuProgram.setText("Program");
        jMenuProgram.setMnemonic('P');
        // Program/Preferences
        // TODO: read all properties from all props file and display them
        /*
        jMenuItemProgramPreferences = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramPreferences);
        jMenuItemProgramPreferences.setText("Preferences");
        jMenuItemProgramPreferences.setMnemonic('P');
        jMenuItemProgramPreferences.addActionListener(new ActionListener() {
  	  public void actionPerformed(ActionEvent evt) {
	    System.out.println("jMenuItemProgramPreferences.actionPerformed, event="+evt);
	    //TODO add your code for jMenuItemProgramPreferences.actionPerformed
  	  }
        });
       */
        // Program/LogWindow
        jMenuItemProgramLogWindow = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramLogWindow);
        jMenuItemProgramLogWindow.setText("LogWindow");
        jMenuItemProgramLogWindow.setMnemonic('L');
        jMenuItemProgramLogWindow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                m_LogWindow.setVisible(true);
            }
        });
        jMenuItemProgramMemoryUsage = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramMemoryUsage);
        jMenuItemProgramMemoryUsage.setText("Memory usage");
        jMenuItemProgramMemoryUsage.setMnemonic('M');
        jMenuItemProgramMemoryUsage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemProgramMemoryUsage.getText();
                if (!containsWindow(title)) {
                    final MemoryUsagePanel panel = new MemoryUsagePanel();
                    Container c = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 400, 50, null, true, true);
                    // optimize size
                    Dimension size = c.getPreferredSize();
                    c.setSize(new Dimension((int) size.getWidth(), (int) size.getHeight()));
                    // stop threads
                    if (m_GUIType == GUI_MDI) {
                        final ChildFrameMDI frame = (ChildFrameMDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    } else {
                        final ChildFrameSDI frame = (ChildFrameSDI) c;
                        Point l = panel.getFrameLocation();
                        if ((l.x != -1) && (l.y != -1))
                            frame.setLocation(l);
                        frame.addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                panel.stopMonitoring();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuProgram.add(new JSeparator());
        // Program/Exit
        jMenuItemProgramExit = new JMenuItem();
        jMenuProgram.add(jMenuItemProgramExit);
        jMenuItemProgramExit.setText("Exit");
        jMenuItemProgramExit.setMnemonic('E');
        jMenuItemProgramExit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // close all children
                Iterator iter = getWindowList();
                Vector<Container> list = new Vector<Container>();
                while (iter.hasNext()) list.add((Container) 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);
            }
        });
        // Applications
        jMenuApplications = new JMenu();
        jMenuBar.add(jMenuApplications);
        jMenuApplications.setText("Applications");
        jMenuApplications.setMnemonic('A');
        // Applications/Explorer
        jMenuItemApplicationsExplorer = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExplorer);
        jMenuItemApplicationsExplorer.setText("Explorer");
        jMenuItemApplicationsExplorer.setMnemonic('E');
        jMenuItemApplicationsExplorer.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/Experimenter
        jMenuItemApplicationsExperimenter = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsExperimenter);
        jMenuItemApplicationsExperimenter.setText("Experimenter");
        jMenuItemApplicationsExperimenter.setMnemonic('X');
        jMenuItemApplicationsExperimenter.addActionListener(new ActionListener() {

            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));
                }
            }
        });
        // Applications/KnowledgeFlow
        jMenuItemApplicationsKnowledgeFlow = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsKnowledgeFlow);
        jMenuItemApplicationsKnowledgeFlow.setText("KnowledgeFlow");
        jMenuItemApplicationsKnowledgeFlow.setMnemonic('K');
        jMenuItemApplicationsKnowledgeFlow.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsKnowledgeFlow.getText();
                if (!containsWindow(title)) {
                    KnowledgeFlowApp.createSingleton(new String[0]);
                    createFrame(m_Self, title, KnowledgeFlowApp.getSingleton(), new BorderLayout(), BorderLayout.CENTER, 900, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Applications/SimpleCLI
        jMenuItemApplicationsSimpleCLI = new JMenuItem();
        jMenuApplications.add(jMenuItemApplicationsSimpleCLI);
        jMenuItemApplicationsSimpleCLI.setText("SimpleCLI");
        jMenuItemApplicationsSimpleCLI.setMnemonic('S');
        jMenuItemApplicationsSimpleCLI.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemApplicationsSimpleCLI.getText();
                if (!containsWindow(title)) {
                    try {
                        createFrame(m_Self, title, new SimpleCLIPanel(), new BorderLayout(), BorderLayout.CENTER, 600, 500, null, true, true);
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error instantiating SimpleCLI:\n" + e.getMessage());
                        return;
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools
        jMenuTools = new JMenu();
        jMenuBar.add(jMenuTools);
        jMenuTools.setText("Tools");
        jMenuTools.setMnemonic('T');
        // Tools/ArffViewer
        jMenuItemToolsArffViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsArffViewer);
        jMenuItemToolsArffViewer.setText("ArffViewer");
        jMenuItemToolsArffViewer.setMnemonic('A');
        jMenuItemToolsArffViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsArffViewer.getText();
                if (!containsWindow(title)) {
                    ArffViewerMainPanel panel = new ArffViewerMainPanel(null);
                    panel.setConfirmExit(false);
                    Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenu(), true, true);
                    panel.setParent(frame);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/SqlViewer
        jMenuItemToolsSqlViewer = new JMenuItem();
        jMenuTools.add(jMenuItemToolsSqlViewer);
        jMenuItemToolsSqlViewer.setText("SqlViewer");
        jMenuItemToolsSqlViewer.setMnemonic('S');
        jMenuItemToolsSqlViewer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemToolsSqlViewer.getText();
                if (!containsWindow(title)) {
                    final SqlViewer sql = new SqlViewer(null);
                    final Container frame = createFrame(m_Self, title, sql, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, false, true);
                    // custom listener
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                            public void internalFrameClosing(InternalFrameEvent e) {
                                sql.saveSize();
                                ((ChildFrameMDI) frame).dispose();
                            }
                        });
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                            public void windowClosing(WindowEvent e) {
                                sql.saveSize();
                                ((ChildFrameSDI) frame).dispose();
                            }
                        });
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/Bayes net editor
        // Tools/Bayes net editor
        final JMenuItem jMenuItemBayesNet = new JMenuItem();
        jMenuTools.add(jMenuItemBayesNet);
        jMenuItemBayesNet.setText("Bayes net editor");
        jMenuItemBayesNet.setMnemonic('N');
        jMenuItemBayesNet.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                String title = jMenuItemBayesNet.getText();
                if (!containsWindow(title)) {
                    final GUI bayesNetGUI = new GUI();
                    final Container frame = createFrame(m_Self, title, bayesNetGUI, new BorderLayout(), BorderLayout.CENTER, 800, 600, bayesNetGUI.getMenuBar(), false, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Tools/Groovy console
        if (Groovy.isPresent()) {
            jMenuItemToolsGroovyConsole = new JMenuItem();
            jMenuTools.add(jMenuItemToolsGroovyConsole);
            jMenuItemToolsGroovyConsole.setText("Groovy console");
            jMenuItemToolsGroovyConsole.setMnemonic('G');
            jMenuItemToolsGroovyConsole.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    String title = jMenuItemToolsGroovyConsole.getText();
                    if (!containsWindow(title)) {
                        final GroovyPanel panel = new GroovyPanel();
                        final Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenuBar(), false, true);
                        // custom listener
                        if (frame instanceof ChildFrameMDI) {
                            ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                                public void internalFrameClosing(InternalFrameEvent e) {
                                    ((ChildFrameMDI) frame).dispose();
                                }
                            });
                        } else if (frame instanceof ChildFrameSDI) {
                            ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                                public void windowClosing(WindowEvent e) {
                                    ((ChildFrameSDI) frame).dispose();
                                }
                            });
                        }
                    } else {
                        showWindow(getWindow(title));
                    }
                }
            });
        }
        // Tools/Jython console
        if (Jython.isPresent()) {
            jMenuItemToolsJythonConsole = new JMenuItem();
            jMenuTools.add(jMenuItemToolsJythonConsole);
            jMenuItemToolsJythonConsole.setText("Jython console");
            jMenuItemToolsJythonConsole.setMnemonic('J');
            jMenuItemToolsJythonConsole.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    String title = jMenuItemToolsJythonConsole.getText();
                    if (!containsWindow(title)) {
                        final JythonPanel panel = new JythonPanel();
                        final Container frame = createFrame(m_Self, title, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, panel.getMenuBar(), false, true);
                        // custom listener
                        if (frame instanceof ChildFrameMDI) {
                            ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {

                                public void internalFrameClosing(InternalFrameEvent e) {
                                    ((ChildFrameMDI) frame).dispose();
                                }
                            });
                        } else if (frame instanceof ChildFrameSDI) {
                            ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {

                                public void windowClosing(WindowEvent e) {
                                    ((ChildFrameSDI) frame).dispose();
                                }
                            });
                        }
                    } else {
                        showWindow(getWindow(title));
                    }
                }
            });
        }
        // Tools/EnsembleLibrary
        /* currently disabled due to bugs... FracPete
      jMenuItemToolsEnsembleLibrary = new JMenuItem();
      jMenuTools.add(jMenuItemToolsEnsembleLibrary);
      jMenuItemToolsEnsembleLibrary.setText("EnsembleLibrary");
      jMenuItemToolsEnsembleLibrary.setMnemonic('E');
      jMenuItemToolsEnsembleLibrary.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  String title = jMenuItemToolsEnsembleLibrary.getText();
	  if (!containsWindow(title)) {
	    EnsembleLibrary value = new EnsembleLibrary();
	    EnsembleLibraryEditor libraryEditor = new EnsembleLibraryEditor();
	    libraryEditor.setValue(value);
	    createFrame(
		m_Self, title, libraryEditor.getCustomEditor(), new BorderLayout(), 
		BorderLayout.CENTER, 800, 600, null, true, true);
	  }
	  else {
	    showWindow(getWindow(title));
	  }
	}
      });
      */
        // Visualization
        jMenuVisualization = new JMenu();
        jMenuBar.add(jMenuVisualization);
        jMenuVisualization.setText("Visualization");
        jMenuVisualization.setMnemonic('V');
        // Visualization/Plot
        jMenuItemVisualizationPlot = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationPlot);
        jMenuItemVisualizationPlot.setText("Plot");
        jMenuItemVisualizationPlot.setMnemonic('P');
        jMenuItemVisualizationPlot.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserPlot.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build plot
                VisualizePanel panel = new VisualizePanel();
                String filenames = "";
                File[] files = m_FileChooserPlot.getSelectedFiles();
                for (int j = 0; j < files.length; j++) {
                    String filename = files[j].getAbsolutePath();
                    if (j > 0)
                        filenames += ", ";
                    filenames += filename;
                    System.err.println("Loading instances from " + filename);
                    try {
                        Reader r = new java.io.BufferedReader(new FileReader(filename));
                        Instances i = new Instances(r);
                        i.setClassIndex(i.numAttributes() - 1);
                        PlotData2D pd1 = new PlotData2D(i);
                        if (j == 0) {
                            pd1.setPlotName("Master plot");
                            panel.setMasterPlot(pd1);
                        } else {
                            pd1.setPlotName("Plot " + (j + 1));
                            pd1.m_useCustomColour = true;
                            pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
                            panel.addPlot(pd1);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(m_Self, "Error loading file '" + files[j] + "':\n" + e.getMessage());
                        return;
                    }
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationPlot.getText() + " - " + filenames, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/ROC
        // based on this Wiki article:
        // http://weka.sourceforge.net/wiki/index.php/Visualizing_ROC_curve
        jMenuItemVisualizationROC = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationROC);
        jMenuItemVisualizationROC.setText("ROC");
        jMenuItemVisualizationROC.setMnemonic('R');
        jMenuItemVisualizationROC.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserROC.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // create plot
                String filename = m_FileChooserROC.getSelectedFile().getAbsolutePath();
                Instances result = null;
                try {
                    result = new Instances(new BufferedReader(new FileReader(filename)));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                result.setClassIndex(result.numAttributes() - 1);
                ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
                vmc.setROCString("(Area under ROC = " + Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
                vmc.setName(result.relationName());
                PlotData2D tempd = new PlotData2D(result);
                tempd.setPlotName(result.relationName());
                tempd.addInstanceNumberAttribute();
                try {
                    vmc.addPlot(tempd);
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error adding plot:\n" + e.getMessage());
                    return;
                }
                createFrame(m_Self, jMenuItemVisualizationROC.getText() + " - " + filename, vmc, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/TreeVisualizer
        jMenuItemVisualizationTreeVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationTreeVisualizer);
        jMenuItemVisualizationTreeVisualizer.setText("TreeVisualizer");
        jMenuItemVisualizationTreeVisualizer.setMnemonic('T');
        jMenuItemVisualizationTreeVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserTreeVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build tree
                String filename = m_FileChooserTreeVisualizer.getSelectedFile().getAbsolutePath();
                TreeBuild builder = new TreeBuild();
                Node top = null;
                NodePlace arrange = new PlaceNode2();
                try {
                    top = builder.create(new FileReader(filename));
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationTreeVisualizer.getText() + " - " + filename, new TreeVisualizer(null, top, arrange), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/GraphVisualizer
        jMenuItemVisualizationGraphVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationGraphVisualizer);
        jMenuItemVisualizationGraphVisualizer.setText("GraphVisualizer");
        jMenuItemVisualizationGraphVisualizer.setMnemonic('G');
        jMenuItemVisualizationGraphVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                // choose file
                int retVal = m_FileChooserGraphVisualizer.showOpenDialog(m_Self);
                if (retVal != JFileChooser.APPROVE_OPTION)
                    return;
                // build graph
                String filename = m_FileChooserGraphVisualizer.getSelectedFile().getAbsolutePath();
                GraphVisualizer panel = new GraphVisualizer();
                try {
                    if (filename.toLowerCase().endsWith(".xml") || filename.toLowerCase().endsWith(".bif")) {
                        panel.readBIF(new FileInputStream(filename));
                    } else {
                        panel.readDOT(new FileReader(filename));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
                    return;
                }
                // create frame
                createFrame(m_Self, jMenuItemVisualizationGraphVisualizer.getText() + " - " + filename, panel, new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
            }
        });
        // Visualization/BoundaryVisualizer
        jMenuItemVisualizationBoundaryVisualizer = new JMenuItem();
        jMenuVisualization.add(jMenuItemVisualizationBoundaryVisualizer);
        jMenuItemVisualizationBoundaryVisualizer.setText("BoundaryVisualizer");
        jMenuItemVisualizationBoundaryVisualizer.setMnemonic('B');
        jMenuItemVisualizationBoundaryVisualizer.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemVisualizationBoundaryVisualizer.getText();
                if (!containsWindow(title)) {
                    createFrame(m_Self, title, new BoundaryVisualizer(), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                    // dont' do a System.exit after last window got closed!
                    BoundaryVisualizer.setExitIfNoWindowsOpen(false);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // Extensions
        jMenuExtensions = new JMenu("Extensions");
        jMenuExtensions.setMnemonic(java.awt.event.KeyEvent.VK_E);
        jMenuBar.add(jMenuExtensions);
        jMenuExtensions.setVisible(false);
        String extensions = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "");
        if (extensions.length() > 0) {
            jMenuExtensions.setVisible(true);
            String[] classnames = GenericObjectEditor.EDITOR_PROPERTIES.getProperty(MainMenuExtension.class.getName(), "").split(",");
            Hashtable<String, JMenu> submenus = new Hashtable<String, JMenu>();
            // add all extensions
            for (int i = 0; i < classnames.length; i++) {
                String classname = classnames[i];
                try {
                    MainMenuExtension ext = (MainMenuExtension) Class.forName(classname).newInstance();
                    // menuitem in a submenu?
                    JMenu submenu = null;
                    if (ext.getSubmenuTitle() != null) {
                        submenu = submenus.get(ext.getSubmenuTitle());
                        if (submenu == null) {
                            submenu = new JMenu(ext.getSubmenuTitle());
                            submenus.put(ext.getSubmenuTitle(), submenu);
                            insertMenuItem(jMenuExtensions, submenu);
                        }
                    }
                    // create menu item
                    JMenuItem menuitem = new JMenuItem();
                    menuitem.setText(ext.getMenuTitle());
                    // does the extension need a frame or does it have its own ActionListener?
                    ActionListener listener = ext.getActionListener(m_Self);
                    if (listener != null) {
                        menuitem.addActionListener(listener);
                    } else {
                        final JMenuItem finalMenuitem = menuitem;
                        final MainMenuExtension finalExt = ext;
                        menuitem.addActionListener(new ActionListener() {

                            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);
                            }
                        });
                    }
                    // sorted insert of menu item
                    if (submenu != null)
                        insertMenuItem(submenu, menuitem);
                    else
                        insertMenuItem(jMenuExtensions, menuitem);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        // Windows
        jMenuWindows = new JMenu("Windows");
        jMenuWindows.setMnemonic(java.awt.event.KeyEvent.VK_W);
        jMenuBar.add(jMenuWindows);
        // initially, there are no windows open
        jMenuWindows.setVisible(false);
        // Help
        jMenuHelp = new JMenu();
        jMenuBar.add(jMenuHelp);
        jMenuHelp.setText("Help");
        jMenuHelp.setMnemonic('H');
        // Help/Homepage
        jMenuItemHelpHomepage = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpHomepage);
        jMenuItemHelpHomepage.setText("Weka homepage");
        jMenuItemHelpHomepage.setMnemonic('H');
        jMenuItemHelpHomepage.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://www.cs.waikato.ac.nz/~ml/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        /*      // Help/WekaDoc
      jMenuItemHelpWekaDoc = new JMenuItem();
      jMenuHelp.add(jMenuItemHelpWekaDoc);
      jMenuItemHelpWekaDoc.setText("Online documentation");
      jMenuItemHelpWekaDoc.setMnemonic('D');
      jMenuItemHelpWekaDoc.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent evt) {
	  BrowserHelper.openURL(m_Self, "http://weka.sourceforge.net/wekadoc/");
	}
      }); */
        // Help/WekaWiki
        jMenuItemHelpWekaWiki = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpWekaWiki);
        jMenuItemHelpWekaWiki.setText("HOWTOs, code snippets, etc.");
        jMenuItemHelpWekaWiki.setMnemonic('W');
        jMenuItemHelpWekaWiki.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://weka.wikispaces.com/");
            }
        });
        // Help/Sourceforge
        jMenuItemHelpSourceforge = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSourceforge);
        jMenuItemHelpSourceforge.setText("Weka on SourceForge");
        jMenuItemHelpSourceforge.setMnemonic('F');
        jMenuItemHelpSourceforge.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                BrowserHelper.openURL(m_Self, "http://sourceforge.net/projects/weka/");
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/SystemInfo
        jMenuItemHelpSystemInfo = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpSystemInfo);
        jMenuItemHelpSystemInfo.setText("SystemInfo");
        jMenuItemHelpHomepage.setMnemonic('S');
        jMenuItemHelpSystemInfo.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpSystemInfo.getText();
                if (!containsWindow(title)) {
                    // get info
                    Hashtable info = new SystemInfo().getSystemInfo();
                    // sort names
                    Vector names = new Vector();
                    Enumeration enm = info.keys();
                    while (enm.hasMoreElements()) names.add(enm.nextElement());
                    Collections.sort(names);
                    // generate table
                    String[][] data = new String[info.size()][2];
                    for (int i = 0; i < names.size(); i++) {
                        data[i][0] = names.get(i).toString();
                        data[i][1] = info.get(data[i][0]).toString();
                    }
                    String[] titles = new String[] { "Key", "Value" };
                    JTable table = new JTable(data, titles);
                    createFrame(m_Self, title, new JScrollPane(table), new BorderLayout(), BorderLayout.CENTER, 800, 600, null, true, true);
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        jMenuHelp.add(new JSeparator());
        // Help/About
        jMenuItemHelpAbout = new JMenuItem();
        jMenuHelp.add(jMenuItemHelpAbout);
        jMenuItemHelpAbout.setText("About");
        jMenuItemHelpAbout.setMnemonic('A');
        jMenuItemHelpAbout.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String title = jMenuItemHelpAbout.getText();
                if (!containsWindow(title)) {
                    JPanel wekaPan = new JPanel();
                    wekaPan.setToolTipText("Weka, a native bird of New Zealand");
                    ImageIcon wii = new ImageIcon(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("weka/gui/weka3.gif")));
                    JLabel wekaLab = new JLabel(wii);
                    wekaPan.add(wekaLab);
                    Container frame = createFrame(m_Self, title, wekaPan, new BorderLayout(), BorderLayout.CENTER, -1, -1, null, true, true);
                    JPanel titlePan = new JPanel();
                    titlePan.setLayout(new GridLayout(8, 1));
                    titlePan.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
                    titlePan.add(new JLabel("Waikato Environment for", SwingConstants.CENTER));
                    titlePan.add(new JLabel("Knowledge Analysis", SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("Version " + Version.VERSION, SwingConstants.CENTER));
                    titlePan.add(new JLabel(""));
                    titlePan.add(new JLabel("(c) " + Copyright.getFromYear() + " - " + Copyright.getToYear(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getOwner(), SwingConstants.CENTER));
                    titlePan.add(new JLabel(Copyright.getAddress(), SwingConstants.CENTER));
                    if (frame instanceof ChildFrameMDI) {
                        ((ChildFrameMDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameMDI) frame).pack();
                    } else if (frame instanceof ChildFrameSDI) {
                        ((ChildFrameSDI) frame).getContentPane().add(titlePan, BorderLayout.NORTH);
                        ((ChildFrameSDI) frame).pack();
                    }
                } else {
                    showWindow(getWindow(title));
                }
            }
        });
        // size + position
        int screenHeight = getGraphicsConfiguration().getBounds().height;
        int screenWidth = getGraphicsConfiguration().getBounds().width;
        if (m_GUIType == GUI_MDI) {
            int newHeight = (int) (((double) screenHeight) * 0.75);
            int newWidth = (int) (((double) screenWidth) * 0.75);
            setSize(1000 > newWidth ? newWidth : 1000, 800 > newHeight ? newHeight : 800);
            setLocation((screenWidth - getBounds().width) / 2, (screenHeight - getBounds().height) / 2);
        } else if (m_GUIType == GUI_SDI) {
            pack();
            setSize(screenWidth, getHeight());
            setLocation(0, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 89
Project: iranAdempiere-master  File: ControlPanel.java View source code
private void setupUI() {
    JPanel p0 = new JPanel();
    p0.setBounds(0, 0, preferredSize.width, preferredSize.height);
    // Table
    exampleTable = new JTable(new TinyTableModel());
    exampleTable.setRowSelectionAllowed(true);
    exampleTable.setColumnSelectionAllowed(true);
    exampleTable.setColumnSelectionInterval(2, 2);
    exampleTable.setRowSelectionInterval(0, 2);
    exampleTable.setDefaultRenderer(TinyTableModel.TableColorIcon.class, new IconRenderer());
    JScrollPane sp = new JScrollPane(exampleTable);
    sp.setBounds(10, 10, 192, 132);
    add(sp, JDesktopPane.DEFAULT_LAYER);
    scrollBars[6] = sp;
    // Disabled TabbedPane
    exampleTb = new JTabbedPane();
    exampleTb.add("Disabled", new ContentLabel());
    exampleTb.add("Tabbed", new ContentLabel());
    exampleTb.add("Pane", new ContentLabel());
    exampleTb.setEnabled(false);
    exampleTb.setPreferredSize(new Dimension(180, 60));
    exampleTb.setBounds(210, 40, 180, 60);
    add(exampleTb, JDesktopPane.DEFAULT_LAYER);
    // Internal Frame
    frames = new Component[2];
    internalFrame = new JInternalFrame("InternalFrame", true, true, true, true);
    frames[0] = internalFrame;
    internalFrame.updateUI();
    internalFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    internalFrame.addInternalFrameListener(new InternalFrameAdapter() {

        public void internalFrameClosing(InternalFrameEvent e) {
            String msg = "This internal frame cannot be closed.";
            JOptionPane.showInternalMessageDialog(internalFrame, msg);
            e.getInternalFrame().show();
        }
    });
    internalFrame.getContentPane().add(new SizedPanel(200, 100));
    internalFrame.pack();
    Dimension frameSize = internalFrame.getPreferredSize();
    internalFrame.setBounds(400, 10, frameSize.width, frameSize.height);
    internalFrame.show();
    add(internalFrame, JDesktopPane.PALETTE_LAYER);
    // Palette
    palette = new JInternalFrame("Palette", false, true, true, true);
    frames[1] = palette;
    palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
    palette.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    palette.addInternalFrameListener(new InternalFrameAdapter() {

        public void internalFrameClosing(InternalFrameEvent e) {
            String msg = "This internal palette cannot be closed.";
            JOptionPane.showInternalMessageDialog(palette, msg);
            e.getInternalFrame().show();
        }
    });
    JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
    JButton defaultButton = new JButton("InternalMessageDialog");
    buttons[12] = defaultButton;
    defaultButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JOptionPane.showInternalMessageDialog(palette, "Life is a while(true) loop.");
        }
    });
    palette.getRootPane().setDefaultButton(defaultButton);
    JButton b = new JButton("InternalConfirmDialog ");
    buttons[13] = b;
    b.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JOptionPane.showInternalConfirmDialog(palette, "Is programming art?");
        }
    });
    JPanel p3 = new JPanel(new GridLayout(4, 1));
    p3.add(new JLabel());
    p3.add(defaultButton);
    p3.add(new JLabel());
    p3.add(b);
    p2.add(p3);
    palette.getContentPane().add(p2);
    palette.setBounds(400 + internalFrame.getWidth() + 12, 10, 180, 140);
    palette.show();
    add(palette, JDesktopPane.PALETTE_LAYER);
}
Example 90
Project: tizzit-master  File: ControlPanel.java View source code
private void setupUI() {
    JPanel p0 = new JPanel();
    p0.setBounds(0, 0, preferredSize.width, preferredSize.height);
    // Table
    exampleTable = new JTable(new TinyTableModel());
    exampleTable.setRowSelectionAllowed(true);
    exampleTable.setColumnSelectionAllowed(true);
    exampleTable.setColumnSelectionInterval(2, 2);
    exampleTable.setRowSelectionInterval(0, 2);
    exampleTable.setDefaultRenderer(TinyTableModel.TableColorIcon.class, new IconRenderer());
    JScrollPane sp = new JScrollPane(exampleTable);
    sp.setBounds(10, 10, 192, 132);
    add(sp, JDesktopPane.DEFAULT_LAYER);
    scrollBars[6] = sp;
    // Disabled TabbedPane
    exampleTb = new JTabbedPane();
    exampleTb.add("Disabled", new ContentLabel());
    exampleTb.add("Tabbed", new ContentLabel());
    exampleTb.add("Pane", new ContentLabel());
    exampleTb.setEnabled(false);
    exampleTb.setPreferredSize(new Dimension(180, 60));
    exampleTb.setBounds(210, 40, 180, 60);
    add(exampleTb, JDesktopPane.DEFAULT_LAYER);
    // Internal Frame
    frames = new Component[2];
    internalFrame = new JInternalFrame("InternalFrame", true, true, true, true);
    frames[0] = internalFrame;
    internalFrame.updateUI();
    internalFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    internalFrame.addInternalFrameListener(new InternalFrameAdapter() {

        public void internalFrameClosing(InternalFrameEvent e) {
            String msg = "This internal frame cannot be closed.";
            JOptionPane.showInternalMessageDialog(internalFrame, msg);
            e.getInternalFrame().show();
        }
    });
    internalFrame.getContentPane().add(new SizedPanel(200, 100));
    internalFrame.pack();
    Dimension frameSize = internalFrame.getPreferredSize();
    internalFrame.setBounds(400, 10, frameSize.width, frameSize.height);
    internalFrame.show();
    add(internalFrame, JDesktopPane.PALETTE_LAYER);
    // Palette
    palette = new JInternalFrame("Palette", false, true, true, true);
    frames[1] = palette;
    palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
    palette.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    palette.addInternalFrameListener(new InternalFrameAdapter() {

        public void internalFrameClosing(InternalFrameEvent e) {
            String msg = "This internal palette cannot be closed.";
            JOptionPane.showInternalMessageDialog(palette, msg);
            e.getInternalFrame().show();
        }
    });
    JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
    JButton defaultButton = new JButton("InternalMessageDialog");
    buttons[12] = defaultButton;
    defaultButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JOptionPane.showInternalMessageDialog(palette, "Life is a while(true) loop.");
        }
    });
    palette.getRootPane().setDefaultButton(defaultButton);
    JButton b = new JButton("InternalConfirmDialog ");
    buttons[13] = b;
    b.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JOptionPane.showInternalConfirmDialog(palette, "Is programming art?");
        }
    });
    JPanel p3 = new JPanel(new GridLayout(4, 1));
    p3.add(new JLabel());
    p3.add(defaultButton);
    p3.add(new JLabel());
    p3.add(b);
    p2.add(p3);
    palette.getContentPane().add(p2);
    palette.setBounds(400 + internalFrame.getWidth() + 12, 10, 180, 140);
    palette.show();
    add(palette, JDesktopPane.PALETTE_LAYER);
}
Example 91
Project: assertj-swing-master  File: JDesktopPaneChildrenFinder.java View source code
@Override
@RunsInCurrentThread
@Nonnull
public Collection<Component> nonExplicitChildrenOf(@Nonnull Container c) {
    if (!(c instanceof JDesktopPane)) {
        return emptyList();
    }
    return internalFramesFromIcons(c);
}
Example 92
Project: OpenDolphin-master  File: MDI.java View source code
public void createDesktopPane() {
    desktop = new JDesktopPane();
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    desktop.setBackground(Color.GRAY);
    event = new MDIEvent();
    desktop.setDesktopManager(event.getManager());
}
Example 93
Project: freehep-ncolor-pdf-master  File: MDITest.java View source code
public JComponent createComponent() {
    desktop = new JDesktopPane();
    desktop.setPreferredSize(new Dimension(600, 400));
    return desktop;
}
Example 94
Project: JT-master  File: GuiUtil.java View source code
/**
     * Workaround for bug: can't re-show internal frames. See bug parade 4138031.
     */
public static void show(JInternalFrame internalFrame, JDesktopPane desktopPane) throws PropertyVetoException {
    if (!desktopPane.isAncestorOf(internalFrame))
        desktopPane.add(internalFrame);
    internalFrame.setClosed(false);
    internalFrame.setVisible(true);
    internalFrame.toFront();
}
Example 95
Project: jts-master  File: GuiUtil.java View source code
/**
     * Workaround for bug: can't re-show internal frames. See bug parade 4138031.
     */
public static void show(JInternalFrame internalFrame, JDesktopPane desktopPane) throws PropertyVetoException {
    if (!desktopPane.isAncestorOf(internalFrame))
        desktopPane.add(internalFrame);
    internalFrame.setClosed(false);
    internalFrame.setVisible(true);
    internalFrame.toFront();
}
Example 96
Project: com.revolsys.open-master  File: GuiUtil.java View source code
/**
   * Workaround for bug: can't re-show internal frames. See bug parade 4138031.
   */
public static void show(final JInternalFrame internalFrame, final JDesktopPane desktopPane) throws PropertyVetoException {
    if (!desktopPane.isAncestorOf(internalFrame)) {
        desktopPane.add(internalFrame);
    }
    internalFrame.setClosed(false);
    internalFrame.setVisible(true);
    internalFrame.toFront();
}
Example 97
Project: filius-master  File: GUIDesktopPanel.java View source code
public JDesktopPane getDesktopPane() {
    return desktopPane;
}
Example 98
Project: myrobotlab-master  File: Simbad.java View source code
public JDesktopPane getDesktopPane() {
    return desktop;
}
Example 99
Project: Reuseware-master  File: MultipleUtilizationPane.java View source code
private void addConflictPane() {
    conflictPane = new JDesktopPane();
    getContentPane().add(conflictPane, BorderLayout.CENTER);
    conflictPane.setPreferredSize(new java.awt.Dimension(662, 229));
    conflictPane.setBackground(new java.awt.Color(192, 192, 192));
}
Example 100
Project: simbad-master  File: Simbad.java View source code
public JDesktopPane getDesktopPane() {
    return desktop;
}
Example 101
Project: aetheria-master  File: SwingAetheriaGUI.java View source code
public JDesktopPane getPanel() {
    return panel;
}