Example usage for javax.swing JSplitPane HORIZONTAL_SPLIT

List of usage examples for javax.swing JSplitPane HORIZONTAL_SPLIT

Introduction

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

Prototype

int HORIZONTAL_SPLIT

To view the source code for javax.swing JSplitPane HORIZONTAL_SPLIT.

Click Source Link

Document

Horizontal split indicates the Components are split along the x axis.

Usage

From source file:com.diversityarrays.kdxplore.design.EntryFileImportDialog.java

public EntryFileImportDialog(Window owner, String title, File inputFile, Predicate<Role> entryHeadingFilter) {
    super(owner, title, ModalityType.APPLICATION_MODAL);

    this.entryHeadingFilter = entryHeadingFilter;
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setGlassPane(backgroundRunner.getBlockingPane());

    useScrollBarOption.addActionListener(new ActionListener() {
        @Override//from  w  w  w .ja v  a2s  .  co m
        public void actionPerformed(ActionEvent e) {
            updateDataPreviewScrolling();
        }
    });

    headingRoleTableModel = createHeadingRoleTableModel();
    headingRoleTable = new HeadingRoleTable<>(headingRoleTableModel);
    headingTableScrollPane = new JScrollPane(headingRoleTable);
    GuiUtil.setVisibleRowCount(headingRoleTable, 10);

    JPanel roleAssignmentPanel = new JPanel(new BorderLayout());
    roleAssignmentPanel.add(headingTableScrollPane, BorderLayout.CENTER);

    headingRoleTable.setTransferHandler(flth);
    headingRoleTableModel.addChangeListener(headingRoleChangeListener);

    GuiUtil.setVisibleRowCount(dataPreviewTable, 10);
    dataPreviewTable.setTransferHandler(flth);
    dataPreviewScrollPane.setTransferHandler(flth);
    updateDataPreviewScrolling();

    dataPreviewScrollPane.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            //                boolean useScrollBar = useScrollBarOption.isSelected();
            GuiUtil.initialiseTableColumnWidths(dataPreviewTable, true);
        }
    });

    Box top = Box.createHorizontalBox();
    top.add(new JLabel("# rows to preview: "));
    top.add(new JSpinner(previewRowCountSpinnerModel));
    top.add(Box.createHorizontalGlue());
    top.add(useScrollBarOption);

    JPanel dataPreviewPanel = new JPanel(new BorderLayout());
    dataPreviewPanel.add(GuiUtil.createLabelSeparator("Data Preview", top), BorderLayout.NORTH);
    dataPreviewPanel.add(dataPreviewScrollPane, BorderLayout.CENTER);

    headingWarning.setForeground(Color.RED);
    JLabel instructions = new JLabel("<HTML>Please assign a <i>Role</i> for each of the headings in your data"
            + "<br>You must specify one as the <i>Entry Name</i>."
            + "<br>Click on one of the <i>Role</i> cells and select from the dropdown"
            + "<br>To assign multiple headings, select the rows for which you wish"
            + "<br>to set the <i>Role</i> then right-click and choose from the dropdown.");
    instructions.setHorizontalAlignment(JLabel.CENTER);
    instructions.setBackground(Toast.PALE_YELLOW);

    JScrollPane instScroll = new JScrollPane(instructions);
    instScroll.setBackground(Toast.PALE_YELLOW);

    normalEntryNameField.getDocument()
            .addDocumentListener(new DocumentChangeListener((e) -> updateAcceptButton()));
    normalEntryNameField.setText(TrialDesignPreferences.getInstance().getNormalEntryTypeName());

    JPanel rolesPanel = new JPanel();
    GBH gbh = new GBH(rolesPanel, 2, 2, 0, 0);
    int y = 0;
    gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, "Entry Type Name for non-Checks:");
    gbh.add(1, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, normalEntryNameField);
    gbh.add(2, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, saveForFuture);
    ++y;

    gbh.add(0, y, 3, 1, GBH.BOTH, 2, 1, GBH.CENTER, roleAssignmentPanel);
    ++y;

    JSplitPane headingsAndInstructions = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rolesPanel, instScroll);

    JPanel headingPanel = new JPanel(new BorderLayout());
    headingPanel.add(GuiUtil.createLabelSeparator("Assign Roles for Headings"), BorderLayout.NORTH);
    headingPanel.add(headingsAndInstructions, BorderLayout.CENTER);
    headingPanel.add(headingWarning, BorderLayout.SOUTH);

    errorMessage.setEditable(false);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, dataPreviewPanel, headingPanel);
    splitPane.setResizeWeight(0.5);

    cardPanel.add(new JScrollPane(errorMessage), CARD_ERROR);
    cardPanel.add(splitPane, CARD_DATA);

    Box bot = Box.createHorizontalBox();
    bot.add(Box.createHorizontalGlue());
    bot.add(new JButton(cancelAction));
    bot.add(new JButton(acceptAction));
    acceptAction.setEnabled(false);

    Container cp = getContentPane();
    cp.add(cardPanel, BorderLayout.CENTER);
    cp.add(bot, BorderLayout.SOUTH);
    pack();

    sheetNamesComboBox.addActionListener(sheetNamesActionListener);

    Timer timer = new Timer(true);

    previewRowCountSpinnerModel.addChangeListener(new ChangeListener() {
        int nPreview;
        TimerTask timerTask = null;

        @Override
        public void stateChanged(ChangeEvent e) {
            nPreview = previewRowCountSpinnerModel.getNumber().intValue();

            if (timerTask == null) {
                timerTask = new TimerTask() {
                    int lastPreviewCount = nPreview;

                    @Override
                    public void run() {
                        if (lastPreviewCount == nPreview) {
                            System.err.println("Stable at " + lastPreviewCount);
                            // No change, do it now
                            cancel();
                            try {
                                updateDataPreview(lastPreviewCount);
                            } finally {
                                timerTask = null;
                            }
                        } else {
                            System.err.println("Changing from " + lastPreviewCount + " to " + nPreview);
                            lastPreviewCount = nPreview;
                        }
                    }
                };
                timer.scheduleAtFixedRate(timerTask, 500, 100);
            }
        }
    });

    sheetNamesComboBox.setVisible(false);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            removeWindowListener(this);
            setFile(inputFile);
        }
    });
}

