Example usage for javax.swing JSplitPane setDividerLocation

List of usage examples for javax.swing JSplitPane setDividerLocation

Introduction

In this page you can find the example usage for javax.swing JSplitPane setDividerLocation.

Prototype

@BeanProperty(description = "The location of the divider.")
public void setDividerLocation(int location) 

Source Link

Document

Sets the location of the divider.

Usage

From source file:org.ash.history.detail.DetailsPanelH.java

/**
 * Initialize DetailFrame// www.ja v a  2  s . co m
 */
private void initialize() {

    this.setLayout(new BorderLayout());
    JSplitPane splitPaneMainDetail = new JSplitPane();

    this.cpuRadioButton.setText(Options.getInstance().getResource("cpuLabel.text"));
    this.cpuRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.cpuRadioButton);
    this.schedulerRadioButton.setText(Options.getInstance().getResource("schedulerLabel.text"));
    this.schedulerRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.schedulerRadioButton);
    this.userIORadioButton.setText(Options.getInstance().getResource("userIOLabel.text"));
    this.userIORadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.userIORadioButton);
    this.systemIORadioButton.setText(Options.getInstance().getResource("systemIOLabel.text"));
    this.systemIORadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.systemIORadioButton);
    this.concurrencyRadioButton.setText(Options.getInstance().getResource("concurrencyLabel.text"));
    this.concurrencyRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.concurrencyRadioButton);
    this.applicationRadioButton.setText(Options.getInstance().getResource("applicationsLabel.text"));
    this.applicationRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.applicationRadioButton);
    this.commitRadioButton.setText(Options.getInstance().getResource("commitLabel.text"));
    this.commitRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.commitRadioButton);
    this.configurationRadioButton.setText(Options.getInstance().getResource("configurationLabel.text"));
    this.configurationRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.configurationRadioButton);
    this.administrativeRadioButton.setText(Options.getInstance().getResource("administrativeLabel.text"));
    this.administrativeRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.administrativeRadioButton);
    this.networkRadioButton.setText(Options.getInstance().getResource("networkLabel.text"));
    this.networkRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.networkRadioButton);
    this.queuningRadioButton.setText(Options.getInstance().getResource("queueningLabel.text"));
    this.queuningRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.queuningRadioButton);
    this.clusterRadioButton.setText(Options.getInstance().getResource("clusterLabel.text"));
    this.clusterRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.clusterRadioButton);
    this.otherRadioButton.setText(Options.getInstance().getResource("otherLabel.text"));
    this.otherRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.otherRadioButton);

    this.buttonGroup.add(cpuRadioButton);
    this.buttonGroup.add(schedulerRadioButton);
    this.buttonGroup.add(userIORadioButton);
    this.buttonGroup.add(systemIORadioButton);
    this.buttonGroup.add(concurrencyRadioButton);
    this.buttonGroup.add(applicationRadioButton);
    this.buttonGroup.add(commitRadioButton);
    this.buttonGroup.add(configurationRadioButton);
    this.buttonGroup.add(administrativeRadioButton);
    this.buttonGroup.add(networkRadioButton);
    this.buttonGroup.add(queuningRadioButton);
    this.buttonGroup.add(clusterRadioButton);
    this.buttonGroup.add(otherRadioButton);

    /** Button panel fot buttons */
    this.buttonPanel = new JToolBar("PanelButton");
    this.buttonPanel.setFloatable(false);
    this.buttonPanel.setBorder(new EtchedBorder());

    this.buttonPanel.add(this.cpuRadioButton);
    this.buttonPanel.add(this.schedulerRadioButton);
    this.buttonPanel.add(this.userIORadioButton);
    this.buttonPanel.add(this.systemIORadioButton);
    this.buttonPanel.add(this.concurrencyRadioButton);
    this.buttonPanel.add(this.applicationRadioButton);
    this.buttonPanel.add(this.commitRadioButton);
    this.buttonPanel.add(this.configurationRadioButton);
    this.buttonPanel.add(this.administrativeRadioButton);
    this.buttonPanel.add(this.networkRadioButton);
    this.buttonPanel.add(this.queuningRadioButton);
    this.buttonPanel.add(this.clusterRadioButton);
    this.buttonPanel.add(this.otherRadioButton);

    splitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPaneMainDetail.add(new JPanel(), "top");
    splitPaneMainDetail.add(new JPanel(), "bottom");
    splitPaneMainDetail.setDividerLocation(230);
    splitPaneMainDetail.setOneTouchExpandable(true);

    this.mainPanel = new JPanel();
    this.mainPanel.setLayout(new BorderLayout());
    this.mainPanel.setVisible(true);
    this.mainPanel.add(splitPaneMainDetail, BorderLayout.CENTER);

    this.add(this.buttonPanel, BorderLayout.NORTH);
    this.add(this.mainPanel, BorderLayout.CENTER);
}

From source file:src.gui.ItSIMPLE.java

/**
 * @return Returns the planAnalysisFramePanel.
 *//*  w  w w . ja  va  2s .c  o m*/
