Example usage for java.awt Container setLayout

List of usage examples for java.awt Container setLayout

Introduction

In this page you can find the example usage for java.awt Container setLayout.

Prototype

public void setLayout(LayoutManager mgr) 

Source Link

Document

Sets the layout manager for this container.

Usage

From source file:edu.oregonstate.eecs.mcplan.domains.racetrack.RacetrackVisualization.java

public RacetrackVisualization(final Circuit circuit, final RacetrackSimulator sim, final double scale) {
    if (sim != null) {
        this.sim = sim;
        this.state = sim.state();
    }//from w w  w . j  a v a2 s  .c  o m

    this.circuit = circuit;
    this.scale = scale;

    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                final JFrame frame = new JFrame();
                final Container cp = frame.getContentPane();
                cp.setLayout(new BorderLayout());

                draw_panel_ = new DrawPanel();
                final Dimension d = new Dimension((int) scale * circuit.width + 20,
                        (int) scale * circuit.height + 20);
                draw_panel_.setPreferredSize(d);
                draw_panel_.setSize(d);
                cp.add(draw_panel_, BorderLayout.CENTER);

                control_panel_ = new ControlPanel();
                cp.add(control_panel_, BorderLayout.SOUTH);

                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setResizable(false);
                frame.pack();
                frame.setVisible(true);
            }
        });
    } catch (final Exception ex) {
        throw new RuntimeException(ex);
    }

    if (sim != null) {
        updateStateOnEDT(sim.state());
    }
}

From source file:com.mgmtp.jfunk.core.ui.JFunkFrame.java

private void setUpGui() {
    buildMenuBar();/*from  w w w . j a  v a  2 s  . co m*/
    buildToolBar();
    buildPopup();
    buildTree();

    BufferedImage image = null;
    try {
        image = ImageIO.read(getClass().getResource("/jFunk.png"));
        setIconImage(image);
    } catch (Exception e) {
        log.warn("Could not read icon image, standard icon will be used. Exception was: " + e.getMessage());
    }

    setJMenuBar(menuBar);

    if (!readState()) {
        setSize(520, 600);
        setLocationRelativeTo(null);
    }

    final JScrollPane scrollPane = new JScrollPane(tree, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    final Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(jPanelUtilities, BorderLayout.NORTH);
    contentPane.add(scrollPane, BorderLayout.CENTER);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(final WindowEvent e) {
            exit();
        }
    });
}

From source file:org.owasp.jbrofuzz.ui.viewers.WindowViewerFrame.java

/**
 * <p>/*from  w ww.j av a 2s  .c o m*/
 * The window viewer that gets launched for each request within the
 * corresponding panel.
 * </p>
 * 
 * @param parent The parent panel that the frame will belong to
 * @param name The full file name of the file location to be opened
 * 
 * @author subere@uncon.org
 * @version 2.0
 * @since 2.0
 */