From source file:kr.ac.kaist.swrc.jhannanum.demo.GUIDemo.java

/**
 * Setting of the split panel for plug-in pool and the work flow.
 * @return the split panel//from w w  w  .  ja v  a 2  s . c o m
 */
private JComponent createPaneNorth() {
    splitPaneTop = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPaneTop.setLeftComponent(createPluginPool());
    splitPaneTop.setRightComponent(createWorkflow());
    splitPaneTop.setOneTouchExpandable(true);

    return splitPaneTop;
}

From source file:display.containers.FileManager.java

public Container getPane() {
    //if (gui==null) {

    fileSystemView = FileSystemView.getFileSystemView();
    desktop = Desktop.getDesktop();

    JPanel detailView = new JPanel(new BorderLayout(3, 3));
    //fileTableModel = new FileTableModel();

    table = new JTable();
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setAutoCreateRowSorter(true);//from  ww  w.j  a  v  a  2  s . c  o m
    table.setShowVerticalLines(false);
    table.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                Point p = e.getPoint();
                int row = table.convertRowIndexToModel(table.rowAtPoint(p));
                int column = table.convertColumnIndexToModel(table.columnAtPoint(p));
                if (row >= 0 && column >= 0) {
                    mouseDblClicked(row, column);
                }
            }
        }
    });
    table.addKeyListener(new KeyListener() {

        @Override
        public void keyTyped(KeyEvent arg0) {

        }

        @Override
        public void keyReleased(KeyEvent arg0) {
            if (KeyEvent.VK_DELETE == arg0.getKeyCode()) {
                if (mode != 2) {
                    parentFrame.setLock(true);
                    parentFrame.getProgressBarPanel().setVisible(true);
                    Thread t = new Thread(new Runnable() {

                        @Override
                        public void run() {
                            try {
                                deleteSelectedFiles();
                            } catch (IOException e) {
                                JOptionPane.showMessageDialog(parentFrame, "Error during the deletion.",
                                        "Deletion error", JOptionPane.ERROR_MESSAGE);
                                WindowManager.mwLogger.log(Level.SEVERE, "Error during the deletion.", e);
                            } finally {
                                parentFrame.setLock(false);
                                refresh();
                                parentFrame.getProgressBarPanel().setVisible(false);
                            }
                        }
                    });
                    t.start();

                } else {
                    if (UserProfile.CURRENT_USER.getLevel() == 3) {
                        parentFrame.setLock(true);
                        parentFrame.getProgressBarPanel().setVisible(true);
                        Thread delThread = new Thread(new Runnable() {

                            @Override
                            public void run() {
                                int[] rows = table.getSelectedRows();
                                int[] columns = table.getSelectedColumns();
                                for (int i = 0; i < rows.length; i++) {
                                    if (!continueAction) {
                                        continueAction = true;
                                        return;
                                    }
                                    int row = table.convertRowIndexToModel(rows[i]);
                                    try {
                                        deleteServerFile(row);
                                    } catch (Exception e) {
                                        WindowManager.mwLogger.log(Level.SEVERE, "Error during the deletion.",
                                                e);
                                    }
                                }
                                refresh();
                                parentFrame.setLock(false);
                                parentFrame.getProgressBarPanel().setVisible(false);
                            }
                        });
                        delThread.start();

                    }
                }
            }
        }

        @Override
        public void keyPressed(KeyEvent arg0) {
            // TODO Auto-generated method stub

        }
    });
    table.getSelectionModel().addListSelectionListener(listSelectionListener);
    JScrollPane tableScroll = new JScrollPane(table);
    Dimension d = tableScroll.getPreferredSize();
    tableScroll.setPreferredSize(new Dimension((int) d.getWidth(), (int) d.getHeight() / 2));
    detailView.add(tableScroll, BorderLayout.CENTER);

    // the File tree
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    treeModel = new DefaultTreeModel(root);
    table.getRowSorter().addRowSorterListener(new RowSorterListener() {

        @Override
        public void sorterChanged(RowSorterEvent e) {
            ((FileTableModel) table.getModel()).fireTableDataChanged();
        }
    });

    // show the file system roots.
    File[] roots = fileSystemView.getRoots();
    for (File fileSystemRoot : roots) {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(fileSystemRoot);
        root.add(node);
        //showChildren(node);
        //
        File[] files = fileSystemView.getFiles(fileSystemRoot, true);
        for (File file : files) {
            if (file.isDirectory()) {
                node.add(new DefaultMutableTreeNode(file));
            }
        }
        //
    }
    JScrollPane treeScroll = new JScrollPane();

    Dimension preferredSize = treeScroll.getPreferredSize();
    Dimension widePreferred = new Dimension(200, (int) preferredSize.getHeight());
    treeScroll.setPreferredSize(widePreferred);

    JPanel fileView = new JPanel(new BorderLayout(3, 3));

    detailView.add(fileView, BorderLayout.SOUTH);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeScroll, detailView);

    JPanel simpleOutput = new JPanel(new BorderLayout(3, 3));
    progressBar = new JProgressBar();
    simpleOutput.add(progressBar, BorderLayout.EAST);
    progressBar.setVisible(false);
    showChildren(getCurrentDir().toPath());
    //table.setDragEnabled(true);
    table.setColumnSelectionAllowed(false);

    // Menu popup
    Pmenu = new JPopupMenu();
    changeProjectitem = new JMenuItem("Reassign");
    renameProjectitem = new JMenuItem("Rename");
    twitem = new JMenuItem("To workspace");
    tlitem = new JMenuItem("To local");
    processitem = new JMenuItem("Select for process");
    switch (mode) {
    case 0:
        Pmenu.add(twitem);
        twitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                parentFrame.getBtnlocalTowork().doClick();
            }
        });
        break;
    case 1:
        Pmenu.add(tlitem);
        Pmenu.add(processitem);
        tlitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                parentFrame.getBtnWorkTolocal().doClick();
            }
        });
        processitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        // Recupere les lignes selectionnees
                        int[] indices = table.getSelectedRows();
                        // On recupere les fichiers correspondants
                        ArrayList<File> files = new ArrayList<File>();
                        for (int i = 0; i < indices.length; i++) {
                            int row = table.convertRowIndexToModel(indices[i]);
                            File fi = ((FileTableModel) table.getModel()).getFile(row);
                            if (fi.isDirectory())
                                files.add(fi);
                        }
                        ImageProcessingFrame imf = new ImageProcessingFrame(files);
                    }
                });

            }
        });
        break;
    case 2:
        if (UserProfile.CURRENT_USER.getLevel() == 3) {
            Pmenu.add(changeProjectitem);
            Pmenu.add(renameProjectitem);
        }
        Pmenu.add(twitem);
        twitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                parentFrame.getBtndistToWorkspace().doClick();
            }
        });
        Pmenu.add(tlitem);
        tlitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                parentFrame.getBtndistToLocal().doClick();
            }
        });
        break;
    }
    changeProjectitem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            table.setEnabled(false);
            File from = ((FileTableModel) table.getModel())
                    .getFile(table.convertRowIndexToModel(table.getSelectedRows()[0]));

            ReassignProjectPanel reas = new ReassignProjectPanel(from.toPath()); // mode creation de liens
            Popup popup = PopupFactory.getSharedInstance().getPopup(WindowManager.MAINWINDOW, reas,
                    (int) WindowManager.MAINWINDOW.getX() + 200, (int) WindowManager.MAINWINDOW.getY() + 150);
            reas.setPopupWindow(popup);
            popup.show();
            table.setEnabled(true);
        }
    });
    renameProjectitem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            table.setEnabled(false);
            final File from = ((FileTableModel) table.getModel())
                    .getFile(table.convertRowIndexToModel(table.getSelectedRows()[0]));
            JDialog.setDefaultLookAndFeelDecorated(true);
            String s = (String) JOptionPane.showInputDialog(WindowManager.MAINWINDOW, "New project name ?",
                    "Rename project", JOptionPane.PLAIN_MESSAGE, null, null, from.getName());

            //If a string was returned, say so.
            if ((s != null) && (s.length() > 0)) {
                ProjectDAO pdao = new MySQLProjectDAO();
                if (new File(from.getParent() + File.separator + s).exists()) {
                    SwingUtilities.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            JDialog.setDefaultLookAndFeelDecorated(true);
                            JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                    "Couldn't rename " + from.getName()
                                            + " (A file with this filename already exists)",
                                    "Renaming error", JOptionPane.ERROR_MESSAGE);
                        }
                    });
                    WindowManager.mwLogger.log(Level.SEVERE,
                            "Error during file project renaming (" + from.getName() + "). [Duplication error]");
                } else {
                    try {
                        boolean succeed = pdao.renameProject(from.getName(), s);
                        if (!succeed) {
                            SwingUtilities.invokeLater(new Runnable() {

                                @Override
                                public void run() {
                                    JDialog.setDefaultLookAndFeelDecorated(true);
                                    JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                            "Couldn't rename " + from.getName()
                                                    + " (no project with this name)",
                                            "Renaming error", JOptionPane.ERROR_MESSAGE);
                                }
                            });
                        } else {
                            from.renameTo(new File(from.getParent() + File.separator + s));
                            // on renomme le repertoire nifti ou dicom correspondant si il existe
                            switch (from.getParentFile().getName()) {
                            case ServerInfo.NRI_ANALYSE_NAME:
                                if (new File(from.getAbsolutePath().replaceAll(ServerInfo.NRI_ANALYSE_NAME,
                                        ServerInfo.NRI_DICOM_NAME)).exists())
                                    try {
                                        Files.move(Paths.get(from.getAbsolutePath().replaceAll(
                                                ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)),
                                                Paths.get(from.getParent().replaceAll(
                                                        ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)
                                                        + File.separator + s));
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                        SwingUtilities.invokeLater(new Runnable() {

                                            @Override
                                            public void run() {
                                                JDialog.setDefaultLookAndFeelDecorated(true);
                                                JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                                        "Couldn't rename " + from.getName()
                                                                + " (error with file system)",
                                                        "Renaming error", JOptionPane.ERROR_MESSAGE);
                                            }
                                        });
                                        WindowManager.mwLogger.log(Level.SEVERE,
                                                "Error during file project renaming (" + from.getName() + ")",
                                                e);
                                    } //from.renameTo(new File(from.getParent().replaceAll(ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)+File.separator+s));
                                break;
                            case ServerInfo.NRI_DICOM_NAME:
                                if (new File(from.getAbsolutePath().replaceAll(ServerInfo.NRI_DICOM_NAME,
                                        ServerInfo.NRI_ANALYSE_NAME)).exists())
                                    try {
                                        Files.move(Paths.get(from.getAbsolutePath().replaceAll(
                                                ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)),
                                                Paths.get(from.getParent().replaceAll(ServerInfo.NRI_DICOM_NAME,
                                                        ServerInfo.NRI_ANALYSE_NAME) + File.separator + s));
                                    } catch (IOException e) {
                                        SwingUtilities.invokeLater(new Runnable() {

                                            @Override
                                            public void run() {
                                                JDialog.setDefaultLookAndFeelDecorated(true);
                                                JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                                        "Couldn't rename " + from.getName()
                                                                + " (error with file system)",
                                                        "Renaming error", JOptionPane.ERROR_MESSAGE);
                                            }
                                        });
                                        e.printStackTrace();
                                        WindowManager.mwLogger.log(Level.SEVERE,
                                                "Error during file project renaming (" + from.getName() + ")",
                                                e);
                                    } //from.renameTo(new File(from.getParent().replaceAll(ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)+File.separator+s));
                                break;
                            }
                            refresh();
                        }
                    } catch (final SQLException e) {
                        WindowManager.mwLogger.log(Level.SEVERE, "Error during SQL project renaming", e);
                        SwingUtilities.invokeLater(new Runnable() {

                            @Override
                            public void run() {
                                JDialog.setDefaultLookAndFeelDecorated(true);
                                JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                        "Exception : " + e.toString(), "Openning error",
                                        JOptionPane.ERROR_MESSAGE);
                            }
                        });
                    }
                }
            }
            table.setEnabled(true);
        }
    });
    table.addMouseListener(new MouseListener() {

        public void mouseClicked(MouseEvent me) {

        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent me) {
            if (me.getButton() == 3 && table.getSelectedRowCount() > 0) {
                int row = table.convertRowIndexToModel(table.rowAtPoint(me.getPoint()));
                changeProjectitem.setVisible(isPatient(((FileTableModel) table.getModel()).getFile(row)));
                renameProjectitem.setVisible(isProject(((FileTableModel) table.getModel()).getFile(row)));
                Pmenu.show(me.getComponent(), me.getX(), me.getY());
            }
        }
    });
    //

    //}
    return tableScroll;
}