private ItFramePanel getPlanAnalysisFramePanel() {
    if (planAnalysisFramePanel == null) {
        planAnalysisFramePanel = new ItFramePanel(":: Plan Analysis", ItFramePanel.NO_MINIMIZE_MAXIMIZE);

        // tool bar
        JToolBar chartsToolBar = new JToolBar();
        chartsToolBar.add(new JButton(drawChartAction));

        // charts panel
        chartsPanel = new JPanel();
        chartsPanel.setLayout(new BoxLayout(chartsPanel, BoxLayout.Y_AXIS));

        ItFramePanel variableSelectionPanel = new ItFramePanel(".: Select variables to be tracked",
                ItFramePanel.NO_MINIMIZE_MAXIMIZE);
        //variableSelectionPanel.setBackground(new Color(151,151,157));

        JSplitPane split = new JSplitPane();
        split.setContinuousLayout(true);
        split.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
        split.setDividerLocation(2 * screenSize.height / 3);

        split.setDividerSize(8);
        //split.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50));
        //split.setPreferredSize(new Dimension(screenSize.width/4-20, 120));
        split.setLeftComponent(new JScrollPane(variablesPlanTree));
        split.setRightComponent(new JScrollPane(selectedVariablesPlanTree));

        variableSelectionPanel.setContent(split, false);
        //variableSelectionPanel.setParentSplitPane()

        //JPanel variableSelectionPanel  = new JPanel(new BorderLayout());
        //variableSelectionPanel.add(new JScrollPane(variablesPlanTree), BorderLayout.CENTER);
        //variableSelectionPanel.add(new JScrollPane(selectedVariablesPlanTree), BorderLayout.EAST);

        ItFramePanel variableGraphPanel = new ItFramePanel(".: Chart", ItFramePanel.NO_MINIMIZE_MAXIMIZE);
        variableGraphPanel.setContent(chartsPanel, true);

        JSplitPane mainvariablesplit = new JSplitPane();
        mainvariablesplit.setContinuousLayout(true);
        mainvariablesplit.setOrientation(JSplitPane.VERTICAL_SPLIT);
        mainvariablesplit.setDividerLocation(150);
        mainvariablesplit.setDividerSize(8);
        //mainvariablesplit.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50));
        mainvariablesplit.setTopComponent(variableSelectionPanel);
        mainvariablesplit.setBottomComponent(variableGraphPanel);

        // main charts panel - used to locate the tool bar above the charts panel
        JPanel mainChartsPanel = new JPanel(new BorderLayout());
        mainChartsPanel.add(chartsToolBar, BorderLayout.NORTH);
        //mainChartsPanel.add(new JScrollPane(chartsPanel), BorderLayout.CENTER);
        mainChartsPanel.add(mainvariablesplit, BorderLayout.CENTER);

        //Results
        planInfoEditorPane = new JEditorPane();
        planInfoEditorPane.setContentType("text/html");
        planInfoEditorPane.setEditable(false);
        planInfoEditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR));
        planInfoEditorPane.setBackground(Color.WHITE);

        JPanel resultsPanel = new JPanel(new BorderLayout());

        JToolBar resultsToolBar = new JToolBar();
        resultsToolBar.setRollover(true);

        JButton planReportButton = new JButton("View Full Report",
                new ImageIcon("resources/images/viewreport.png"));
        planReportButton.setToolTipText("<html>View full plan report.<br> For multiple plans you will need "
                + "access to the Internet.<br> The components used in the report require such access (no data is "
                + "sent through the Internet).</html>");
        planReportButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //Opens html with defaut browser
                String path = "resources/report/Report.html";
                File report = new File(path);
                path = report.getAbsolutePath();
                try {
                    BrowserLauncher launcher = new BrowserLauncher();
                    launcher.openURLinBrowser("file://" + path);
                } catch (BrowserLaunchingInitializingException ex) {
                    Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
                    appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n");
                } catch (UnsupportedOperatingSystemException ex) {
                    Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
                    appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n");
                }
            }
        });
        resultsToolBar.add(planReportButton);

        resultsToolBar.addSeparator();
        JButton planReportDataButton = new JButton("Save Report Data",
                new ImageIcon("resources/images/savePDDL.png"));
        planReportDataButton.setToolTipText("<html>Save report data to file</html>");
        planReportDataButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //Save report data
                if (solveResult != null) {
                    Element lastOpenFolderElement = itSettings.getChild("generalSettings")
                            .getChild("lastOpenFolder");
                    JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText());
                    fc.setDialogTitle("Save Report Data");
                    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                    fc.setFileFilter(new XMLFileFilter());

                    int returnVal = fc.showSaveDialog(ItSIMPLE.this);
                    if (returnVal == JFileChooser.APPROVE_OPTION) {
                        File selectedFile = fc.getSelectedFile();
                        String path = selectedFile.getPath();

                        if (!path.toLowerCase().endsWith(".xml")) {
                            path += ".xml";
                        }
                        //save file (xml)
                        try {
                            FileWriter file = new FileWriter(path);
                            file.write(XMLUtilities.toString(solveResult));
                            file.close();
                        } catch (IOException e1) {
                            e1.printStackTrace();
                        }

                        //Save as a last open folder
                        String folder = selectedFile.getParent();
                        //Element lastOpenFolderElement = itSettings.getChild("generalSettings").getChild("lastOpenFolder");
                        lastOpenFolderElement.setText(folder);
                        XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());

                        //Ask if the user wants to save plans individually too.
                        boolean needToSavePlans = false;
                        int option = JOptionPane.showOptionDialog(instance,
                                "<html><center>Do you also want to save the plans"
                                        + "<br>in individual files?</center></html>",
                                "Save plans", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                                null, null);
                        switch (option) {
                        case JOptionPane.YES_OPTION: {
                            needToSavePlans = true;
                        }
                            break;
                        case JOptionPane.NO_OPTION: {
                            needToSavePlans = false;
                        }
                            break;
                        }

                        if (needToSavePlans) {
                            //Close Open tabs
                            List<?> problems = null;
                            try {
                                XPath ppath = new JDOMXPath("project/domains/domain/problems/problem");
                                problems = ppath.selectNodes(solveResult);
                            } catch (JaxenException e2) {
                                e2.printStackTrace();
                            }

                            for (int i = 0; i < problems.size(); i++) {
                                Element problem = (Element) problems.get(i);
                                //create a folder for each problem and put all plans inside as xml files
                                String folderName = problem.getChildText("name");
                                String folderPath = selectedFile.getAbsolutePath()
                                        .replace(selectedFile.getName(), folderName);
                                //System.out.println(folderPath);
                                File planfolder = new File(folderPath);
                                boolean canSavePlan = false;
                                try {
                                    if (planfolder.mkdir()) {
                                        System.out.println("Directory '" + folderPath + "' created.");
                                        canSavePlan = true;
                                    } else {
                                        System.out.println("Directory '" + folderPath + "' was not created.");
                                    }

                                } catch (Exception ep) {
                                    ep.printStackTrace();
                                }

                                if (canSavePlan) {
                                    Element plans = problem.getChild("plans");
                                    for (Iterator<Element> it = plans.getChildren("xmlPlan").iterator(); it
                                            .hasNext();) {
                                        Element eaplan = it.next();
                                        Element theplanner = eaplan.getChild("planner");
                                        //save file (xml)
                                        String planFileName = "solution" + theplanner.getChildText("name") + "-"
                                                + theplanner.getChildText("version") + "-"
                                                + Integer.toString(plans.getChildren().indexOf(eaplan))
                                                + ".xml";
                                        String planPath = folderPath + File.separator + planFileName;
                                        /*
                                        try {
                                            FileWriter planfile = new FileWriter(planPath);
                                            planfile.write(XMLUtilities.toString(eaplan));
                                            planfile.close();
                                            System.out.println("File '" + planPath + "' created.");
                                        } catch (IOException e1) {
                                            e1.printStackTrace();
                                        }
                                        *
                                        */
                                        if (eaplan.getChild("plan").getChildren().size() > 0) {

                                            //TODO: save the plan in PDDL too. It should be done through the XPDDL/PDDL classes
                                            String pddlplan = ToXPDDL.XMLtoXPDDLPlan(eaplan);
                                            String planFileNamePDDL = "solution"
                                                    + theplanner.getChildText("name") + "-"
                                                    + theplanner.getChildText("version") + "-"
                                                    + Integer.toString(plans.getChildren().indexOf(eaplan))
                                                    + ".pddl";
                                            String planPathPDDL = folderPath + File.separator
                                                    + planFileNamePDDL;

                                            //String cfolderPath = selectedFile.getAbsolutePath().replace(selectedFile.getName(), "");
                                            //String planFileNamePDDL = theplanner.getChildText("name")+"-"+theplanner.getChildText("version") + "-" + folderName+"-solution.pddl";
                                            //String planPathPDDL = cfolderPath + File.separator + planFileNamePDDL;
                                            //if (!theplanner.getChildText("name").contains("MIPS")){
                                            try {
                                                FileWriter planfile = new FileWriter(planPathPDDL);
                                                planfile.write(pddlplan);
                                                planfile.close();
                                                System.out.println("File '" + planPathPDDL + "' created.");
                                            } catch (IOException e1) {
                                                e1.printStackTrace();
                                            }
                                        } //}

                                    }

                                }

                            }
                        }

                    }
                } else {
                    appendOutputPanelText(">> No report data available to save! \n");
                }

            }
        });
        resultsToolBar.add(planReportDataButton);

        JButton openPlanReportDataButton = new JButton("Open Report Data",
                new ImageIcon("resources/images/openreport.png"));
        openPlanReportDataButton.setToolTipText("<html>Open report data to file</html>");
        openPlanReportDataButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                planSimStatusBar.setText("Status: Opening File...");
                appendOutputPanelText(">> Opening File... \n");
                //Open report data
                Element lastOpenFolderElement = itSettings.getChild("generalSettings")
                        .getChild("lastOpenFolder");
                JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText());
                fc.setDialogTitle("Open Report Data");
                fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                fc.setFileFilter(new XMLFileFilter());

                int returnVal = fc.showOpenDialog(ItSIMPLE.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {

                    File file = fc.getSelectedFile();
                    // Get itSIMPLE itSettings from itSettings.xml
                    org.jdom.Document resultsDoc = null;
                    try {
                        resultsDoc = XMLUtilities.readFromFile(file.getPath());
                        solveResult = resultsDoc.getRootElement();
                        //XMLUtilities.printXML(solveResult);
                        if (solveResult.getName().equals("projects")) {

                            String report = PlanAnalyzer.generatePlannersComparisonReport(solveResult);
                            String comparisonReport = PlanAnalyzer
                                    .generateFullPlannersComparisonReport(solveResult);
                            //Save Comparison Report file
                            saveFile("resources/report/Report.html", comparisonReport);
                            setPlanInfoPanelText(report);
                            setPlanEvaluationInfoPanelText("");
                            appendOutputPanelText(">> Report data read! \n");

                            //My experiments
                            PlanAnalyzer.myAnalysis(itPlanners.getChild("planners"), solveResult);
                        }
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }

                    //Save as a last open folder
                    String folder = fc.getSelectedFile().getParent();
                    lastOpenFolderElement.setText(folder);
                    XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());

                } else {
                    planSimStatusBar.setText("Status:");
                    appendOutputPanelText(">> Canceled \n");
                }

            }
        });
        resultsToolBar.add(openPlanReportDataButton);

        JButton compareProjectReportDataButton = new JButton("Compare Project Data",
                new ImageIcon("resources/images/compare.png"));
        compareProjectReportDataButton.setToolTipText(
                "<html>Compare different project report data <br> This is commonly use to compare diferent domain models with different adjustments.<br>"
                        + "One project data must be chosen as a reference; others will be compared to this referencial one.</html>");
        compareProjectReportDataButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                final ProjectComparisonDialog dialog = new ProjectComparisonDialog();
                dialog.setVisible(true);

                final List<String> files = dialog.getFiles();

                if (files.size() > 1) {

                    new Thread() {
                        public void run() {
                            appendOutputPanelText(">> Project comparison report requested. Processing... \n");

                            planSimStatusBar.setText("Status: Reading files ...");
                            appendOutputPanelText(">> Reading files ... \n");

                            //base project file
                            String baseFileName = files.get(0);
                            appendOutputPanelText(">> Reading file '" + baseFileName + "' \n");
                            org.jdom.Document baseProjectDoc = null;
                            try {
                                baseProjectDoc = XMLUtilities.readFromFile(baseFileName);
                            } catch (Exception ec) {
                                ec.printStackTrace();
                            }
                            Element baseProject = null;
                            if (baseProjectDoc != null) {
                                baseProject = baseProjectDoc.getRootElement().getChild("project");
                            }

                            //The comparible projects
                            List<Element> comparableProjects = new ArrayList<Element>();

                            for (int i = 1; i < files.size(); i++) {
                                String eafile = files.get(i);
                                appendOutputPanelText(">> Reading file '" + eafile + "' \n");
                                org.jdom.Document eaProjectDoc = null;
                                try {
                                    eaProjectDoc = XMLUtilities.readFromFile(eafile);
                                } catch (Exception ec) {
                                    ec.printStackTrace();
                                }
                                if (eaProjectDoc != null) {
                                    comparableProjects.add(eaProjectDoc.getRootElement().getChild("project"));
                                }

                            }
                            appendOutputPanelText(">> Files read. Building report... \n");

                            String comparisonReport = PlanAnalyzer.generateProjectComparisonReport(baseProject,
                                    comparableProjects);
                            saveFile("resources/report/Report.html", comparisonReport);
                            appendOutputPanelText(
                                    ">> Project comparison report generated. Press 'View Full Report'\n");
                            appendOutputPanelText(" \n");

                        }
                    }.start();

                }

            }
        });
        resultsToolBar.add(compareProjectReportDataButton);

        resultsPanel.add(resultsToolBar, BorderLayout.NORTH);
        resultsPanel.add(new JScrollPane(planInfoEditorPane), BorderLayout.CENTER);

        JTabbedPane planAnalysisTabbedPane = new JTabbedPane();
        planAnalysisTabbedPane.addTab("Results", resultsPanel);
        planAnalysisTabbedPane.addTab("Variable Tracking", mainChartsPanel);
        planAnalysisTabbedPane.addTab("Movie Maker", getMovieMakerPanel());
        planAnalysisTabbedPane.addTab("Plan Evaluation", getPlanEvaluationPanel());
        planAnalysisTabbedPane.addTab("Plan Database", getPlanDatabasePanel());
        planAnalysisTabbedPane.addTab("Rationale Database", getRationaleDatabasePanel());

        JPanel planAnalysisPanel = new JPanel(new BorderLayout());
        //planAnalysisPanel.add(chartsToolBar, BorderLayout.NORTH);
        planAnalysisPanel.add(planAnalysisTabbedPane, BorderLayout.CENTER);
        planAnalysisFramePanel.setContent(planAnalysisPanel, false);

    }

    return planAnalysisFramePanel;
}