public WindowViewerFrame(final AbstractPanel parent, final String name) {

    super("JBroFuzz - File Viewer - " + name);

    setIconImage(ImageCreator.IMG_FRAME.getImage());

    // The container pane
    final Container pane = getContentPane();
    pane.setLayout(new BorderLayout());

    // Define the Panel
    final JPanel listPanel = new JPanel();
    listPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(name),
            BorderFactory.createEmptyBorder(1, 1, 1, 1)));
    listPanel.setLayout(new BorderLayout());

    // Get the preferences for wrapping lines of text
    final boolean wrapText = JBroFuzz.PREFS.getBoolean(JBroFuzzPrefs.FUZZING[3].getId(), false);

    if (wrapText) {

        listTextArea = new JTextPane();

    } else {

        listTextArea = new NonWrappingTextPane();

    }

    // Refine the Text Area
    listTextArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
    listTextArea.setEditable(false);

    // Define the search area
    entry = new JTextField(10);
    status = new JLabel("Enter text to search:");

    // Initialise the highlighter on the text area
    hilit = new DefaultHighlighter();
    painter = new DefaultHighlighter.DefaultHighlightPainter(HILIT_COLOR);
    listTextArea.setHighlighter(hilit);

    entryBg = entry.getBackground();
    entry.getDocument().addDocumentListener(this);

    final InputMap im = entry.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    final ActionMap am = entry.getActionMap();
    im.put(KeyStroke.getKeyStroke("ESCAPE"), CANCEL_ACTION);
    am.put(CANCEL_ACTION, new CancelAction());

    // Right click: Cut, Copy, Paste, Select All
    AbstractPanel.popupText(listTextArea, false, true, false, true);

    // Define the Scroll Pane for the Text Area
    final JScrollPane listTextScrollPane = new JScrollPane(listTextArea);
    listTextScrollPane.setVerticalScrollBarPolicy(20);
    listTextScrollPane.setHorizontalScrollBarPolicy(30);

    // Define the progress bar
    final JProgressBar progressBar = new JProgressBar();
    progressBar.setString("   ");
    progressBar.setStringPainted(true);

    // Define the bottom panel with the progress bar
    final JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 15, 15));
    bottomPanel.add(status);
    bottomPanel.add(entry);
    bottomPanel.add(progressBar);

    listTextArea.setCaretPosition(0);
    // doSyntaxHighlight();
    /*      listTextArea.setEditorKit(new StyledEditorKit() {
            
             private static final long serialVersionUID = -6085642347022880064L;
            
             @Override
             public Document createDefaultDocument() {
    return new TextHighlighter();
             }
            
          });
    */

    listPanel.add(listTextScrollPane);

    // Global Frame Issues
    pane.add(listPanel, BorderLayout.CENTER);
    pane.add(bottomPanel, BorderLayout.SOUTH);

    this.setLocation(parent.getLocationOnScreen().x + 100, parent.getLocationOnScreen().y + 20);
    this.setSize(SIZE_X, SIZE_Y);

    setResizable(true);
    setVisible(true);
    setMinimumSize(new Dimension(SIZE_X, SIZE_Y));
    setDefaultCloseOperation(2);

    listTextArea.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(final KeyEvent ke) {
            if (ke.getKeyCode() == 27) {
                WindowViewerFrame.this.dispose();
            }
            if (ke.getKeyCode() == 10) {
                search();
            }
        }
    });

    entry.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(final KeyEvent ke) {
            if (ke.getKeyCode() == 10) {
                search();
            }
        }
    });

    class FileLoader extends SwingWorker<String, Object> { // NO_UCD

        @Override
        public String doInBackground() {

            progressBar.setIndeterminate(true);

            String dbType = JBroFuzz.PREFS.get(JBroFuzzPrefs.DBSETTINGS[11].getId(), "-1");

            if (dbType.equals("SQLite") || dbType.equals("CouchDB")) {

                String sessionId = parent.getFrame().getJBroFuzz().getWindow().getPanelFuzzing()
                        .getSessionName();

                if (sessionId == null || sessionId.equals("null")) {
                    sessionId = JBroFuzz.PREFS.get("sessionId", "");
                }

                Logger.log("Reading Session: " + sessionId + " with name: " + name, 3);

                MessageContainer mc = parent.getFrame().getJBroFuzz().getStorageHandler()
                        .readFuzzFile(name, sessionId, parent.getFrame().getJBroFuzz().getWindow()).get(0);

                listTextArea.setText("Date: " + mc.getEndDateFull() + "\n" + "FileName: " + mc.getFileName()
                        + "\n" + "URL: " + mc.getTextURL() + "\n" + "Payload: " + mc.getPayload() + "\n"
                        + "EncodedPayload: " + mc.getEncodedPayload() + "\n" + "TextRequest:"
                        + mc.getTextRequest() + "\n" + "Message: " + mc.getMessage() + "\n" + "Status: "
                        + mc.getStatus() + "\n"

                );

            } else {
                Logger.log("Loading data from file", 3);
                final File inputFile = new File(parent.getFrame().getJBroFuzz().getWindow().getPanelFuzzing()
                        .getFrame().getJBroFuzz().getStorageHandler().getLocationURIString(), name + ".html");

                listTextArea.setText(

                        FileHandler.readFile(inputFile)

                );
            }
            return "done";
        }

        @Override
        protected void done() {
            progressBar.setIndeterminate(false);
            progressBar.setValue(100);
            listTextArea.repaint();
        }
    }

    (new FileLoader()).execute();

}

From source file:RSAccounts.java