From source file:it.ventuland.ytd.ui.GUIClient.java

private void addComponentsToPane(final Container pane) {
    this.panel = new JPanel();
    this.panel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;

    ActionManager lActionManager = new ActionManager();

    dlm = new DefaultListModel<String>();
    this.urllist = new JList<String>(dlm);
    // TODO maybe we add a button to remove added URLs from list?
    //this.userlist.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
    this.urllist.setFocusable(false);
    textarea = new JTextArea(2, 2);
    textarea.setEditable(true);//from   ww  w. j  a  v  a 2s. co m
    textarea.setFocusable(false);

    JScrollPane leftscrollpane = new JScrollPane(this.urllist);
    JScrollPane rightscrollpane = new JScrollPane(textarea);
    this.middlepane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftscrollpane, rightscrollpane);
    this.middlepane.setOneTouchExpandable(true);
    this.middlepane.setDividerLocation(150);

    Dimension minimumSize = new Dimension(25, 25);
    leftscrollpane.setMinimumSize(minimumSize);
    rightscrollpane.setMinimumSize(minimumSize);

    this.directorybutton = new JButton("", createImageIcon("images/open.png", ""));
    gbc.gridx = 0;
    gbc.gridy = 0;
    this.directorybutton.addActionListener(lActionManager);
    this.panel.add(this.directorybutton, gbc);

    this.saveconfigcheckbox = new JCheckBox("Save config");
    this.saveconfigcheckbox.setSelected(false);

    this.panel.add(this.saveconfigcheckbox);

    this.saveconfigcheckbox.setEnabled(false);

    // TODO check if initial download directory exists
    // assume that at least the users homedir exists
    String shomedir = System.getProperty("user.home").concat(File.separator);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.directorytextfield = new JTextField(shomedir, 20 + (mIsDebug ? 48 : 0));
    this.directorytextfield.setEnabled(false);
    this.directorytextfield.setFocusable(true);
    this.directorytextfield.addActionListener(lActionManager);
    this.panel.add(this.directorytextfield, gbc);

    JLabel dirhint = new JLabel("Download to folder:");

    gbc.gridx = 0;
    gbc.gridy = 1;
    this.panel.add(dirhint, gbc);

    this.middlepane.setPreferredSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width / 3,
            Toolkit.getDefaultToolkit().getScreenSize().height / 4 + (mIsDebug ? 200 : 0)));

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 2;
    gbc.weightx = 2;
    gbc.gridwidth = 2;
    this.panel.add(this.middlepane, gbc);

    // radio buttons for resolution to download
    mVideoResolutionBtnGrp = new ButtonGroup();
    JPanel lRadioPanel = new JPanel(new GridLayout(1, 0));
    List<Object> lVidQ = mAppContext.getList("youtube-downloader.video-quality");
    JRadioButton lRadioButton = null;
    for (Object obj : lVidQ) {
        String lQuality = (String) obj;
        String lToolTip = mAppContext.getString("youtube-downloader.video-quality." + lQuality + ".tooltip");
        boolean lSelected = mAppContext
                .getBoolean("youtube-downloader.video-quality." + lQuality + ".selected");
        boolean lEnabled = mAppContext.getBoolean("youtube-downloader.video-quality." + lQuality + ".enabled");
        lRadioButton = new JRadioButton(lQuality);
        lRadioButton.setName(lQuality);
        lRadioButton.setActionCommand(lQuality.toLowerCase());
        lRadioButton.addActionListener(lActionManager);
        lRadioButton.setToolTipText(lToolTip);
        lRadioButton.setSelected(lSelected);
        lRadioButton.setEnabled(lEnabled);
        mVideoResolutionBtnGrp.add(lRadioButton);
        lRadioPanel.add(lRadioButton);
    }

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.gridheight = 0;
    gbc.gridwidth = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.NORTHEAST;
    this.panel.add(lRadioPanel, gbc);

    // radio buttons for video format to download
    mVideoQualityBtnGrp = new ButtonGroup();
    lRadioPanel = new JPanel(new GridLayout(1, 0));
    save3dcheckbox = new JCheckBox("3D");
    save3dcheckbox.setToolTipText("stereoscopic video");
    save3dcheckbox.setSelected(false);
    save3dcheckbox.setEnabled(true);
    lRadioPanel.add(save3dcheckbox);
    List<Object> lVidR = mAppContext.getList("youtube-downloader.video-resolution");
    lRadioButton = null;
    for (Object obj : lVidR) {
        String lResolution = (String) obj;
        String lToolTip = mAppContext
                .getString("youtube-downloader.video-resolution." + lResolution + ".tooltip");
        boolean lSelected = mAppContext
                .getBoolean("youtube-downloader.video-resolution." + lResolution + ".selected");
        boolean lEnabled = mAppContext
                .getBoolean("youtube-downloader.video-resolution." + lResolution + ".enabled");
        lRadioButton = new JRadioButton(lResolution);
        lRadioButton.setName(lResolution);
        lRadioButton.setActionCommand(lResolution.toLowerCase());
        lRadioButton.addActionListener(lActionManager);
        lRadioButton.setToolTipText(lToolTip);
        lRadioButton.setSelected(lSelected);
        lRadioButton.setEnabled(lEnabled);
        mVideoQualityBtnGrp.add(lRadioButton);
        lRadioPanel.add(lRadioButton);
    }

    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridheight = 0;
    gbc.gridwidth = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.NORTHEAST;
    this.panel.add(lRadioPanel, gbc);

    JLabel hint = new JLabel("Type, paste or drag'n drop a YouTube video address:");

    gbc.fill = 0;
    gbc.gridwidth = 0;
    gbc.gridheight = 1;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.anchor = GridBagConstraints.WEST;
    this.panel.add(hint, gbc);

    textinputfield = new JTextField(20);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.gridwidth = 2;
    textinputfield.setEnabled(true);
    textinputfield.setFocusable(true);
    textinputfield.addActionListener(lActionManager);
    textinputfield.getDocument().addDocumentListener(new UrlInsertListener());
    this.panel.add(textinputfield, gbc);

    this.quitbutton = new JButton("", createImageIcon("images/exit.png", ""));
    gbc.gridx = 2;
    gbc.gridy = 5;
    gbc.gridwidth = 0;
    this.quitbutton.addActionListener(lActionManager);
    this.quitbutton.setActionCommand("quit");
    this.quitbutton.setToolTipText("Exit.");

    this.panel.add(this.quitbutton, gbc);

    pane.add(this.panel);
    addWindowListener(new GUIWindowAdapter());

    this.setDropTarget(new DropTarget(this, new DragDropListener()));
    textarea.setTransferHandler(null); // otherwise the dropped text would be inserted

}

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.ApproximationSetViewer.java