From source file:ca.uhn.hl7v2.testpanel.ui.TestPanelWindow.java

/**
 * Initialize the contents of the frame.
 *//*from w  ww  .j  ava 2s . c o m*/
private void initialize() {
    myframe = new JFrame();
    myframe.setVisible(false);

    List<Image> l = new ArrayList<Image>();
    l.add(Toolkit.getDefaultToolkit()
            .getImage(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_16.png")));
    l.add(Toolkit.getDefaultToolkit()
            .getImage(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_64.png")));

    myframe.setIconImages(l);
    myframe.setTitle("HAPI TestPanel");
    myframe.setBounds(100, 100, 796, 603);
    myframe.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    myframe.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent theE) {
            myController.close();
        }
    });

    JMenuBar menuBar = new JMenuBar();
    myframe.setJMenuBar(menuBar);

    JMenu mnFile = new JMenu("File");
    mnFile.setMnemonic('f');
    menuBar.add(mnFile);

    JMenuItem mntmExit = new JMenuItem("Exit");
    mntmExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            myController.close();
        }
    });

    JMenuItem mntmNewMessage = new JMenuItem("New Message...");
    mntmNewMessage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.addMessage();
        }
    });
    mntmNewMessage.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/message_hl7.png")));
    mnFile.add(mntmNewMessage);

    mySaveMenuItem = new JMenuItem("Save");
    mySaveMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mySaveMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSaveMessages();
        }
    });
    mnFile.add(mySaveMenuItem);

    mySaveAsMenuItem = new JMenuItem("Save As...");
    mySaveAsMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSaveMessagesAs();
        }
    });
    mnFile.add(mySaveAsMenuItem);

    mymenuItem_3 = new JMenuItem("Open");
    mymenuItem_3.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mymenuItem_3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.openMessages();
        }
    });

    myRevertToSavedMenuItem = new JMenuItem("Revert to Saved");
    myRevertToSavedMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.revertMessage((Hl7V2MessageCollection) myController.getLeftSelectedItem());
        }
    });
    mnFile.add(myRevertToSavedMenuItem);
    mnFile.add(mymenuItem_3);

    myRecentFilesMenu = new JMenu("Open Recent");
    mnFile.add(myRecentFilesMenu);

    JSeparator separator = new JSeparator();
    mnFile.add(separator);
    mnFile.add(mntmExit);

    JMenu mnNewMenu = new JMenu("View");
    mnNewMenu.setMnemonic('v');
    menuBar.add(mnNewMenu);

    myShowLogConsoleMenuItem = new JMenuItem("Show Log Console");
    myShowLogConsoleMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Prefs.getInstance().setShowLogConsole(!Prefs.getInstance().getShowLogConsole());
            updateLogScrollPaneVisibility();
            myframe.validate();
        }
    });
    mnNewMenu.add(myShowLogConsoleMenuItem);

    mymenu_1 = new JMenu("Test");
    menuBar.add(mymenu_1);

    mymenuItem_1 = new JMenuItem("Populate TestPanel with Sample Message and Connections...");
    mymenuItem_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.populateWithSampleMessageAndConnections();
        }
    });
    mymenu_1.add(mymenuItem_1);

    mymenu_3 = new JMenu("Tools");
    menuBar.add(mymenu_3);

    mnHl7V2FileDiff = new JMenuItem("HL7 v2 File Diff...");
    mnHl7V2FileDiff.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (myHl7V2FileDiff == null) {
                myHl7V2FileDiff = new Hl7V2FileDiffController(myController);
            }
            myHl7V2FileDiff.show();
        }
    });
    mymenu_3.add(mnHl7V2FileDiff);

    mymenuItem_5 = new JMenuItem("HL7 v2 File Sort...");
    mymenuItem_5.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (myHl7V2FileSort == null) {
                myHl7V2FileSort = new Hl7V2FileSortController(myController);
            }
            myHl7V2FileSort.show();
        }
    });
    mymenu_3.add(mymenuItem_5);

    mymenu_2 = new JMenu("Conformance");
    menuBar.add(mymenu_2);

    mymenuItem_2 = new JMenuItem("Profiles and Tables...");
    mymenuItem_2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.showProfilesAndTablesEditor();
        }
    });
    mymenu_2.add(mymenuItem_2);

    mymenu = new JMenu("Help");
    mymenu.setMnemonic('H');
    menuBar.add(mymenu);

    mymenuItem = new JMenuItem("About HAPI TestPanel...");
    mymenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showAboutDialog();
        }
    });
    mymenuItem.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_16.png")));
    mymenu.add(mymenuItem);

    mymenuItem_4 = new JMenuItem("Licenses...");
    mymenuItem_4.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new LicensesDialog().setVisible(true);
        }
    });
    mymenu.add(mymenuItem_4);
    myframe.getContentPane().setLayout(new BorderLayout(0, 0));

    JSplitPane outerSplitPane = new JSplitPane();
    outerSplitPane.setBorder(null);
    myframe.getContentPane().add(outerSplitPane);

    JSplitPane leftSplitPane = new JSplitPane();
    leftSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    outerSplitPane.setLeftComponent(leftSplitPane);

    JPanel messagesPanel = new JPanel();
    leftSplitPane.setLeftComponent(messagesPanel);
    GridBagLayout gbl_messagesPanel = new GridBagLayout();
    gbl_messagesPanel.columnWidths = new int[] { 110, 0 };
    gbl_messagesPanel.rowHeights = new int[] { 20, 30, 118, 0, 0 };
    gbl_messagesPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_messagesPanel.rowWeights = new double[] { 0.0, 0.0, 100.0, 1.0, Double.MIN_VALUE };
    messagesPanel.setLayout(gbl_messagesPanel);

    JLabel lblMessages = new JLabel("Messages");
    GridBagConstraints gbc_lblMessages = new GridBagConstraints();
    gbc_lblMessages.insets = new Insets(0, 0, 5, 0);
    gbc_lblMessages.gridx = 0;
    gbc_lblMessages.gridy = 0;
    messagesPanel.add(lblMessages, gbc_lblMessages);

    JToolBar messagesToolBar = new JToolBar();
    messagesToolBar.setFloatable(false);
    messagesToolBar.setRollover(true);
    messagesToolBar.setAlignmentX(Component.LEFT_ALIGNMENT);
    GridBagConstraints gbc_messagesToolBar = new GridBagConstraints();
    gbc_messagesToolBar.insets = new Insets(0, 0, 5, 0);
    gbc_messagesToolBar.weightx = 1.0;
    gbc_messagesToolBar.anchor = GridBagConstraints.NORTHWEST;
    gbc_messagesToolBar.gridx = 0;
    gbc_messagesToolBar.gridy = 1;
    messagesPanel.add(messagesToolBar, gbc_messagesToolBar);

    JButton msgOpenButton = new JButton("");
    msgOpenButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.openMessages();
        }
    });

    myAddMessageButton = new JButton("");
    myAddMessageButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.addMessage();
        }
    });
    myAddMessageButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png")));
    myAddMessageButton.setToolTipText("New Message");
    myAddMessageButton.setBorderPainted(false);
    myAddMessageButton.addMouseListener(new HoverButtonMouseAdapter(myAddMessageButton));
    messagesToolBar.add(myAddMessageButton);

    myDeleteMessageButton = new JButton("");
    myDeleteMessageButton.setToolTipText("Close Selected Message");
    myDeleteMessageButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.closeMessage((Hl7V2MessageCollection) myController.getLeftSelectedItem());
        }
    });
    myDeleteMessageButton.setBorderPainted(false);
    myDeleteMessageButton.addMouseListener(new HoverButtonMouseAdapter(myDeleteMessageButton));
    myDeleteMessageButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/close.png")));
    messagesToolBar.add(myDeleteMessageButton);
    msgOpenButton.setBorderPainted(false);
    msgOpenButton.setToolTipText("Open Messages from File");
    msgOpenButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png")));
    msgOpenButton.addMouseListener(new HoverButtonMouseAdapter(msgOpenButton));
    messagesToolBar.add(msgOpenButton);

    myMsgSaveButton = new JButton("");
    myMsgSaveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSaveMessages();
        }
    });
    myMsgSaveButton.setBorderPainted(false);
    myMsgSaveButton.setToolTipText("Save Selected Messages to File");
    myMsgSaveButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/save.png")));
    myMsgSaveButton.addMouseListener(new HoverButtonMouseAdapter(myMsgSaveButton));
    messagesToolBar.add(myMsgSaveButton);

    myMessagesList = new JList();
    myMessagesList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (myMessagesList.getSelectedIndex() >= 0) {
                ourLog.debug("New messages selection " + myMessagesList.getSelectedIndex());
                myController.setLeftSelectedItem(myMessagesList.getSelectedValue());
                myOutboundConnectionsList.clearSelection();
                myOutboundConnectionsList.repaint();
                myInboundConnectionsList.clearSelection();
                myInboundConnectionsList.repaint();
            }
            updateLeftToolbarButtons();
        }
    });
    GridBagConstraints gbc_MessagesList = new GridBagConstraints();
    gbc_MessagesList.gridheight = 2;
    gbc_MessagesList.weightx = 1.0;
    gbc_MessagesList.weighty = 1.0;
    gbc_MessagesList.fill = GridBagConstraints.BOTH;
    gbc_MessagesList.gridx = 0;
    gbc_MessagesList.gridy = 2;
    messagesPanel.add(myMessagesList, gbc_MessagesList);

    JPanel connectionsPanel = new JPanel();
    leftSplitPane.setRightComponent(connectionsPanel);
    GridBagLayout gbl_connectionsPanel = new GridBagLayout();
    gbl_connectionsPanel.columnWidths = new int[] { 194, 0 };
    gbl_connectionsPanel.rowHeights = new int[] { 0, 30, 0, 0, 0, 0, 0 };
    gbl_connectionsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_connectionsPanel.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
    connectionsPanel.setLayout(gbl_connectionsPanel);

    JLabel lblConnections = new JLabel("Sending Connections");
    lblConnections.setHorizontalAlignment(SwingConstants.CENTER);
    GridBagConstraints gbc_lblConnections = new GridBagConstraints();
    gbc_lblConnections.insets = new Insets(0, 0, 5, 0);
    gbc_lblConnections.anchor = GridBagConstraints.NORTH;
    gbc_lblConnections.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblConnections.gridx = 0;
    gbc_lblConnections.gridy = 0;
    connectionsPanel.add(lblConnections, gbc_lblConnections);

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    GridBagConstraints gbc_toolBar = new GridBagConstraints();
    gbc_toolBar.insets = new Insets(0, 0, 5, 0);
    gbc_toolBar.anchor = GridBagConstraints.NORTH;
    gbc_toolBar.fill = GridBagConstraints.HORIZONTAL;
    gbc_toolBar.gridx = 0;
    gbc_toolBar.gridy = 1;
    connectionsPanel.add(toolBar, gbc_toolBar);

    myAddConnectionButton = new JButton("");
    myAddConnectionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.addOutboundConnection();
        }
    });
    myAddConnectionButton.setBorderPainted(false);
    myAddConnectionButton.addMouseListener(new HoverButtonMouseAdapter(myAddConnectionButton));
    myAddConnectionButton.setBorder(null);
    myAddConnectionButton.setToolTipText("New Connection");
    myAddConnectionButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png")));
    toolBar.add(myAddConnectionButton);

    myDeleteOutboundConnectionButton = new JButton("");
    myDeleteOutboundConnectionButton.setToolTipText("Delete Selected Connection");
    myDeleteOutboundConnectionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (myController.getLeftSelectedItem() instanceof OutboundConnection) {
                myController.removeOutboundConnection((OutboundConnection) myController.getLeftSelectedItem());
            }
        }
    });
    myDeleteOutboundConnectionButton.setBorderPainted(false);
    myDeleteOutboundConnectionButton
            .addMouseListener(new HoverButtonMouseAdapter(myDeleteOutboundConnectionButton));
    myDeleteOutboundConnectionButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/delete.png")));
    toolBar.add(myDeleteOutboundConnectionButton);

    myStartOneOutboundButton = new JButton("");
    myStartOneOutboundButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (myController.getLeftSelectedItem() instanceof OutboundConnection) {
                myController.startOutboundConnection((OutboundConnection) myController.getLeftSelectedItem());
            }
        }
    });
    myStartOneOutboundButton.setBorderPainted(false);
    myStartOneOutboundButton.setToolTipText("Start selected connection");
    myStartOneOutboundButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_one.png")));
    myStartOneOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartOneOutboundButton));
    toolBar.add(myStartOneOutboundButton);

    myStartAllOutboundButton = new JButton("");
    myStartAllOutboundButton.setBorderPainted(false);
    myStartAllOutboundButton.setToolTipText("Start all sending connections");
    myStartAllOutboundButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_all.png")));
    myStartAllOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartAllOutboundButton));
    myStartAllOutboundButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent theE) {
            myController.startAllOutboundConnections();
        }
    });
    toolBar.add(myStartAllOutboundButton);

    myStopAllOutboundButton = new JButton("");
    myStopAllOutboundButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.stopAllOutboundConnections();
        }
    });
    myStopAllOutboundButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/stop_all.png")));
    myStopAllOutboundButton.setToolTipText("Stop all sending connections");
    myStopAllOutboundButton.setBorderPainted(false);
    myStopAllOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStopAllOutboundButton));
    toolBar.add(myStopAllOutboundButton);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(null);
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
    gbc_scrollPane.gridx = 0;
    gbc_scrollPane.gridy = 2;
    connectionsPanel.add(scrollPane, gbc_scrollPane);

    myOutboundConnectionsList = new JList();
    myOutboundConnectionsList.setBorder(null);
    myOutboundConnectionsList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (myOutboundConnectionsList.getSelectedIndex() >= 0) {
                ourLog.debug(
                        "New outbound connection selection " + myOutboundConnectionsList.getSelectedIndex());
                myController.setLeftSelectedItem(myOutboundConnectionsList.getSelectedValue());
                myMessagesList.clearSelection();
                myMessagesList.repaint();
                myInboundConnectionsList.clearSelection();
                myInboundConnectionsList.repaint();
            }
            updateLeftToolbarButtons();
        }
    });
    scrollPane.setViewportView(myOutboundConnectionsList);

    JLabel lblReceivingConnections = new JLabel("Receiving Connections");
    lblReceivingConnections.setHorizontalAlignment(SwingConstants.CENTER);
    GridBagConstraints gbc_lblReceivingConnections = new GridBagConstraints();
    gbc_lblReceivingConnections.insets = new Insets(0, 0, 5, 0);
    gbc_lblReceivingConnections.gridx = 0;
    gbc_lblReceivingConnections.gridy = 3;
    connectionsPanel.add(lblReceivingConnections, gbc_lblReceivingConnections);

    JToolBar toolBar_1 = new JToolBar();
    toolBar_1.setFloatable(false);
    GridBagConstraints gbc_toolBar_1 = new GridBagConstraints();
    gbc_toolBar_1.anchor = GridBagConstraints.WEST;
    gbc_toolBar_1.insets = new Insets(0, 0, 5, 0);
    gbc_toolBar_1.gridx = 0;
    gbc_toolBar_1.gridy = 4;
    connectionsPanel.add(toolBar_1, gbc_toolBar_1);

    myAddInboundConnectionButton = new JButton("");
    myAddInboundConnectionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.addInboundConnection();
        }
    });
    myAddInboundConnectionButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png")));
    myAddInboundConnectionButton.setToolTipText("New Connection");
    myAddInboundConnectionButton.setBorderPainted(false);
    myAddInboundConnectionButton.addMouseListener(new HoverButtonMouseAdapter(myAddInboundConnectionButton));
    toolBar_1.add(myAddInboundConnectionButton);

    myDeleteInboundConnectionButton = new JButton("");
    myDeleteInboundConnectionButton.setToolTipText("Delete Selected Connection");
    myDeleteInboundConnectionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (myController.getLeftSelectedItem() instanceof InboundConnection) {
                myController.removeInboundConnection((InboundConnection) myController.getLeftSelectedItem());
            }
        }
    });
    myDeleteInboundConnectionButton.setBorderPainted(false);
    myDeleteInboundConnectionButton
            .addMouseListener(new HoverButtonMouseAdapter(myDeleteInboundConnectionButton));
    myDeleteInboundConnectionButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/delete.png")));
    toolBar_1.add(myDeleteInboundConnectionButton);

    myStartOneInboundButton = new JButton("");
    myStartOneInboundButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (myController.getLeftSelectedItem() instanceof InboundConnection) {
                myController.startInboundConnection((InboundConnection) myController.getLeftSelectedItem());
            }
        }
    });
    myStartOneInboundButton.setBorderPainted(false);
    myStartOneInboundButton.setToolTipText("Start selected connection");
    myStartOneInboundButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_one.png")));
    myStartOneInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartOneInboundButton));
    toolBar_1.add(myStartOneInboundButton);

    myStartAllInboundButton = new JButton("");
    myStartAllInboundButton.setBorderPainted(false);
    myStartAllInboundButton.setToolTipText("Start all receiving connections");
    myStartAllInboundButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_all.png")));
    myStartAllInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartAllInboundButton));
    myStartAllInboundButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent theE) {
            myController.startAllInboundConnections();
        }
    });
    toolBar_1.add(myStartAllInboundButton);

    myStopAllInboundButton = new JButton("");
    myStopAllInboundButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myController.stopAllInboundConnections();
        }
    });
    myStopAllInboundButton.setIcon(
            new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/stop_all.png")));
    myStopAllInboundButton.setToolTipText("Stop all receiving connections");
    myStopAllInboundButton.setBorderPainted(false);
    myStopAllInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStopAllInboundButton));
    toolBar_1.add(myStopAllInboundButton);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBorder(null);
    GridBagConstraints gbc_scrollPane_1 = new GridBagConstraints();
    gbc_scrollPane_1.fill = GridBagConstraints.BOTH;
    gbc_scrollPane_1.gridx = 0;
    gbc_scrollPane_1.gridy = 5;
    connectionsPanel.add(scrollPane_1, gbc_scrollPane_1);

    myInboundConnectionsList = new JList();
    myInboundConnectionsList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (myInboundConnectionsList.getSelectedIndex() >= 0) {
                ourLog.debug("New inbound connection selection " + myInboundConnectionsList.getSelectedIndex());
                myController.setLeftSelectedItem(myInboundConnectionsList.getSelectedValue());
                myMessagesList.clearSelection();
                myMessagesList.repaint();
                myOutboundConnectionsList.clearSelection();
                myOutboundConnectionsList.repaint();
                myInboundConnectionsList.repaint();
            }
            updateLeftToolbarButtons();
        }
    });
    scrollPane_1.setViewportView(myInboundConnectionsList);
    leftSplitPane.setDividerLocation(200);

    myWorkspacePanel = new JPanel();
    myWorkspacePanel.setBorder(null);
    outerSplitPane.setRightComponent(myWorkspacePanel);
    myWorkspacePanel.setLayout(new BorderLayout(0, 0));
    outerSplitPane.setDividerLocation(200);

    myLogScrollPane = new LogTable();
    myLogScrollPane.setPreferredSize(new Dimension(454, 120));
    myLogScrollPane.setMaximumSize(new Dimension(32767, 120));
    myframe.getContentPane().add(myLogScrollPane, BorderLayout.SOUTH);

    updateLogScrollPaneVisibility();

    updateLeftToolbarButtons();
}