private void buildGUI() {
    Container c = getContentPane();
    c.setLayout(new FlowLayout());

    accountNumberList = new JList();
    loadAccounts();//  ww  w . ja va  2s.c  o m
    accountNumberList.setVisibleRowCount(2);
    JScrollPane accountNumberListScrollPane = new JScrollPane(accountNumberList);

    gotoText = new JTextField(3);
    freeQueryText = new JTextField(40);

    //Do Get Account Button
    getAccountButton = new JButton("Get Account");
    getAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                rs.first();
                while (rs.next()) {
                    if (rs.getString("acc_id").equals(accountNumberList.getSelectedValue()))
                        break;
                }
                if (!rs.isAfterLast()) {
                    accountIDText.setText(rs.getString("acc_id"));
                    usernameText.setText(rs.getString("username"));
                    passwordText.setText(rs.getString("password"));
                    tsText.setText(rs.getString("ts"));
                    activeTSText.setText(rs.getString("act_ts"));
                }
            } catch (SQLException selectException) {
                displaySQLErrors(selectException);
            }
        }
    });

    //Do Insert Account Button
    insertAccountButton = new JButton("Insert Account");
    insertAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Statement statement = connection.createStatement();
                int i = statement.executeUpdate("INSERT INTO acc_acc VALUES(" + accountIDText.getText() + ", "
                        + "'" + usernameText.getText() + "', " + "'" + passwordText.getText() + "', " + "0"
                        + ", " + "now())");
                errorText.append("Inserted " + i + " rows successfully");
                accountNumberList.removeAll();
                loadAccounts();
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            }
        }
    });

    //Do Delete Account Button
    deleteAccountButton = new JButton("Delete Account");
    deleteAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Statement statement = connection.createStatement();
                int i = statement.executeUpdate(
                        "DELETE FROM acc_acc WHERE acc_id = " + accountNumberList.getSelectedValue());
                errorText.append("Deleted " + i + " rows successfully");
                accountNumberList.removeAll();
                loadAccounts();
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            }
        }
    });

    //Do Update Account Button
    updateAccountButton = new JButton("Update Account");
    updateAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Statement statement = connection.createStatement();
                int i = statement.executeUpdate("UPDATE acc_acc " + "SET username='" + usernameText.getText()
                        + "', " + "password='" + passwordText.getText() + "', " + "act_ts = now() "
                        + "WHERE acc_id = " + accountNumberList.getSelectedValue());
                errorText.append("Updated " + i + " rows successfully");
                accountNumberList.removeAll();
                loadAccounts();
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            }
        }
    });

    //Do Next Button
    nextButton = new JButton(">");
    nextButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                if (!rs.isLast()) {
                    rs.next();
                    accountIDText.setText(rs.getString("acc_id"));
                    usernameText.setText(rs.getString("username"));
                    passwordText.setText(rs.getString("password"));
                    tsText.setText(rs.getString("ts"));
                    activeTSText.setText(rs.getString("act_ts"));
                }
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            }
        }
    });

    //Do Next Button
    previousButton = new JButton("<");
    previousButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                if (!rs.isFirst()) {
                    rs.previous();
                    accountIDText.setText(rs.getString("acc_id"));
                    usernameText.setText(rs.getString("username"));
                    passwordText.setText(rs.getString("password"));
                    tsText.setText(rs.getString("ts"));
                    activeTSText.setText(rs.getString("act_ts"));
                }
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            }
        }
    });

    //Do last Button
    lastButton = new JButton(">|");
    lastButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                rs.last();
                accountIDText.setText(rs.getString("acc_id"));
                usernameText.setText(rs.getString("username"));
                passwordText.setText(rs.getString("password"));
                tsText.setText(rs.getString("ts"));
                activeTSText.setText(rs.getString("act_ts"));
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            }
        }
    });

    //Do first Button
    firstButton = new JButton("|<");
    firstButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                rs.first();
                accountIDText.setText(rs.getString("acc_id"));
                usernameText.setText(rs.getString("username"));
                passwordText.setText(rs.getString("password"));
                tsText.setText(rs.getString("ts"));
                activeTSText.setText(rs.getString("act_ts"));
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            }
        }
    });

    //Do gotoButton
    gotoButton = new JButton("Goto");
    gotoButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                rs.absolute(Integer.parseInt(gotoText.getText()));
                accountIDText.setText(rs.getString("acc_id"));
                usernameText.setText(rs.getString("username"));
                passwordText.setText(rs.getString("password"));
                tsText.setText(rs.getString("ts"));
                activeTSText.setText(rs.getString("act_ts"));
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            }
        }
    });

    //Do freeQueryButton
    freeQueryButton = new JButton("Execute Query");
    freeQueryButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                if (freeQueryText.getText().toUpperCase().indexOf("SELECT") >= 0) {
                    rs = statement.executeQuery(freeQueryText.getText());
                    if (rs.next()) {
                        accountIDText.setText(rs.getString("acc_id"));
                        usernameText.setText(rs.getString("username"));
                        passwordText.setText(rs.getString("password"));
                        tsText.setText(rs.getString("ts"));
                        activeTSText.setText(rs.getString("act_ts"));
                    }
                } else {
                    int i = statement.executeUpdate(freeQueryText.getText());
                    errorText.append("Rows affected = " + i);
                    loadAccounts();
                }
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            }
        }
    });

    JPanel first = new JPanel(new GridLayout(5, 1));
    first.add(accountNumberListScrollPane);
    first.add(getAccountButton);
    first.add(insertAccountButton);
    first.add(deleteAccountButton);
    first.add(updateAccountButton);

    accountIDText = new JTextField(15);
    usernameText = new JTextField(15);
    passwordText = new JTextField(15);
    tsText = new JTextField(15);
    activeTSText = new JTextField(15);
    errorText = new JTextArea(5, 15);
    errorText.setEditable(false);

    JPanel second = new JPanel();
    second.setLayout(new GridLayout(6, 1));
    second.add(accountIDText);
    second.add(usernameText);
    second.add(passwordText);
    second.add(tsText);
    second.add(activeTSText);

    JPanel third = new JPanel();
    third.add(new JScrollPane(errorText));

    JPanel fourth = new JPanel();
    fourth.add(firstButton);
    fourth.add(previousButton);
    fourth.add(nextButton);
    fourth.add(lastButton);
    fourth.add(gotoText);
    fourth.add(gotoButton);

    JPanel fifth = new JPanel();
    fifth.add(freeQueryText);

    c.add(first);
    c.add(second);
    c.add(third);
    c.add(fourth);
    c.add(fifth);
    c.add(freeQueryButton);
    setSize(500, 500);
    show();
}