/**
 * Lays out the components on this window.  This method is invoked by the
 * constructor, and should not be invoked again.
 *///from www  .  j  a  v  a2 s  . c om
protected void layoutComponents() {
    setLayout(new BorderLayout());

    JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.CENTER));
    buttonPane.add(useInitialBounds);
    buttonPane.add(useReferenceSetBounds);
    buttonPane.add(useDynamicBounds);
    buttonPane.add(useZoomBounds);

    JPanel objectivePane = new JPanel(new FlowLayout(FlowLayout.CENTER));
    objectivePane.add(new JLabel(localization.getString("text.xAxis")));
    objectivePane.add(xAxisSelection);
    objectivePane.add(new JLabel(localization.getString("text.yAxis")));
    objectivePane.add(yAxisSelection);

    JPanel controlPane = new JPanel(new GridLayout(3, 1));
    controlPane.add(slider);
    controlPane.add(buttonPane);
    controlPane.add(objectivePane);

    JPanel rightPane = new JPanel(new BorderLayout());
    rightPane.add(chartContainer, BorderLayout.CENTER);
    rightPane.add(controlPane, BorderLayout.SOUTH);

    JPanel leftPane = new JPanel(new BorderLayout());
    leftPane.setBorder(BorderFactory.createTitledBorder(localization.getString("text.seeds")));
    leftPane.add(new JScrollPane(seedList), BorderLayout.CENTER);
    leftPane.add(selectAll, BorderLayout.SOUTH);
    leftPane.setMinimumSize(new Dimension(100, 100));

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPane, rightPane);

    add(splitPane, BorderLayout.CENTER);
}