From source file:net.sourceforge.pmd.util.designer.Designer.java

public Designer(String[] args) {
    if (args.length > 0) {
        exitOnClose = !args[0].equals("-noexitonclose");
    }//ww w  .j  a  v a 2 s.c o  m

    Initializer.initialize();

    xpathQueryArea.setFont(new Font("Verdana", Font.PLAIN, 16));
    JSplitPane controlSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, createCodeEditorPanel(),
            createXPathQueryPanel());

    JSplitPane astAndSymbolTablePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createASTPanel(),
            createSymbolTableResultPanel());

    JSplitPane resultsSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, astAndSymbolTablePane,
            createXPathResultPanel());

    JTabbedPane tabbed = new JTabbedPane();
    tabbed.addTab("Abstract Syntax Tree / XPath / Symbol Table", resultsSplitPane);
    tabbed.addTab("Data Flow Analysis", dfaPanel);
    tabbed.setMnemonicAt(0, KeyEvent.VK_A);
    tabbed.setMnemonicAt(1, KeyEvent.VK_D);

    JSplitPane containerSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, controlSplitPane, tabbed);
    containerSplitPane.setContinuousLayout(true);

    JMenuBar menuBar = createMenuBar();
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(containerSplitPane);
    frame.setDefaultCloseOperation(exitOnClose ? JFrame.EXIT_ON_CLOSE : WindowConstants.DISPOSE_ON_CLOSE);

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;

    frame.pack();
    frame.setSize(screenWidth * 3 / 4, screenHeight * 3 / 4);
    frame.setLocation((screenWidth - frame.getWidth()) / 2, (screenHeight - frame.getHeight()) / 2);
    frame.setVisible(true);
    int horozontalMiddleLocation = controlSplitPane.getMaximumDividerLocation() * 3 / 5;
    controlSplitPane.setDividerLocation(horozontalMiddleLocation);
    containerSplitPane.setDividerLocation(containerSplitPane.getMaximumDividerLocation() / 2);
    astAndSymbolTablePane.setDividerLocation(astAndSymbolTablePane.getMaximumDividerLocation() / 3);
    resultsSplitPane.setDividerLocation(horozontalMiddleLocation);

    loadSettings();
}