From source file:org.broad.igv.util.stats.KMPlotFrame.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    panel1 = new JPanel();
    panel2 = new JPanel();
    label2 = new JLabel();
    survivalColumnControl = new JComboBox();
    panel3 = new JPanel();
    label3 = new JLabel();
    censurColumnControl = new JComboBox();
    panel4 = new JPanel();
    label4 = new JLabel();
    groupByControl = new JComboBox();

    //======== this ========
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Kaplan-Meier Plot");
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    //======== dialogPane ========
    {//from   ww  w  . ja  v  a  2s  . c  o  m
        dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
        dialogPane.setLayout(new BorderLayout());

        //======== contentPanel ========
        {
            contentPanel.setLayout(new BorderLayout());

            //======== panel1 ========
            {
                panel1.setAlignmentX(0.0F);
                panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS));

                //======== panel2 ========
                {
                    panel2.setAlignmentX(1.0F);
                    panel2.setLayout(null);

                    //---- label2 ----
                    label2.setText("Survival column");
                    panel2.add(label2);
                    label2.setBounds(new Rectangle(new Point(5, 10), label2.getPreferredSize()));

                    //---- survivalColumnControl ----
                    survivalColumnControl.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            survivalColumnControlActionPerformed(e);
                        }
                    });
                    panel2.add(survivalColumnControl);
                    survivalColumnControl.setBounds(120, 5, 235,
                            survivalColumnControl.getPreferredSize().height);

                    { // compute preferred size
                        Dimension preferredSize = new Dimension();
                        for (int i = 0; i < panel2.getComponentCount(); i++) {
                            Rectangle bounds = panel2.getComponent(i).getBounds();
                            preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                            preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
                        }
                        Insets insets = panel2.getInsets();
                        preferredSize.width += insets.right;
                        preferredSize.height += insets.bottom;
                        panel2.setMinimumSize(preferredSize);
                        panel2.setPreferredSize(preferredSize);
                    }
                }
                panel1.add(panel2);

                //======== panel3 ========
                {
                    panel3.setAlignmentX(1.0F);
                    panel3.setLayout(null);

                    //---- label3 ----
                    label3.setText("Censure column");
                    panel3.add(label3);
                    label3.setBounds(new Rectangle(new Point(5, 10), label3.getPreferredSize()));

                    //---- censurColumnControl ----
                    censurColumnControl.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            survivalColumnControlActionPerformed(e);
                        }
                    });
                    panel3.add(censurColumnControl);
                    censurColumnControl.setBounds(120, 5, 235, censurColumnControl.getPreferredSize().height);

                    { // compute preferred size
                        Dimension preferredSize = new Dimension();
                        for (int i = 0; i < panel3.getComponentCount(); i++) {
                            Rectangle bounds = panel3.getComponent(i).getBounds();
                            preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                            preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
                        }
                        Insets insets = panel3.getInsets();
                        preferredSize.width += insets.right;
                        preferredSize.height += insets.bottom;
                        panel3.setMinimumSize(preferredSize);
                        panel3.setPreferredSize(preferredSize);
                    }
                }
                panel1.add(panel3);

                //======== panel4 ========
                {
                    panel4.setAlignmentX(1.0F);
                    panel4.setLayout(null);

                    //---- label4 ----
                    label4.setText("Group by");
                    panel4.add(label4);
                    label4.setBounds(new Rectangle(new Point(5, 10), label4.getPreferredSize()));

                    //---- groupByControl ----
                    groupByControl.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            survivalColumnControlActionPerformed(e);
                        }
                    });
                    panel4.add(groupByControl);
                    groupByControl.setBounds(120, 5, 235, groupByControl.getPreferredSize().height);

                    { // compute preferred size
                        Dimension preferredSize = new Dimension();
                        for (int i = 0; i < panel4.getComponentCount(); i++) {
                            Rectangle bounds = panel4.getComponent(i).getBounds();
                            preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                            preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
                        }
                        Insets insets = panel4.getInsets();
                        preferredSize.width += insets.right;
                        preferredSize.height += insets.bottom;
                        panel4.setMinimumSize(preferredSize);
                        panel4.setPreferredSize(preferredSize);
                    }
                }
                panel1.add(panel4);
            }
            contentPanel.add(panel1, BorderLayout.NORTH);
        }
        dialogPane.add(contentPanel, BorderLayout.CENTER);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    setSize(565, 510);
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:savant.view.swing.BookmarkSheet.java