From source file:cl.almejo.vsim.gui.SimWindow.java

public SimWindow(Circuit circuit) {
    _circuit = circuit;/*from   w w w  . jav a2s  . c o  m*/
    _circuit.addCircuitEventListener(this);
    _canvas = new CircuitCanvas(_circuit);

    setBounds(100, 100, 800, 800);

    _displaysPane = new JTabbedPane();

    CanvasScrollPane scrollPane = new CanvasScrollPane(_canvas);
    CenterCanvasButton panel = new CenterCanvasButton();
    panel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            SimWindow.this.getCanvas().center();
        }
    });
    scrollPane.addCorner(panel);

    JSplitPane rightSplitpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPane, _displaysPane);
    rightSplitpane.setOneTouchExpandable(true);
    rightSplitpane.setDividerLocation(600);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
            new JSplitPane(JSplitPane.VERTICAL_SPLIT, getToolsPane(), new JPanel()), rightSplitpane);

    getContentPane().add(splitPane, BorderLayout.CENTER);

    JPanel statusBar = getStatusBar();
    statusBar.add(new ZoomChanger(_canvas));
    getContentPane().add(statusBar, BorderLayout.SOUTH);

    setVisible(true);

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addComponentListener(this);
    addWindowListener(this);
    _canvas.addMouseListener(this);
    _canvas.setZoom(1.0);
    _canvas.addMouseMotionListener(this);
    _canvas.resizeViewport();

    addMenu();
    addMainToolbar();
    updateActionStates();
    updateTitle();
}