From source file:net.sourceforge.squirrel_sql.client.gui.HelpViewerWindow.java

/**
 * Create user interface./*from w  w  w .ja v  a 2 s  .co  m*/
 */
private void createGUI() throws IOException {
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    final SquirrelResources rsrc = _app.getResources();
    final ImageIcon icon = rsrc.getIcon(SquirrelResources.IImageNames.VIEW);
    if (icon != null) {
        setIconImage(icon.getImage());
    }

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setBorder(BorderFactory.createEmptyBorder());
    splitPane.setOneTouchExpandable(true);
    splitPane.setContinuousLayout(true);
    splitPane.add(createContentsTree(), JSplitPane.LEFT);
    splitPane.add(createDetailsPanel(), JSplitPane.RIGHT);
    contentPane.add(splitPane, BorderLayout.CENTER);
    splitPane.setDividerLocation(200);

    contentPane.add(new HtmlViewerPanelToolBar(_app, _detailPnl), BorderLayout.NORTH);

    Font fn = _app.getFontInfoStore().getStatusBarFontInfo().createFont();
    _statusBar.setFont(fn);
    contentPane.add(_statusBar, BorderLayout.SOUTH);

    pack();

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            _detailPnl.setHomeURL(_homeURL);
            _tree.expandRow(0);
            _tree.expandRow(2);
            if (_app.getSquirrelPreferences().isFirstRun()) {
                _tree.setSelectionRow(1);
            } else {
                _tree.setSelectionRow(3);
            }
            _tree.setRootVisible(false);
        }
    });

    _detailPnl.addListener(new IHtmlViewerPanelListener() {
        public void currentURLHasChanged(HtmlViewerPanelListenerEvent evt) {
            selectTreeNodeForURL(evt.getHtmlViewerPanel().getURL());
        }

        public void homeURLHasChanged(HtmlViewerPanelListenerEvent evt) {
            // Nothing to do.
        }
    });
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