public BookmarkSheet(Container c) {

    // set the layout of the data sheet
    c.setLayout(new BorderLayout());
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    /**//from ww w.  j  a v a2s .  c o m
     * Create a toolbar. 
     */
    JMenuBar toolbar = new JMenuBar();
    toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS));
    c.add(toolbar, BorderLayout.NORTH);

    JButton previousButton = new JButton();
    previousButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UP));
    previousButton.setToolTipText("Go to previous bookmark [ Ctrl+( ]");
    previousButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    previousButton.putClientProperty("JButton.segmentPosition", "first");
    previousButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToPreviousBookmark();
        }

    });
    toolbar.add(previousButton);

    JButton nextButton = new JButton();
    nextButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.DOWN));
    nextButton.setToolTipText("Go to next bookmark [ Ctrl+) ]");
    nextButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    nextButton.putClientProperty("JButton.segmentPosition", "last");
    nextButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToNextBookmark();
        }

    });
    toolbar.add(nextButton);

    JButton goButton = new JButton("Go");
    goButton.setToolTipText("Go to selected bookmark");
    goButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    goButton.putClientProperty("JButton.segmentPosition", "only");
    goButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            goToSelectedBookmark();
        }

    });
    toolbar.add(goButton);

    toolbar.add(Box.createGlue());

    addButton = new JButton();
    addButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_ADD));
    addButton.setToolTipText("Add bookmark for current range");
    addButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    addButton.putClientProperty("JButton.segmentPosition", "first");
    addButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            BookmarkController fc = BookmarkController.getInstance();
            fc.addCurrentRangeToBookmarks();
        }
    });
    toolbar.add(addButton);

    JButton deleteButton = new JButton();
    deleteButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_RM));
    deleteButton.setToolTipText("Delete selected bookmarks");
    deleteButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    deleteButton.putClientProperty("JButton.segmentPosition", "last");
    deleteButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            BookmarkController fc = BookmarkController.getInstance();
            int[] selectedRows = table.getSelectedRows();
            Arrays.sort(selectedRows);
            boolean delete = false;

            if (selectedRows.length > 0 && confirmDelete) {
                Object[] options = { "Yes", "No", "Yes, don't ask again" };
                JLabel message = new JLabel(
                        "Are you sure you want to delete " + selectedRows.length + " item(s)?");
                message.setPreferredSize(new Dimension(300, 20));
                int confirmDeleteDialog = JOptionPane.showOptionDialog(DialogUtils.getMainWindow(), message,
                        "Confirm Delete", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                        options, options[0]);

                if (confirmDeleteDialog == 0) {
                    delete = true;
                } else if (confirmDeleteDialog == 2) {
                    delete = true;
                    confirmDelete = false;
                }
            } else if (selectedRows.length > 0 && !confirmDelete) {
                delete = true;
            }

            if (delete) {
                for (int i = selectedRows.length - 1; i >= 0; i--) {
                    fc.removeBookmark(selectedRows[i]);
                }
            }
        }
    });
    toolbar.add(deleteButton);

    toolbar.add(Box.createGlue());

    JButton loadButton = new JButton();
    loadButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.OPEN));
    loadButton.setToolTipText("Load bookmarks from file");
    loadButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    loadButton.putClientProperty("JButton.segmentPosition", "first");
    loadButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            loadBookmarks(table);
        }
    });
    toolbar.add(loadButton);

    JButton saveButton = new JButton();
    saveButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SAVE));
    saveButton.setToolTipText("Save bookmarks to file");
    saveButton.putClientProperty("JButton.buttonType", "segmentedRoundRect");
    saveButton.putClientProperty("JButton.segmentPosition", "last");
    saveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            saveBookmarks(table);
        }
    });
    toolbar.add(saveButton);

    // create a table (the most important component)
    table = new JTable(new BookmarksTableModel());
    table.setAutoCreateRowSorter(true);
    table.setFillsViewportHeight(true);
    table.setShowGrid(true);
    table.setGridColor(Color.gray);
    //table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

    // add the table and its header to the subpanel
    c.add(table.getTableHeader());

    add(table);

    final JScrollPane sp = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    sp.setWheelScrollingEnabled(false);
    sp.addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            sp.getVerticalScrollBar().setValue(sp.getVerticalScrollBar().getValue() + e.getUnitsToScroll() * 2);
        }
    });

    c.add(sp);

    // add glue to fill the remaining space
    add(Box.createGlue());
}

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

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

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

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

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

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

    pack();

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

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

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