From source file:edu.umich.robot.GuiApplication.java

/**
 * Entry point./*from   w w  w  . j a va  2 s. com*/
 * 
 * @param args Args from command line.
 */
public GuiApplication(Config config) {
    // Heavyweight is not desirable but it is the only thing that will
    // render in front of the Viewer on all platforms. Blame OpenGL
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);

    // must have config
    //Config config = (args.length > 0) ? ConfigUtil.getDefaultConfig(args) : promptForConfig(frame);
    if (config == null)
        System.exit(1);

    // Add more stuff to the config file that doesn't change between runs.
    Application.setupSimulatorConfig(config);
    setupViewerConfig(config);

    Configs.toLog(logger, config);

    controller = new Controller(config, new Gamepad());
    controller.initializeGamepad();

    viewer = new Viewer(config, frame);
    // This puts us in full 3d mode by default. The Viewer GUI doesn't
    // reflect this in its right click drop-down, a bug.
    viewer.getVisCanvas().getViewManager().setInterfaceMode(3);

    controller.addListener(RobotAddedEvent.class, listener);
    controller.addListener(RobotRemovedEvent.class, listener);
    controller.addListener(AfterResetEvent.class, listener);
    controller.addListener(ControllerActivatedEvent.class, listener);
    controller.addListener(ControllerDeactivatedEvent.class, listener);

    actionManager = new ActionManager(this);
    initActions();

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            controller.shutdown();
            System.exit(0);
        }
    });
    frame.setLayout(new BorderLayout());

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    fileMenu.add(actionManager.getAction(CreateSplinterRobotAction.class));
    fileMenu.add(actionManager.getAction(CreateSuperdroidRobotAction.class));
    fileMenu.add(new JSeparator());
    fileMenu.add(actionManager.getAction(ConnectSuperdroidAction.class));
    fileMenu.add(new JSeparator());
    fileMenu.add(actionManager.getAction(ResetPreferencesAction.class));

    /*
    fileMenu.add(new JSeparator());
    fileMenu.add(actionManager.getAction(TextMessageAction.class));
    */

    fileMenu.add(new JSeparator());
    fileMenu.add(actionManager.getAction(SaveMapAction.class));
    fileMenu.add(new JSeparator());
    fileMenu.add(actionManager.getAction(ExitAction.class));
    menuBar.add(fileMenu);

    JMenu cameraMenu = new JMenu("Camera");
    cameraMenu.add(actionManager.getAction(DisableFollowAction.class));
    cameraMenu.add(actionManager.getAction(FollowPositionAction.class));
    cameraMenu.add(actionManager.getAction(FollowPositionAndThetaAction.class));
    cameraMenu.add(new JSeparator());
    cameraMenu.add(actionManager.getAction(MoveCameraBehindAction.class));
    cameraMenu.add(actionManager.getAction(MoveCameraAboveAction.class));
    menuBar.add(cameraMenu);

    JMenu objectMenu = new JMenu("Objects");
    boolean added = false;
    for (String objectName : controller.getObjectNames()) {
        added = true;
        objectMenu.add(new AddObjectAction(this, objectName));
    }
    if (!added)
        objectMenu.add(new JLabel("No objects available"));
    menuBar.add(objectMenu);

    menuBar.revalidate();
    frame.setJMenuBar(menuBar);

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    toolBar.add(actionManager.getAction(SoarParametersAction.class));
    toolBar.add(actionManager.getAction(SoarDataAction.class));
    toolBar.add(actionManager.getAction(ResetAction.class));
    toolBar.add(actionManager.getAction(SoarToggleAction.class));
    toolBar.add(actionManager.getAction(SoarStepAction.class));
    toolBar.add(actionManager.getAction(SimSpeedAction.class));
    frame.add(toolBar, BorderLayout.PAGE_START);

    viewerView = new ViewerView(viewer.getVisCanvas());
    robotsView = new RobotsView(this, actionManager);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, viewerView, robotsView);
    splitPane.setDividerLocation(0.75);

    // TODO SoarApril
    /*
    viewer.addRobotSelectionChangedListener(robotsView);
    viewer.getVisCanvas().setDrawGround(true);
    */

    viewer.getVisCanvas().addEventHandler(new VisCanvasEventAdapter() {

        public String getName() {
            return "Place Object";
        }

        @Override
        public boolean mouseClicked(VisCanvas vc, GRay3D ray, MouseEvent e) {
            boolean ret = false;
            synchronized (GuiApplication.this) {
                if (objectToAdd != null && controller != null) {
                    controller.addObject(objectToAdd, ray.intersectPlaneXY());
                    objectToAdd = null;
                    ret = true;
                } else {
                    double[] click = ray.intersectPlaneXY();
                    chatView.setClick(new Point2D.Double(click[0], click[1]));
                }
            }
            status.setMessage(
                    String.format("%3.1f,%3.1f", ray.intersectPlaneXY()[0], ray.intersectPlaneXY()[1]));
            return ret;
        }
    });

    consoleView = new ConsoleView();
    chatView = new ChatView(this);
    controller.getRadio().addRadioHandler(chatView);

    final JSplitPane bottomPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, consoleView, chatView);
    bottomPane.setDividerLocation(200);

    final JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, splitPane, bottomPane);
    splitPane2.setDividerLocation(0.75);

    frame.add(splitPane2, BorderLayout.CENTER);

    status = new StatusBar();
    frame.add(status, BorderLayout.SOUTH);

    /*
    frame.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(WindowEvent e)
    {
        final Preferences windowPrefs = getWindowPreferences();
        final Rectangle r = frame.getBounds();
        if(frame.getExtendedState() == JFrame.NORMAL)
        {
            windowPrefs.putInt("x", r.x);
            windowPrefs.putInt("y", r.y);
            windowPrefs.putInt("width", r.width);
            windowPrefs.putInt("height", r.height);
            windowPrefs.putInt("divider", splitPane.getDividerLocation());
        }
                
        exit();
    }});
            
    Preferences windowPrefs = getWindowPreferences();
    if (windowPrefs.get("x", null) != null)
    {
    frame.setBounds(
            windowPrefs.getInt("x", 0), 
            windowPrefs.getInt("y", 0), 
            windowPrefs.getInt("width", 1200), 
            windowPrefs.getInt("height", 900));
    splitPane.setDividerLocation(windowPrefs.getInt("divider", 500));
    }
    else
    {
    frame.setBounds(
            windowPrefs.getInt("x", 0), 
            windowPrefs.getInt("y", 0), 
            windowPrefs.getInt("width", 1200), 
            windowPrefs.getInt("height", 900));
    splitPane.setDividerLocation(0.75);
    frame.setLocationRelativeTo(null); // center
    }
    */

    frame.getRootPane().setBounds(0, 0, 1600, 1200);

    frame.getRootPane().registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            frame.dispose();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);

    frame.pack();

    frame.setVisible(true);

    for (String s : config.getStrings("splinters", new String[0])) {
        double[] pos = config.getDoubles(s + ".position");
        if (pos == null) {
            logger.error("Splinter indexed in config file but no position defined: " + s);
            continue;
        }

        Pose pose = new Pose(pos);
        String prods = config.getString(s + ".productions");
        boolean collisions = config.getBoolean(s + ".wallCollisions", true);

        controller.createSplinterRobot(s, pose, collisions);
        boolean simulated = config.getBoolean(s + ".simulated", true);
        if (simulated)
            controller.createSimSplinter(s);
        else
            controller.createRealSplinter(s);
        controller.createSimLaser(s);
        if (prods != null) {
            controller.createSoarController(s, s, prods, config.getChild(s + ".properties"));
            PREFERENCES.put("lastProductions", prods);
        }
    }

    for (String s : config.getStrings("superdroids", new String[0])) {
        double[] pos = config.getDoubles(s + ".position");
        if (pos == null) {
            logger.error("Superdroid indexed in config file but no position defined: " + s);
            continue;
        }

        Pose pose = new Pose(pos);
        String prods = config.getString(s + ".productions");
        boolean collisions = config.getBoolean(s + ".wallCollisions", true);

        controller.createSuperdroidRobot(s, pose, collisions);
        boolean simulated = config.getBoolean(s + ".simulated", true);
        if (simulated)
            controller.createSimSuperdroid(s);
        else {
            try {
                controller.createRealSuperdroid(s, "192.168.1.165", 3192);
            } catch (UnknownHostException e1) {
                e1.printStackTrace();
            } catch (SocketException e1) {
                e1.printStackTrace();
            }
        }
        controller.createSimLaser(s);
        if (prods != null) {
            // wait a sec
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
            }
            controller.createSoarController(s, s, prods, config.getChild(s + ".properties"));
            PREFERENCES.put("lastProductions", prods);
        }
    }

}

