Example usage for javax.swing JSplitPane setContinuousLayout

List of usage examples for javax.swing JSplitPane setContinuousLayout

Introduction

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

Prototype

@BeanProperty(description = "Whether the child components are continuously redisplayed and laid out during user intervention.")
public void setContinuousLayout(boolean newContinuousLayout) 

Source Link

Document

Sets the value of the continuousLayout property, which must be true for the child components to be continuously redisplayed and laid out during user intervention.

Usage

From source file:src.gui.ItSIMPLE.java

/**
 * @return Returns the planAnalysisFramePanel.
 *//*from www.j  a  v  a2  s . 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:net.sourceforge.pmd.util.designer.Designer.java

public Designer(String[] args) {
    if (args.length > 0) {
        exitOnClose = !args[0].equals("-noexitonclose");
    }/*from w w w  .  j a  va2s  . 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 ww w.  ja v a2s  . 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:org.apache.jmeter.gui.MainFrame.java

/**
 * Create the GUI components and layout.
 *///from   w  w  w  .j  av a  2  s  .  c om
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
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.Cockpit.java

/**
 * Initialises the application's GUI elements.
 *///from   ww w  .j av a 2  s  . c  o m
private void initGui() {
    initMenus();

    JPanel appContent = new JPanel(new GridBagLayout());
    this.getContentPane().add(appContent);

    // Buckets panel.
    JPanel bucketsPanel = new JPanel(new GridBagLayout());

    JButton bucketActionButton = new JButton();
    bucketActionButton.setToolTipText("Bucket actions menu");
    guiUtils.applyIcon(bucketActionButton, "/images/nuvola/16x16/actions/misc.png");
    bucketActionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JButton sourceButton = (JButton) e.getSource();
            bucketActionMenu.show(sourceButton, 0, sourceButton.getHeight());
        }
    });
    bucketsPanel.add(new JHtmlLabel("<html><b>Buckets</b></html>", this), new GridBagConstraints(0, 0, 1, 1, 1,
            0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
    bucketsPanel.add(bucketActionButton, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    bucketTableModel = new BucketTableModel(false);
    bucketTableModelSorter = new TableSorter(bucketTableModel);
    bucketsTable = new JTable(bucketTableModelSorter);
    bucketTableModelSorter.setTableHeader(bucketsTable.getTableHeader());
    bucketsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    bucketsTable.getSelectionModel().addListSelectionListener(this);
    bucketsTable.setShowHorizontalLines(true);
    bucketsTable.setShowVerticalLines(false);
    bucketsTable.addMouseListener(new ContextMenuListener());
    bucketsPanel.add(new JScrollPane(bucketsTable), new GridBagConstraints(0, 1, 2, 1, 1, 1,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0));
    bucketsPanel.add(new JLabel(" "), new GridBagConstraints(0, 2, 2, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));

    // Filter panel.
    filterObjectsPanel = new JPanel(new GridBagLayout());
    filterObjectsPrefix = new JTextField();
    filterObjectsPrefix.setToolTipText("Only show objects with this prefix");
    filterObjectsPrefix.addActionListener(this);
    filterObjectsPrefix.setActionCommand("RefreshObjects");
    filterObjectsDelimiter = new JComboBox(new String[] { "", "/", "?", "\\" });
    filterObjectsDelimiter.setEditable(true);
    filterObjectsDelimiter.setToolTipText("Object name delimiter");
    filterObjectsDelimiter.addActionListener(this);
    filterObjectsDelimiter.setActionCommand("RefreshObjects");
    filterObjectsPanel.add(new JHtmlLabel("Prefix:", this), new GridBagConstraints(0, 0, 1, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0));
    filterObjectsPanel.add(filterObjectsPrefix, new GridBagConstraints(1, 0, 1, 1, 1, 0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    filterObjectsPanel.add(new JHtmlLabel("Delimiter:", this), new GridBagConstraints(2, 0, 1, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0));
    filterObjectsPanel.add(filterObjectsDelimiter, new GridBagConstraints(3, 0, 1, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0));
    filterObjectsPanel.setVisible(false);

    // Objects panel.
    JPanel objectsPanel = new JPanel(new GridBagLayout());
    int row = 0;
    filterObjectsCheckBox = new JCheckBox("Filter objects");
    filterObjectsCheckBox.addActionListener(this);
    filterObjectsCheckBox.setToolTipText("Check this option to filter the objects listed");
    objectsPanel.add(new JHtmlLabel("<html><b>Objects</b></html>", this), new GridBagConstraints(0, row, 1, 1,
            1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
    objectsPanel.add(filterObjectsCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    JButton objectActionButton = new JButton();
    objectActionButton.setToolTipText("Object actions menu");
    guiUtils.applyIcon(objectActionButton, "/images/nuvola/16x16/actions/misc.png");
    objectActionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JButton sourceButton = (JButton) e.getSource();
            objectActionMenu.show(sourceButton, 0, sourceButton.getHeight());
        }
    });
    objectsPanel.add(objectActionButton, new GridBagConstraints(2, row, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    objectsPanel.add(filterObjectsPanel, new GridBagConstraints(0, ++row, 3, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    objectsTable = new JTable();
    objectTableModel = new ObjectTableModel();
    objectTableModelSorter = new TableSorter(objectTableModel);
    objectTableModelSorter.setTableHeader(objectsTable.getTableHeader());
    objectsTable.setModel(objectTableModelSorter);
    objectsTable.setDefaultRenderer(Long.class, new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 301092191828910402L;

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            String formattedSize = byteFormatter.formatByteSize(((Long) value).longValue());
            return super.getTableCellRendererComponent(table, formattedSize, isSelected, hasFocus, row, column);
        }
    });
    objectsTable.setDefaultRenderer(Date.class, new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 7285511556343895652L;

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            Date date = (Date) value;
            return super.getTableCellRendererComponent(table, yearAndTimeSDF.format(date), isSelected, hasFocus,
                    row, column);
        }
    });
    objectsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    objectsTable.getSelectionModel().addListSelectionListener(this);
    objectsTable.setShowHorizontalLines(true);
    objectsTable.setShowVerticalLines(true);
    objectsTable.addMouseListener(new ContextMenuListener());
    objectsTableSP = new JScrollPane(objectsTable);
    objectsPanel.add(objectsTableSP, new GridBagConstraints(0, ++row, 3, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsZero, 0, 0));
    objectsSummaryLabel = new JHtmlLabel("Please select a bucket", this);
    objectsSummaryLabel.setHorizontalAlignment(JLabel.CENTER);
    objectsSummaryLabel.setFocusable(false);
    objectsPanel.add(objectsSummaryLabel, new GridBagConstraints(0, ++row, 3, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    // Combine sections.
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, bucketsPanel, objectsPanel);
    splitPane.setOneTouchExpandable(true);
    splitPane.setContinuousLayout(true);

    appContent.add(splitPane, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));

    // Set preferred sizes
    int preferredWidth = 800;
    int preferredHeight = 600;
    this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight)));

    splitPane.setResizeWeight(0.30);

    // Initialize drop target.
    initDropTarget(new JComponent[] { objectsTableSP, objectsTable });
    objectsTable.getDropTarget().setActive(false);
    objectsTableSP.getDropTarget().setActive(false);
}

From source file:org.n52.ifgicopter.spf.gui.FrameworkCorePanel.java

/**
 * default constructor to create the framework core panel.
 *///from ww  w .j a v  a2  s.  c  o  m
public FrameworkCorePanel() {

    /*
     * INPUT PLUGIN LIST
     */
    this.pluginsPanel = new JPanel();
    this.pluginsPanel.setLayout(new GridBagLayout());
    this.pluginsPanel.setBackground(DEFAULT_COLOR);

    this.globalGBC = new GridBagConstraints();
    this.globalGBC.gridx = 0;
    this.globalGBC.gridy = 0;
    this.globalGBC.weightx = 0.0;
    this.globalGBC.weighty = 0.0;
    this.globalGBC.anchor = GridBagConstraints.NORTHWEST;
    this.globalGBC.fill = GridBagConstraints.HORIZONTAL;

    this.pluginsPanel.add(
            new JLabel("<html><body><div><strong>" + "Active Plugins</strong></div></body></html>"),
            this.globalGBC);

    this.globalGBC.gridy++;
    this.globalGBC.gridwidth = GridBagConstraints.REMAINDER;
    this.globalGBC.insets = new Insets(0, 0, 5, 0);
    this.pluginsPanel.add(new JSeparator(), this.globalGBC);
    this.globalGBC.insets = new Insets(0, 0, 0, 0);

    this.globalGBC.weightx = 1.0;
    this.globalGBC.gridy = 0;
    this.globalGBC.gridx = 1;
    this.pluginsPanel.add(Box.createHorizontalGlue(), this.globalGBC);
    this.globalGBC.weightx = 0.0;
    this.globalGBC.gridx = 0;
    this.globalGBC.gridy = 1;

    /*
     * the contentpanel
     */
    this.contentPanel = new JPanel();
    this.contentPanel.setLayout(new CardLayout());
    this.contentPanel.setBorder(BorderFactory.createEtchedBorder());
    this.contentPanel.add(WelcomePanel.getInstance(), WELCOME_PANEL);
    // ((CardLayout) contentPanel.getLayout()).show(contentPanel, WELCOME_PANEL);

    JScrollPane startupS = new JScrollPane(this.contentPanel);
    startupS.setViewportBorder(null);

    /*
     * wrap the plugins to ensure top alignment
     */
    JPanel pluginsPanelWrapper = new JPanel(new BorderLayout());
    pluginsPanelWrapper.add(this.pluginsPanel, BorderLayout.NORTH);
    pluginsPanelWrapper.add(Box.createVerticalGlue(), BorderLayout.CENTER);
    pluginsPanelWrapper.setBorder(BorderFactory.createEtchedBorder());
    pluginsPanelWrapper.setBackground(this.pluginsPanel.getBackground());
    JScrollPane wrapperS = new JScrollPane(pluginsPanelWrapper);
    wrapperS.setViewportBorder(null);

    /*
     * add both scroll panes to the split pane
     */
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, wrapperS, startupS);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(250);
    splitPane.setContinuousLayout(true);

    Dimension minimumSize = new Dimension(100, 100);
    startupS.setMinimumSize(minimumSize);

    this.setLayout(new BorderLayout());
    this.add(splitPane);
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Initializes and returns a split pane, either vertical or horizontal 
 * depending on the passed parameter./*from  ww  w  . ja  va  2 s.  c  o  m*/
 * 
 * @param orientation The orientation of the split pane.
 * @return See above.
 */
private JSplitPane initSplitPane(int orientation) {
    int type;
    switch (orientation) {
    case JSplitPane.HORIZONTAL_SPLIT:
    case JSplitPane.VERTICAL_SPLIT:
        type = orientation;
        break;
    default:
        type = JSplitPane.HORIZONTAL_SPLIT;
    }
    JSplitPane pane = new JSplitPane(type);
    pane.setOneTouchExpandable(true);
    pane.setContinuousLayout(true);
    pane.setDividerLocation(-1);
    pane.setResizeWeight(0.0);
    return pane;
}

From source file:org.pentaho.reporting.engine.classic.demo.util.CompoundDemoFrame.java

protected Container createDefaultContentPane() {

    demoContent = new JPanel();
    demoContent.setLayout(new BorderLayout());
    demoContent.setMinimumSize(new Dimension(100, 100));
    demoContent.add(getNoHandlerInfoPane(), BorderLayout.CENTER);

    JPanel placeHolder = new JPanel();
    placeHolder.setMinimumSize(new Dimension(300, 0));
    placeHolder.setPreferredSize(new Dimension(300, 0));
    placeHolder.setMaximumSize(new Dimension(300, 0));

    JPanel rootContent = new JPanel();
    rootContent.setLayout(new BorderLayout());
    rootContent.add(demoContent, BorderLayout.CENTER);
    rootContent.add(placeHolder, BorderLayout.NORTH);

    final DemoSelectorTreeNode root = new DemoSelectorTreeNode(null, demoSelector);
    final DefaultTreeModel model = new DefaultTreeModel(root);
    final JTree demoTree = new JTree(model);
    demoTree.addTreeSelectionListener(new TreeSelectionHandler());

    JSplitPane rootSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(demoTree),
            rootContent);//from www .  ja va2 s.c o  m
    rootSplitPane.setContinuousLayout(true);
    rootSplitPane.setDividerLocation(200);
    rootSplitPane.setOneTouchExpandable(true);
    return rootSplitPane;
}