From source file:de.codesourcery.eve.skills.ui.utils.GridLayoutBuilder.java

public void addTo(java.awt.Container container) {
    container.setLayout(new GridBagLayout());
    addTo(wrap(container));
}

From source file:edu.clemson.cs.nestbed.client.gui.MoteDetailFrame.java

public MoteDetailFrame(int configID, MoteTestbedAssignment mtba, Mote mote, MoteType moteType, Program program)
        throws RemoteException, NotBoundException, MalformedURLException, ClassNotFoundException {
    super("Mote " + mtba.getMoteAddress() + " - (" + mote.getMoteSerialID() + ")");

    this.mtba = mtba;
    this.mote = mote;
    this.moteType = moteType;
    this.program = program;

    lookupRemoteManagers();// w  w  w  .j  av  a2 s  . c  o m
    profilingSymbols = profSymManager.getProgramProfilingSymbols(configID, program.getID());
    progProfMsgSymbols = progProfMsgSymManager.getProgramProfilingMessageSymbols(configID, program.getID());

    programSymbols = new HashMap<Integer, ProgramSymbol>();
    List<ProgramSymbol> ps = programSymbolManager.getProgramSymbols(program.getID());
    for (ProgramSymbol i : ps) {
        programSymbols.put(i.getID(), i);
    }

    programMessageSymbols = new HashMap<Integer, ProgramMessageSymbol>();
    List<ProgramMessageSymbol> pms = progMsgSymManager.getProgramMessageSymbols(program.getID());

    for (ProgramMessageSymbol i : pms) {
        programMessageSymbols.put(i.getID(), i);
    }

    symbolTable.addMouseListener(new ProfilingTableMouseListener());
    symbolTable.setModel(new ProfilingTableModel());
    symbolTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    messageTable.addMouseListener(new MessageTableMouseListener());
    messageTable.setModel(new MessageTableModel());
    messageTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    setJMenuBar(buildMenuBar());

    Container c = this.getContentPane();
    c.setLayout(new BorderLayout());

    c.add(buildMotePanel(), BorderLayout.NORTH);
    c.add(buildBottomPane(), BorderLayout.CENTER);
}