public void checkForInitialLoadScreenSizes(final FormControl control, final JSplitPane verticalMain,
        final String verticalMainName, final JSplitPane verticalSub, final String verticalSubName,
        final JSplitPane horizontalMain, final String horizontalMainName, final JSplitPane horizontalSub,
        final String horizontalSubName) {
    if ((control.getWidth() == -1) && (control.getHeight() == -1) && (control.getLeft() == -1)
            && (control.getTop() == -1)) {
        final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        final GraphicsDevice[] gs = ge.getScreenDevices();
        if (gs.length > 0) {
            final DisplayMode dm = gs[0].getDisplayMode();
            final int screenWidth = dm.getWidth() - 20;
            final int screenHeight = dm.getHeight() - 50;
            // Set form bounds
            control.setTop(10);/*from  w w  w .  j  a v  a2s . c o  m*/
            control.setLeft(10);
            control.setWidth(screenWidth);
            control.setHeight(screenHeight);
            control.resizeScreen();
            // Set divider positions
            int dividerPosition = 175;
            verticalMain.setDividerLocation(dividerPosition);
            control.setExtra(verticalMainName, dividerPosition);
            dividerPosition = screenHeight / 3;
            verticalSub.setDividerLocation(dividerPosition);
            control.setExtra(verticalSubName, dividerPosition);
            dividerPosition = screenWidth / 3;
            horizontalMain.setDividerLocation(dividerPosition);
            control.setExtra(horizontalMainName, dividerPosition);
            horizontalSub.setDividerLocation(dividerPosition);
            control.setExtra(horizontalSubName, dividerPosition);
        }
    }

}