From source file:org.pentaho.ui.xul.swing.SwingElement.java

public void layout() {
    super.layout();
    double totalFlex = 0.0;

    if (isVisible() == false) {
        resetContainer();/*from  w ww  .j  a v a  2s  .co m*/
        return;
    }

    for (Element comp : getChildNodes()) {
        // if (comp.getManagedObject() == null) {
        // continue;
        // }
        if (((XulComponent) comp).getFlex() > 0) {
            flexLayout = true;
            totalFlex += ((XulComponent) comp).getFlex();
        }
    }

    double currentFlexTotal = 0.0;

    Align alignment = (getAlign() != null) ? Align.valueOf(this.getAlign().toUpperCase()) : null;

    for (int i = 0; i < getChildNodes().size(); i++) {
        XulComponent comp = (XulComponent) getChildNodes().get(i);
        gc.fill = GridBagConstraints.BOTH;

        if (comp instanceof XulSplitter) {
            JPanel prevContainer = container;
            container = new ScrollablePanel(new GridBagLayout());
            container.setOpaque(false);

            final JSplitPane splitter = new JSplitPane(
                    (this.getOrientation() == Orient.VERTICAL) ? JSplitPane.VERTICAL_SPLIT
                            : JSplitPane.HORIZONTAL_SPLIT,
                    prevContainer, container);
            splitter.setContinuousLayout(true);

            final double splitterSize = currentFlexTotal / totalFlex;
            splitter.setResizeWeight(splitterSize);
            if (totalFlex > 0) {
                splitter.addComponentListener(new ComponentListener() {
                    public void componentHidden(ComponentEvent arg0) {
                    }

                    public void componentMoved(ComponentEvent arg0) {
                    }

                    public void componentShown(ComponentEvent arg0) {
                    }

                    public void componentResized(ComponentEvent arg0) {
                        splitter.setDividerLocation(splitterSize);
                        splitter.removeComponentListener(this);
                    }

                });

            }

            if (!flexLayout) {
                if (this.getOrientation() == Orient.VERTICAL) { // VBox and such
                    gc.weighty = 1.0;
                } else {
                    gc.weightx = 1.0;
                }

                prevContainer.add(Box.createGlue(), gc);
            }
            setManagedObject(splitter);
        }

        Object maybeComponent = comp.getManagedObject();
        if (maybeComponent == null || !(maybeComponent instanceof Component)) {
            continue;
        }
        if (this.getOrientation() == Orient.VERTICAL) { // VBox and such
            gc.gridheight = comp.getFlex() + 1;
            gc.gridwidth = GridBagConstraints.REMAINDER;
            gc.weighty = (totalFlex == 0) ? 0 : (comp.getFlex() / totalFlex);
        } else {
            gc.gridwidth = comp.getFlex() + 1;
            gc.gridheight = GridBagConstraints.REMAINDER;
            gc.weightx = (totalFlex == 0) ? 0 : (comp.getFlex() / totalFlex);
        }

        currentFlexTotal += comp.getFlex();

        if (this.getOrientation() == Orient.VERTICAL) { // VBox and such
            if (alignment != null) {
                gc.fill = GridBagConstraints.NONE;
                switch (alignment) {
                case START:
                    gc.anchor = GridBagConstraints.WEST;
                    break;
                case CENTER:
                    gc.anchor = GridBagConstraints.CENTER;
                    break;
                case END:
                    gc.anchor = GridBagConstraints.EAST;
                    break;
                }
            }

        } else {
            if (alignment != null) {
                gc.fill = GridBagConstraints.NONE;
                switch (alignment) {
                case START:
                    gc.anchor = GridBagConstraints.NORTH;
                    break;
                case CENTER:
                    gc.anchor = GridBagConstraints.CENTER;
                    break;
                case END:
                    gc.anchor = GridBagConstraints.SOUTH;
                    break;
                }
            }
        }

        Component component = (Component) maybeComponent;

        if (comp.getWidth() > 0 || comp.getHeight() > 0) {
            Dimension minSize = component.getMinimumSize();
            Dimension prefSize = component.getPreferredSize();

            if (comp.getWidth() > 0) {
                minSize.width = comp.getWidth();
                prefSize.width = comp.getWidth();
            }
            if (comp.getHeight() > 0) {
                minSize.height = comp.getHeight();
                prefSize.height = comp.getHeight();
            }
            component.setMinimumSize(minSize);
            component.setPreferredSize(prefSize);
        }

        container.add(component, gc);

        if (i + 1 == getChildNodes().size() && !flexLayout) {
            if (this.getOrientation() == Orient.VERTICAL) { // VBox and such
                gc.weighty = 1.0;

            } else {
                gc.weightx = 1.0;

            }
            container.add(Box.createGlue(), gc);
        }
    }

}

From source file:org.richie.codeGen.ui.CodeGenMainUI.java

private void initlize() {
    setTitle("??");
    setBounds(120, 80, 1024, 550);//from  www. ja va 2  s .  co m
    setDefaultCloseOperation(3);
    setLayout(new BorderLayout(5, 5));
    // ?MenuBar
    initMenuBar();
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, getWestPanel(), getCenterPanel());
    split.setContinuousLayout(false);
    split.setOneTouchExpandable(true);
    split.setDividerLocation(150);
    add(split, BorderLayout.CENTER);
    //?pdm
    openLastPdmFile();
    addCloseListener();
    this.setIconImage(new ImageIcon(ClassLoader.getSystemResource("resources/images/logo.jpg")).getImage());
}