From source file:com.pironet.tda.TDA.java

/**
 * initializes tda panel//from  ww  w.  jav  a  2  s  . c o m
 *
 * @param asJConsolePlugin specifies if tda is running as plugin
 */
public void init(boolean asJConsolePlugin, boolean asVisualVMPlugin) {
    // init everything
    tree = new JTree();
    addTreeListener(tree);
    runningAsJConsolePlugin = asJConsolePlugin;
    runningAsVisualVMPlugin = asVisualVMPlugin;

    //Create the HTML viewing pane.
    if (!this.runningAsVisualVMPlugin && !this.runningAsJConsolePlugin) {
        InputStream is = TDA.class.getResourceAsStream("/doc/welcome.html");

        htmlPane = new JEditorPane();

        String welcomeText = parseWelcomeURL(is);
        htmlPane.setContentType("text/html");
        htmlPane.setText(welcomeText);
    } else if (asJConsolePlugin) {
        htmlPane = new JEditorPane("text/html",
                "<html><body bgcolor=\"ffffff\"><i>Press Button above to request a thread dump.</i></body></html>");

    } else {
        htmlPane = new JEditorPane("text/html", "<html><body bgcolor=\"ffffff\"></body></html>");
    }
    htmlPane.putClientProperty(Const.AA_TEXT_INFO_PROPERTY_KEY, Boolean.TRUE);
    htmlPane.setEditable(false);

    if (!asJConsolePlugin && !asVisualVMPlugin) {
        hdt = new DropTarget(htmlPane, new FileDropTargetListener());
    }

    JEditorPane emptyPane = new JEditorPane("text/html", "");
    emptyPane.setEditable(false);

    htmlPane.addHyperlinkListener(evt -> {
        // if a link was clicked
        if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
            if (evt.getDescription().startsWith("monitor")) {
                navigateToMonitor(evt.getDescription());
            } else if (evt.getDescription().startsWith("dump")) {
                navigateToDump();
            } else if (evt.getDescription().startsWith("wait")) {
                navigateToChild("Threads waiting");
            } else if (evt.getDescription().startsWith("sleep")) {
                navigateToChild("Threads sleeping");
            } else if (evt.getDescription().startsWith("dead")) {
                navigateToChild("Deadlocks");
            } else if (evt.getDescription().startsWith("threaddump")) {
                addMXBeanDump();
            } else if (evt.getDescription().startsWith("openlogfile") && !evt.getDescription().endsWith("//")) {
                File[] files = { new File(evt.getDescription().substring(14)) };
                openFiles(files, false);
            } else if (evt.getDescription().startsWith("openlogfile")) {
                chooseFile();
            } else if (evt.getDescription().startsWith("opensession") && !evt.getDescription().endsWith("//")) {
                File file = new File(evt.getDescription().substring(14));
                openSession(file, true);
            } else if (evt.getDescription().startsWith("opensession")) {
                openSession();
            } else if (evt.getDescription().startsWith("preferences")) {
                showPreferencesDialog();
            } else if (evt.getDescription().startsWith("filters")) {
                showFilterDialog();
            } else if (evt.getDescription().startsWith("categories")) {
                showCategoriesDialog();
            } else if (evt.getDescription().startsWith("overview")) {
                showHelp();
            } else if (evt.getURL() != null) {
                try {
                    // launch a browser with the appropriate URL
                    Browser.open(evt.getURL().toString());
                } catch (InterruptedException e) {
                    System.out.println("Error launching external browser.");
                } catch (IOException e) {
                    System.out.println("I/O error launching external browser." + e.getMessage());
                    e.printStackTrace();
                }
            }
        }
    });

    htmlView = new ViewScrollPane(htmlPane, runningAsVisualVMPlugin);
    ViewScrollPane emptyView = new ViewScrollPane(emptyPane, runningAsVisualVMPlugin);

    // create the top split pane
    topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    topSplitPane.setLeftComponent(emptyView);
    topSplitPane.setDividerSize(Const.DIVIDER_SIZE);
    topSplitPane.setContinuousLayout(true);

    //Add the scroll panes to a split pane.
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setBottomComponent(htmlView);
    splitPane.setTopComponent(topSplitPane);
    splitPane.setDividerSize(Const.DIVIDER_SIZE);
    splitPane.setContinuousLayout(true);

    if (this.runningAsVisualVMPlugin) {
        setOpaque(true);
        setBackground(Color.WHITE);
        setBorder(BorderFactory.createEmptyBorder(6, 0, 3, 0));
        topSplitPane.setBorder(BorderFactory.createEmptyBorder());
        topSplitPane.setOpaque(false);
        topSplitPane.setBackground(Color.WHITE);
        htmlPane.setBorder(BorderFactory.createEmptyBorder());
        htmlPane.setOpaque(false);
        htmlPane.setBackground(Color.WHITE);
        splitPane.setBorder(BorderFactory.createEmptyBorder());
        splitPane.setOpaque(false);
        splitPane.setBackground(Color.WHITE);
    }

    Dimension minimumSize = new Dimension(200, 50);
    htmlView.setMinimumSize(minimumSize);
    emptyView.setMinimumSize(minimumSize);

    //Add the split pane to this panel.
    add(htmlView, BorderLayout.CENTER);

    statusBar = new StatusBar(!(asJConsolePlugin || asVisualVMPlugin));
    add(statusBar, BorderLayout.SOUTH);

    firstFile = true;
    setFileOpen(false);

    if (!runningAsVisualVMPlugin) {
        setShowToolbar(PrefManager.get().getShowToolbar());
    }

    if (firstFile && runningAsVisualVMPlugin) {
        // init filechooser
        fc = new JFileChooser();
        fc.setMultiSelectionEnabled(true);
        fc.setCurrentDirectory(PrefManager.get().getSelectedPath());
    }
}