From source file:op.tools.SYSTools.java

/**
 * Setzt eine Split Pane (animiert oder nicht animiert) auf eine entsprechende Position (Prozentual zwischen 0 und 1)
 *
 * @param split/*from   www.  j  a v a  2  s . com*/
 * @param stop
 * @param speedInMillis
 * @return Die neue, relative Position (zwischen 0 und 1)
 */
public static double showSide(final JSplitPane split, final double stop, int speedInMillis) {

    if (OPDE.isAnimation() && speedInMillis > 0) {
        OPDE.debug("ShowSide double-version");
        final double start = new Double(split.getDividerLocation())
                / new Double(getDividerInAbsolutePosition(split, 1.0d));

        final TimingSource ts = new SwingTimerTimingSource();
        Animator.setDefaultTimingSource(ts);
        ts.init();
        Animator animator = new Animator.Builder().setInterpolator(new AccelerationInterpolator(0.2, 0.2))
                .setDuration(speedInMillis, TimeUnit.MILLISECONDS).setRepeatCount(1)
                .setStartDirection(Animator.Direction.FORWARD).addTarget(new TimingTargetAdapter() {
                    double differenz = stop - start;

                    @Override
                    public void timingEvent(Animator animator, double fraction) {
                        split.setDividerLocation(start + (differenz * fraction));
                    }

                }).build();

        animator.start();

    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                split.setDividerLocation(stop);
            }
        });
    }
    return stop;
}

From source file:org.apache.cassandra.contrib.circuit.CircuitFrame.java