From source file:IconDemoApplet.java

public void init() {
    //Parse the applet parameters
    pictures = parseParameters();/* w  ww .j ava  2 s . c  om*/

    //If the applet tag doesn't provide an "IMAGE0" parameter,
    //display an error message.
    if (pictures.size() == 0) {
        captionLabel = new JLabel("No images listed in applet tag.");
        captionLabel.setHorizontalAlignment(JLabel.CENTER);
        getContentPane().add(captionLabel);
        return;
    }

    //NOW CREATE THE GUI COMPONENTS

    //A label to identify XX of XX.
    numberLabel = new JLabel("Picture " + (current + 1) + " of " + pictures.size());
    numberLabel.setHorizontalAlignment(JLabel.LEFT);
    numberLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5));

    //A label for the caption.
    final Photo first = (Photo) pictures.firstElement();
    captionLabel = new JLabel(first.caption);
    captionLabel.setHorizontalAlignment(JLabel.CENTER);
    captionLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));

    //A label for displaying the photographs.
    photographLabel = new JLabel("Loading first image...");
    photographLabel.setHorizontalAlignment(JLabel.CENTER);
    photographLabel.setVerticalAlignment(JLabel.CENTER);
    photographLabel.setVerticalTextPosition(JLabel.CENTER);
    photographLabel.setHorizontalTextPosition(JLabel.CENTER);
    photographLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    photographLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0),
            photographLabel.getBorder()));

    //Set the preferred size for the picture,
    //with room for the borders.
    Insets i = photographLabel.getInsets();
    photographLabel.setPreferredSize(
            new Dimension(widthOfWidest + i.left + i.right, heightOfTallest + i.bottom + i.top));

    //Create the next and previous buttons.
    ImageIcon nextIcon = new ImageIcon(getURL(imagedir + "right.gif"));
    ImageIcon dimmedNextIcon = new ImageIcon(getURL(imagedir + "dimmedRight.gif"));
    ImageIcon previousIcon = new ImageIcon(getURL(imagedir + "left.gif"));
    ImageIcon dimmedPreviousIcon = new ImageIcon(getURL(imagedir + "dimmedLeft.gif"));

    previousButton = new JButton("Previous Picture", previousIcon);
    previousButton.setDisabledIcon(dimmedPreviousIcon);
    previousButton.setVerticalTextPosition(AbstractButton.CENTER);
    previousButton.setHorizontalTextPosition(AbstractButton.RIGHT);
    previousButton.setMnemonic(KeyEvent.VK_P);
    previousButton.setActionCommand("previous");
    previousButton.addActionListener(this);
    previousButton.setEnabled(false);

    nextButton = new JButton("Next Picture", nextIcon);
    nextButton.setDisabledIcon(dimmedNextIcon);
    nextButton.setVerticalTextPosition(AbstractButton.CENTER);
    nextButton.setHorizontalTextPosition(AbstractButton.LEFT);
    nextButton.setMnemonic(KeyEvent.VK_N);
    nextButton.setActionCommand("next");
    nextButton.addActionListener(this);

    //Lay out the GUI.
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    Container contentPane = getContentPane();
    contentPane.setLayout(layout);

    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.HORIZONTAL;
    layout.setConstraints(numberLabel, c);
    contentPane.add(numberLabel);

    layout.setConstraints(captionLabel, c);
    contentPane.add(captionLabel);

    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    layout.setConstraints(photographLabel, c);
    contentPane.add(photographLabel);

    c.gridwidth = GridBagConstraints.RELATIVE;
    c.fill = GridBagConstraints.HORIZONTAL;
    layout.setConstraints(previousButton, c);
    contentPane.add(previousButton);

    c.gridwidth = GridBagConstraints.REMAINDER;
    layout.setConstraints(nextButton, c);
    contentPane.add(nextButton);

    //Start loading the image for the first photograph now.
    //The loadImage method uses a SwingWorker
    //to load the image in a separate thread.
    loadImage(imagedir + first.filename, current);
}