From source file:de.xplib.xdbm.ui.Application.java

/**
 * //  w  w  w.  j a  va  2  s  . com
 */
private void initUI() {

    this.getContentPane().setLayout(new DockLayout(this, DockLayout.STACKING_STYLE));

    this.menuBar = new ApplicationMenuBar(this);
    this.toolBars = new ApplicationToolBars(this);
    this.consolePanel = new BottomFrame(this);
    this.treePanel = new LeftFrame(this);
    this.resourceFrame = new CenterFrame(this);

    this.jspContentConsole = new UIFSplitPane();
    this.jspTreeResource = new UIFSplitPane();

    this.add(this.jspContentConsole, DockLayout.center);

    this.jspContentConsole.setBorder(BorderFactory.createEmptyBorder());
    this.jspContentConsole.setOrientation(JSplitPane.VERTICAL_SPLIT);
    this.jspContentConsole.setDividerSize(5);
    this.jspContentConsole.add(this.jspTreeResource, JSplitPane.TOP);
    this.jspContentConsole.add(this.consolePanel, JSplitPane.BOTTOM);

    this.jspTreeResource.setBorder(BorderFactory.createEmptyBorder());
    this.jspTreeResource.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    this.jspTreeResource.setDividerSize(5);
    this.jspTreeResource.setDividerLocation(200);
    this.jspTreeResource.add(this.treePanel, JSplitPane.TOP);
    this.jspTreeResource.add(this.resourceFrame, JSplitPane.BOTTOM);

    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

    this.setSize((int) dim.getWidth(), (int) dim.getHeight() - 30);
    this.setVisible(true);
}

From source file:sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();//from   www.  jav  a 2  s.  c o  m
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null)
                startMovie();
            else
                stopMovie();
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0)
                newValue = currentValue;
            if (newValue > MAXIMUM_SCALE)
                newValue = currentValue;
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0)
                newValue = currentValue;
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}