public CircuitFrame(String hostname, int port) {
    super(appTitle);
    setSize(defaultSize);/*w  w w.jav  a2s .  c o m*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // The menu bar w/ items.
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);

    quitMI = new JMenuItem("Quit");
    quitMI.setMnemonic(KeyEvent.VK_Q);
    quitMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, Event.CTRL_MASK));
    quitMI.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    fileMenu.add(quitMI);

    JMenu toolsMenu = new JMenu("Tools");
    toolsMenu.setMnemonic(KeyEvent.VK_T);
    menuBar.add(toolsMenu);

    verifyMI = new JMenuItem("Verify Ring");
    verifyMI.addActionListener(this);
    toolsMenu.add(verifyMI);

    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(helpMenu);

    aboutMI = new JMenuItem("About");
    aboutMI.setMnemonic(KeyEvent.VK_A);
    aboutMI.addActionListener(this);
    helpMenu.add(aboutMI);

    // FIXME: a progress dialog should be up while instantiating RingPanel
    ringModel = new RingModel(hostname, port);
    ringPanel = new RingPanel(ringModel);

    statusOutput = new JTextArea();
    statusOutput.setEditable(false);
    Component logPanel = new JScrollPane(statusOutput);

    JSplitPane contentPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, ringPanel, logPanel);
    setContentPane(contentPane);

    // Order matters here...
    ringPanel.setPreferredSize(getSize());
    setVisible(true);
    contentPane.setDividerLocation(0.8);
}

From source file:org.apache.jackrabbit.oak.explorer.Explorer.java

private void createAndShowGUI(final File path, boolean skipSizeCheck) throws IOException {
    JTextArea log = new JTextArea(5, 20);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setLineWrap(true);/*from   w  w w  . ja v  a2s  . c  om*/
    log.setEditable(false);

    final NodeStoreTree treePanel = new NodeStoreTree(backend, log, skipSizeCheck);

    final JFrame frame = new JFrame("Explore " + path + " @head");
    frame.addWindowListener(new java.awt.event.WindowAdapter() {
        @Override
        public void windowClosing(java.awt.event.WindowEvent windowEvent) {
            IOUtils.closeQuietly(treePanel);
            System.exit(0);
        }
    });

    JPanel content = new JPanel(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(treePanel),
            new JScrollPane(log));
    splitPane.setDividerLocation(0.3);
    content.add(new JScrollPane(splitPane), c);
    frame.getContentPane().add(content);

    JMenuBar menuBar = new JMenuBar();
    menuBar.setMargin(new Insets(2, 2, 2, 2));

    JMenuItem menuReopen = new JMenuItem("Reopen");
    menuReopen.setMnemonic(KeyEvent.VK_R);
    menuReopen.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            try {
                treePanel.reopen();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    });

    JMenuItem menuCompaction = new JMenuItem("Time Machine");
    menuCompaction.setMnemonic(KeyEvent.VK_T);
    menuCompaction.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            List<String> revs = backend.readRevisions();
            String s = (String) JOptionPane.showInputDialog(frame, "Revert to a specified revision",
                    "Time Machine", JOptionPane.PLAIN_MESSAGE, null, revs.toArray(), revs.get(0));
            if (s != null && treePanel.revert(s)) {
                frame.setTitle("Explore " + path + " @" + s);
            }
        }
    });

    JMenuItem menuRefs = new JMenuItem("Tar File Info");
    menuRefs.setMnemonic(KeyEvent.VK_I);
    menuRefs.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            List<String> tarFiles = new ArrayList<String>();
            for (File f : path.listFiles()) {
                if (f.getName().endsWith(".tar")) {
                    tarFiles.add(f.getName());
                }
            }

            String s = (String) JOptionPane.showInputDialog(frame, "Choose a tar file", "Tar File Info",
                    JOptionPane.PLAIN_MESSAGE, null, tarFiles.toArray(), tarFiles.get(0));
            if (s != null) {
                treePanel.printTarInfo(s);
            }
        }
    });

    JMenuItem menuSCR = new JMenuItem("Segment Refs");
    menuSCR.setMnemonic(KeyEvent.VK_R);
    menuSCR.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            String s = JOptionPane.showInputDialog(frame, "Segment References\nUsage: <segmentId>",
                    "Segment References", JOptionPane.PLAIN_MESSAGE);
            if (s != null) {
                treePanel.printSegmentReferences(s);
            }
        }
    });

    JMenuItem menuDiff = new JMenuItem("SegmentNodeState diff");
    menuDiff.setMnemonic(KeyEvent.VK_D);
    menuDiff.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            String s = JOptionPane.showInputDialog(frame,
                    "SegmentNodeState diff\nUsage: <recordId> <recordId> [<path>]", "SegmentNodeState diff",
                    JOptionPane.PLAIN_MESSAGE);
            if (s != null) {
                treePanel.printDiff(s);
            }
        }
    });

    JMenuItem menuPCM = new JMenuItem("Persisted Compaction Maps");
    menuPCM.setMnemonic(KeyEvent.VK_P);
    menuPCM.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            treePanel.printPCMInfo();
        }
    });

    menuBar.add(menuReopen);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuCompaction);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuRefs);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuSCR);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuDiff);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuPCM);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));

    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setSize(960, 720);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:org.apache.jmeter.gui.MainFrame.java

/**
 * Create the GUI components and layout.
 *///  w ww  .  j a  va 2 s .  com
private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    menuBar = new JMeterMenuBar();
    setJMenuBar(menuBar);
    JPanel all = new JPanel(new BorderLayout());
    all.add(createToolBar(), BorderLayout.NORTH);

    JSplitPane treeAndMain = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);

    treePanel = createTreePanel();
    treeAndMain.setLeftComponent(treePanel);

    JSplitPane topAndDown = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    topAndDown.setOneTouchExpandable(true);
    topAndDown.setDividerLocation(0.8);
    topAndDown.setResizeWeight(.8);
    topAndDown.setContinuousLayout(true);
    topAndDown.setBorder(null); // see bug jdk 4131528
    if (!DISPLAY_LOGGER_PANEL) {
        topAndDown.setDividerSize(0);
    }
    mainPanel = createMainPanel();

    logPanel = createLoggerPanel();
    errorsAndFatalsCounterLogTarget = new ErrorsAndFatalsCounterLogTarget();
    LoggingManager.addLogTargetToRootLogger(new LogTarget[] { logPanel, errorsAndFatalsCounterLogTarget });

    topAndDown.setTopComponent(mainPanel);
    topAndDown.setBottomComponent(logPanel);

    treeAndMain.setRightComponent(topAndDown);

    treeAndMain.setResizeWeight(.2);
    treeAndMain.setContinuousLayout(true);
    all.add(treeAndMain, BorderLayout.CENTER);

    getContentPane().add(all);

    tree.setSelectionRow(1);
    addWindowListener(new WindowHappenings());
    // Building is complete, register as listener
    GuiPackage.getInstance().registerAsListener();
    setTitle(DEFAULT_TITLE);
    setIconImage(JMeterUtils.getImage("icon-apache.png").getImage());// $NON-NLS-1$
    setWindowTitle(); // define AWT WM_CLASS string
}