Example usage for javax.swing JScrollPane setMinimumSize

List of usage examples for javax.swing JScrollPane setMinimumSize

Introduction

In this page you can find the example usage for javax.swing JScrollPane setMinimumSize.

Prototype

@BeanProperty(description = "The minimum size of the component.")
public void setMinimumSize(Dimension minimumSize) 

Source Link

Document

Sets the minimum size of this component to a constant value.

Usage

From source file:org.formic.wizard.step.gui.FeatureListStep.java

/**
 * {@inheritDoc}/*from ww  w  .ja  v  a  2  s  .co m*/
 * @see org.formic.wizard.step.GuiStep#init()
 */
public Component init() {
    featureInfo = new JEditorPane("text/html", StringUtils.EMPTY);
    featureInfo.setEditable(false);
    featureInfo.addHyperlinkListener(new HyperlinkListener());

    Feature[] features = provider.getFeatures();
    JTable table = new JTable(features.length, 1) {
        private static final long serialVersionUID = 1L;

        public Class getColumnClass(int column) {
            return getValueAt(0, column).getClass();
        }

        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    table.setBackground(new javax.swing.JList().getBackground());

    GuiForm form = createForm();

    for (int ii = 0; ii < features.length; ii++) {
        final Feature feature = (Feature) features[ii];
        final JCheckBox box = new JCheckBox();

        String name = getName() + '.' + feature.getKey();
        form.bind(name, box);

        box.putClientProperty("feature", feature);
        featureMap.put(feature.getKey(), box);

        if (feature.getInfo() == null) {
            feature.setInfo(Installer.getString(getName() + "." + feature.getKey() + ".html"));
        }
        feature.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                if (Feature.ENABLED_PROPERTY.equals(event.getPropertyName())) {
                    if (box.isSelected() != feature.isEnabled()) {
                        box.setSelected(feature.isEnabled());
                    }
                }
            }
        });

        box.setText(Installer.getString(name));
        box.setBackground(table.getBackground());
        if (!feature.isAvailable()) {
            box.setSelected(false);
            box.setEnabled(false);
        }
        table.setValueAt(box, ii, 0);
    }

    FeatureListMouseListener mouseListener = new FeatureListMouseListener();
    for (int ii = 0; ii < features.length; ii++) {
        Feature feature = (Feature) features[ii];
        if (feature.isEnabled() && feature.isAvailable()) {
            JCheckBox box = (JCheckBox) featureMap.get(feature.getKey());
            box.setSelected(true);
            mouseListener.processDependencies(feature);
            mouseListener.processExclusives(feature);
        }
    }

    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.setDefaultRenderer(JCheckBox.class, new ComponentTableCellRenderer());

    table.addKeyListener(new FeatureListKeyListener());
    table.addMouseListener(mouseListener);
    table.getSelectionModel().addListSelectionListener(new FeatureListSelectionListener(table));

    table.setRowSelectionInterval(0, 0);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    JPanel container = new JPanel(new BorderLayout());
    container.add(table, BorderLayout.CENTER);
    panel.add(new JScrollPane(container), BorderLayout.CENTER);
    JScrollPane infoScroll = new JScrollPane(featureInfo);
    infoScroll.setMinimumSize(new Dimension(0, 50));
    infoScroll.setMaximumSize(new Dimension(0, 50));
    infoScroll.setPreferredSize(new Dimension(0, 50));
    panel.add(infoScroll, BorderLayout.SOUTH);

    return panel;
}

From source file:org.jannocessor.ui.RenderPreviewDialog.java

private void initialize() {
    logger.debug("Initializing UI...");
    DefaultSyntaxKit.initKit();/*from  ww  w.  j  av  a 2 s . c o m*/

    JEditorPane.registerEditorKitForContentType("text/java_template", "org.jannocessor.syntax.JavaTemplateKit",
            getClass().getClassLoader());

    JEditorPane.registerEditorKitForContentType("text/java_output", "org.jannocessor.syntax.JavaOutputKit",
            getClass().getClassLoader());

    setTitle("JAnnocessor - Java Annotation Processor");
    setLayout(new BorderLayout(5, 5));

    listFiles();

    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    double width = screenSize.getWidth() * 0.9;
    double height = screenSize.getHeight() * 0.8;

    // Font font = new Font("Courier New", Font.PLAIN, 14);

    input = createInput();
    JScrollPane scroll1 = new JScrollPane(input, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    input.setContentType("text/java_template");

    input.setText("");

    scroll1.setMinimumSize(new Dimension(200, 200));
    scroll1.setPreferredSize(new Dimension((int) (width * 0.5), (int) height));
    add(scroll1, BorderLayout.CENTER);

    output = Box.createVerticalBox();

    scroll2 = new JScrollPane(output, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll2.setMinimumSize(new Dimension(200, 200));
    scroll2.setPreferredSize(new Dimension((int) (width * 0.5), (int) height));
    add(scroll2, BorderLayout.EAST);

    combo = createCombo();

    combo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            load((File) combo.getSelectedItem());
        }
    });

    add(combo, BorderLayout.NORTH);
    JLabel help = new JLabel(
            " Choose a template from the drop-down box to edit it. Navigation: Alt + Left & Alt + Right; Refresh = F5, Close = Esc",
            JLabel.CENTER);

    help.setForeground(Color.WHITE);
    help.setBackground(Color.BLACK);
    help.setOpaque(true);
    help.setFont(new Font("Courier New", Font.BOLD, 14));
    add(help, BorderLayout.SOUTH);

    keyListener = new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_F5) {
                e.consume();
                processElements();
                refresh();
            } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                e.consume();
                dispose();
            } else if (e.getKeyCode() == KeyEvent.VK_LEFT && e.isAltDown()) {
                e.consume();
                moveBackward();
            } else if (e.getKeyCode() == KeyEvent.VK_RIGHT && e.isAltDown()) {
                e.consume();
                moveForward();
            } else if (e.getKeyCode() == KeyEvent.VK_S && e.isControlDown()) {
                e.consume();
                save();
            } else if (e.getKeyCode() == KeyEvent.VK_I && e.isControlDown()) {
                e.consume();
                increase();
            } else if (e.getKeyCode() == KeyEvent.VK_D && e.isControlDown()) {
                e.consume();
                decrease();
            }
        }
    };

    input.addKeyListener(keyListener);
    combo.addKeyListener(keyListener);

    setActive(0);

    pack();
    setModal(true);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    input.requestFocus();
    logger.debug("Initialized UI.");
}

From source file:org.jannocessor.ui.RenderPreviewDialog.java

private JComponent createOutput(String title, String content) {
    editor = new JEditorPane();

    JScrollPane scroll = new JScrollPane(editor, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.setMinimumSize(new Dimension(100, 100));

    editor.setContentType("text/java_output");
    editor.setEditable(false);/* www .j a  va  2s  .co m*/
    editor.setText(content);
    editor.addKeyListener(keyListener);

    JLabel header = new JLabel(title);

    Box box = Box.createVerticalBox();
    box.add(header);
    box.add(scroll);

    return box;
}

From source file:org.monkeys.gui.matcher.MatcherPanel.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//  w w w.ja v  a  2 s. com
 */
@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    javax.swing.JSplitPane splitPane = new javax.swing.JSplitPane();
    textPanel = new javax.swing.JPanel();
    textHeader = new org.monkeys.gui.HeaderLabel();
    javax.swing.JScrollPane textScroll = new javax.swing.JScrollPane();
    textArea = new javax.swing.JTextArea();
    editPanel = new javax.swing.JPanel();
    clearButton = new javax.swing.JButton();
    javax.swing.JSeparator jSeparator2 = new javax.swing.JSeparator();
    editButton = new javax.swing.JToggleButton();
    matchingPanel = new javax.swing.JPanel();
    org.monkeys.gui.HeaderLabel matchingHeader = new org.monkeys.gui.HeaderLabel();
    matchingScroll = new javax.swing.JScrollPane();
    matchingList = new org.monkeys.gui.matcher.MatcherTable();
    org.monkeys.gui.HeaderLabel categoryLabel = new org.monkeys.gui.HeaderLabel();
    categoryDropdown = new org.monkeys.gui.CategoryDropdown();
    clipboardButton = new javax.swing.JToggleButton();
    selectButton = new javax.swing.JToggleButton();
    removeDuplicateButton = new javax.swing.JButton();
    removeRowButton = new javax.swing.JButton();
    javax.swing.JSeparator jSeparator3 = new javax.swing.JSeparator();
    javax.swing.JSeparator jSeparator4 = new javax.swing.JSeparator();
    javax.swing.JSeparator jSeparator5 = new javax.swing.JSeparator();
    modifyButton = new javax.swing.JButton();
    javax.swing.JSeparator jSeparator6 = new javax.swing.JSeparator();
    undoButton = new javax.swing.JButton();
    javax.swing.JSeparator jSeparator7 = new javax.swing.JSeparator();
    clipboardDropdown = new javax.swing.JComboBox();

    splitPane.setBorder(null);
    splitPane.setDividerSize(8);
    splitPane.setResizeWeight(0.6);

    textHeader.setText("Text");

    textScroll.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray));
    textScroll.setMinimumSize(new java.awt.Dimension(200, 50));
    textScroll.setPreferredSize(new java.awt.Dimension(300, 150));

    textArea.setTabSize(4);
    textArea.setAutoscrolls(false);
    textScroll.setViewportView(textArea);

    clearButton
            .setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/clear-20.png"))); // NOI18N
    clearButton.setText("Clear");
    clearButton.setToolTipText("Clear All Fields");
    clearButton.setBorderPainted(false);
    clearButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            clearButtonActionPerformed(evt);
        }
    });

    jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);

    editButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/lock-18.png"))); // NOI18N
    editButton.setSelected(true);
    editButton.setText("Edit");
    editButton.setToolTipText("Edit Text");
    editButton.setBorderPainted(false);
    editButton.setDisabledIcon(
            new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/lock-18.png"))); // NOI18N
    editButton.setIconTextGap(3);
    editButton.setSelectedIcon(
            new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/unlock-18.png"))); // NOI18N
    editButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            editButtonActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout editPanelLayout = new javax.swing.GroupLayout(editPanel);
    editPanel.setLayout(editPanelLayout);
    editPanelLayout.setHorizontalGroup(editPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editPanelLayout.createSequentialGroup().addComponent(editButton).addGap(0, 0, 0)
                    .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, 0).addComponent(clearButton).addGap(0, 89, Short.MAX_VALUE)));

    editPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { clearButton, editButton });

    editPanelLayout.setVerticalGroup(editPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(editPanelLayout.createSequentialGroup().addGap(0, 0, 0)
                    .addGroup(editPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSeparator2)
                            .addComponent(editButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(clearButton, javax.swing.GroupLayout.PREFERRED_SIZE, 24,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(0, 0, 0)));

    editPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL,
            new java.awt.Component[] { clearButton, editButton });

    javax.swing.GroupLayout textPanelLayout = new javax.swing.GroupLayout(textPanel);
    textPanel.setLayout(textPanelLayout);
    textPanelLayout.setHorizontalGroup(textPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(textPanelLayout.createSequentialGroup()
                    .addComponent(editPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(textPanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(textPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(textScroll, javax.swing.GroupLayout.Alignment.TRAILING,
                                    javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                            .addComponent(textHeader, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addContainerGap()));
    textPanelLayout.setVerticalGroup(textPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(textPanelLayout.createSequentialGroup().addContainerGap()
                    .addComponent(textHeader, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, 0)
                    .addComponent(editPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(textScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                    .addContainerGap()));

    splitPane.setLeftComponent(textPanel);

    matchingHeader.setText("Matches");

    matchingScroll.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray));
    matchingScroll.setMinimumSize(new java.awt.Dimension(200, 120));
    matchingScroll.setPreferredSize(new java.awt.Dimension(480, 300));
    matchingScroll.setViewportView(matchingList);

    categoryLabel.setText("Category");

    clipboardButton.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/clipboard-16.png"))); // NOI18N
    clipboardButton.setToolTipText("Copy Selected To Clipboard");
    clipboardButton.setBorderPainted(false);
    clipboardButton.setEnabled(false);
    clipboardButton.setIconTextGap(2);
    clipboardButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            clipboardButtonActionPerformed(evt);
        }
    });

    selectButton
            .setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/list-16.png"))); // NOI18N
    selectButton.setToolTipText("Select / Unselect All");
    selectButton.setBorderPainted(false);
    selectButton.setEnabled(false);
    selectButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            selectButtonActionPerformed(evt);
        }
    });

    removeDuplicateButton.setIcon(new javax.swing.ImageIcon(
            getClass().getResource("/org/monkeys/gui/icons/remove-duplicates-16.png"))); // NOI18N
    removeDuplicateButton.setToolTipText("Remove Duplicates");
    removeDuplicateButton.setBorderPainted(false);
    removeDuplicateButton.setEnabled(false);
    removeDuplicateButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            removeDuplicateButtonActionPerformed(evt);
        }
    });

    removeRowButton
            .setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/remove-16.png"))); // NOI18N
    removeRowButton.setToolTipText("Remove Selected");
    removeRowButton.setBorderPainted(false);
    removeRowButton.setEnabled(false);
    removeRowButton.setIconTextGap(2);
    removeRowButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            removeRowButtonActionPerformed(evt);
        }
    });

    jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);

    jSeparator4.setOrientation(javax.swing.SwingConstants.VERTICAL);

    jSeparator5.setOrientation(javax.swing.SwingConstants.VERTICAL);

    modifyButton
            .setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/edit-16.png"))); // NOI18N
    modifyButton.setToolTipText("Edit Selected");
    modifyButton.setBorderPainted(false);
    modifyButton.setEnabled(false);
    modifyButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            modifyButtonActionPerformed(evt);
        }
    });

    jSeparator6.setOrientation(javax.swing.SwingConstants.VERTICAL);

    undoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/undo-16.png"))); // NOI18N
    undoButton.setBorderPainted(false);
    undoButton.setEnabled(false);
    undoButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            undoButtonActionPerformed(evt);
        }
    });

    jSeparator7.setOrientation(javax.swing.SwingConstants.VERTICAL);

    clipboardDropdown.setEditable(true);
    clipboardDropdown.setModel(
            new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    clipboardDropdown.setEnabled(false);

    javax.swing.GroupLayout matchingPanelLayout = new javax.swing.GroupLayout(matchingPanel);
    matchingPanel.setLayout(matchingPanelLayout);
    matchingPanelLayout.setHorizontalGroup(matchingPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(matchingPanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(matchingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(matchingPanelLayout.createSequentialGroup().addComponent(selectButton)
                                    .addGap(0, 0, 0)
                                    .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(0, 0, 0).addComponent(removeDuplicateButton).addGap(0, 0, 0)
                                    .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(0, 0, 0).addComponent(removeRowButton).addGap(0, 0, 0)
                                    .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 12,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(0, 0, 0).addComponent(modifyButton).addGap(0, 0, 0)
                                    .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 12,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(0, 0, 0).addComponent(undoButton).addGap(0, 0, 0)
                                    .addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 12,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(0, 0, 0)
                                    .addComponent(clipboardDropdown, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(0, 0, 0).addComponent(clipboardButton)
                                    .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(matchingScroll, javax.swing.GroupLayout.Alignment.TRAILING,
                                    javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                            .addComponent(categoryLabel, javax.swing.GroupLayout.Alignment.TRAILING,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(categoryDropdown, javax.swing.GroupLayout.Alignment.TRAILING,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(matchingHeader, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addContainerGap()));

    matchingPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { clipboardButton, modifyButton, removeRowButton });

    matchingPanelLayout.setVerticalGroup(matchingPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(matchingPanelLayout.createSequentialGroup().addContainerGap()
                    .addComponent(categoryLabel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, 0)
                    .addComponent(categoryDropdown, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(matchingHeader, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(matchingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(matchingPanelLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, matchingPanelLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(removeDuplicateButton).addComponent(jSeparator4,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(matchingPanelLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                    false)
                                            .addComponent(selectButton,
                                                    javax.swing.GroupLayout.Alignment.LEADING,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                                            .addComponent(jSeparator3,
                                                    javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(removeRowButton,
                                                    javax.swing.GroupLayout.Alignment.LEADING,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    28, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(modifyButton)
                            .addGroup(matchingPanelLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(clipboardButton, javax.swing.GroupLayout.Alignment.TRAILING,
                                            javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(matchingPanelLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(undoButton).addComponent(jSeparator6,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(jSeparator7, javax.swing.GroupLayout.Alignment.TRAILING,
                                    javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(clipboardDropdown, javax.swing.GroupLayout.Alignment.TRAILING,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(matchingScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
                    .addContainerGap()));

    matchingPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL,
            new java.awt.Component[] { clipboardButton, clipboardDropdown });

    splitPane.setRightComponent(matchingPanel);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addComponent(splitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 664, Short.MAX_VALUE)
                    .addGap(0, 0, 0)));
    layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(splitPane));
}

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

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

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

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

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

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

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

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

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

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

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

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

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

From source file:org.omegat.gui.scripting.ScriptingWindow.java

private void initWindowLayout() {
    // set default size and position
    frame.setBounds(50, 80, 1150, 650);//from   w  w  w.  j a va 2  s.  c o  m
    StaticUIUtils.persistGeometry(frame, Preferences.SCRIPTWINDOW_GEOMETRY_PREFIX);

    frame.getContentPane().setLayout(new BorderLayout(0, 0));

    m_scriptList = new JList<>();
    JScrollPane scrollPaneList = new JScrollPane(m_scriptList);

    m_scriptList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                onListSelectionChanged();
            }
        }
    });

    m_scriptList.addMouseMotionListener(new MouseMotionAdapter() {

        @Override
        public void mouseMoved(MouseEvent e) {
            ListModel<ScriptItem> lm = m_scriptList.getModel();
            int index = m_scriptList.locationToIndex(e.getPoint());
            if (index > -1) {
                m_scriptList.setToolTipText(lm.getElementAt(index).getFile().getName());
            }
        }

    });

    m_txtResult = new JEditorPane();
    JScrollPane scrollPaneResults = new JScrollPane(m_txtResult);

    //m_txtScriptEditor = new StandardScriptEditor();
    m_txtScriptEditor = getScriptEditor();

    m_txtScriptEditor.initLayout(this);

    JSplitPane splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, m_txtScriptEditor.getPanel(),
            scrollPaneResults);
    splitPane1.setOneTouchExpandable(true);
    splitPane1.setDividerLocation(430);
    Dimension minimumSize1 = new Dimension(100, 50);
    //scrollPaneEditor.setMinimumSize(minimumSize1);
    scrollPaneResults.setMinimumSize(minimumSize1);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPaneList, splitPane1);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(250);

    Dimension minimumSize = new Dimension(100, 50);
    scrollPaneList.setMinimumSize(minimumSize);
    scrollPaneResults.setMinimumSize(minimumSize);

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

    JPanel panelSouth = new JPanel();
    FlowLayout fl_panelSouth = (FlowLayout) panelSouth.getLayout();
    fl_panelSouth.setAlignment(FlowLayout.LEFT);
    frame.getContentPane().add(panelSouth, BorderLayout.SOUTH);
    setupRunButtons(panelSouth);

    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    frame.setJMenuBar(createMenuBar());
}

From source file:org.opendatakit.briefcase.ui.ScrollingStatusListDialog.java

private ScrollingStatusListDialog(Frame frame, String title, IFormDefinition form, String statusHtml) {
    super(frame, title + form.getFormName(), true);
    this.form = form;
    AnnotationProcessor.process(this);
    // Create and initialize the buttons.
    JButton cancelButton = new JButton("Close");
    cancelButton.addActionListener(this);
    getRootPane().setDefaultButton(cancelButton);

    editorArea = new JEditorPane("text/plain", statusHtml);
    editorArea.setEditable(false);/*from   ww  w .jav  a2  s . c  om*/
    //Put the editor pane in a scroll pane.
    JScrollPane editorScrollPane = new JScrollPane(editorArea);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(400, 300));
    editorScrollPane.setMinimumSize(new Dimension(10, 10));

    // Create a container so that we can add a title around
    // the scroll pane. Can't add a title directly to the
    // scroll pane because its background would be white.
    // Lay out the label and scroll pane from top to bottom.
    JPanel listPane = new JPanel();
    listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
    listPane.add(Box.createRigidArea(new Dimension(0, 5)));
    listPane.add(editorScrollPane);
    listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // Lay out the buttons from left to right.
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(cancelButton);

    // Put everything together, using the content pane's BorderLayout.
    Container contentPane = getContentPane();
    contentPane.add(listPane, BorderLayout.CENTER);
    contentPane.add(buttonPane, BorderLayout.PAGE_END);

    // Initialize values.
    pack();
    setLocationRelativeTo(null);
}

From source file:org.optaplanner.mes.common.swingui.SolverAndPersistenceFrame.java

private JComponent createScoreFieldPanel() {
    scoreFieldPanel = new JPanel();
    scoreTextArea = new JTextArea();
    scoreFieldPanel.add(scoreTextArea);//from   w  ww . jav  a 2s  .  c o m
    scoreFieldPanel.setLayout(new BoxLayout(scoreFieldPanel, BoxLayout.Y_AXIS));

    JScrollPane scrollPane = new JScrollPane(scoreFieldPanel);
    scrollPane.getVerticalScrollBar().setUnitIncrement(25);
    scrollPane.setMinimumSize(new Dimension(100, 80));
    // Size fits into screen resolution 1024*768
    scrollPane.setPreferredSize(new Dimension(180, 200));

    scoreFieldTitlePanel = new JPanel(new BorderLayout());
    scoreFieldTitlePanel.add(scrollPane, BorderLayout.CENTER);
    scoreFieldTitlePanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createTitledBorder("Score")));

    return scoreFieldTitlePanel;
}

From source file:org.revager.gui.findings_list.FindingsListFrame.java

private void createCommAndRatePanel() {

    JLabel recLbl = new JLabel(translate("Final recommendation for the product:"));
    recLbl.setFont(UI.VERY_LARGE_FONT_BOLD);

    JLabel meetCommLbl = new JLabel(translate("Comments on the meeting:"));
    meetCommLbl.setFont(UI.VERY_LARGE_FONT_BOLD);

    JLabel protCommLbl = new JLabel(translate("Comments on the list of findings:"));
    protCommLbl.setFont(UI.VERY_LARGE_FONT_BOLD);

    meetCommTxtArea = new JTextArea();
    meetCommTxtArea.setRows(4);// w w  w .  java2  s .co m
    meetCommTxtArea.setFont(UI.VERY_LARGE_FONT);

    protCommTxtArea = new JTextArea();
    protCommTxtArea.setRows(4);
    protCommTxtArea.setFont(UI.VERY_LARGE_FONT);

    recBx = new JComboBox<>();
    recBx.setEditable(true);
    recBx.setFont(UI.VERY_LARGE_FONT);

    /*
     * adding focus and tab listeners to TextAreas
     */

    meetCommTxtArea.addKeyListener(updateListener);
    meetCommTxtArea.addKeyListener(tabKeyListener);

    protCommTxtArea.addKeyListener(updateListener);
    protCommTxtArea.addKeyListener(tabKeyListener);

    for (String rec : Data.getDefaultRecommendations()) {
        recBx.addItem(rec);
    }
    recBx.setSelectedIndex(0);
    recBx.addItemListener(itemListener);
    recBx.setSelectedItem(revMgmt.getRecommendation().trim());

    meetCommTxtArea.setText(Application.getInstance().getMeetingMgmt().getMeetingComment(currentMeet).trim());
    protCommTxtArea.setText(protMgmt.getProtocolComment(currentProt).trim());

    JScrollPane meetCommScrllPn = GUITools.setIntoScrllPn(meetCommTxtArea);
    meetCommScrllPn.setMinimumSize(meetCommScrllPn.getPreferredSize());
    GUITools.scrollToTop(meetCommScrllPn);

    protCommScrllPn = GUITools.setIntoScrllPn(protCommTxtArea);
    protCommScrllPn.setMinimumSize(protCommScrllPn.getPreferredSize());
    GUITools.scrollToTop(protCommScrllPn);

    GUITools.addComponent(tabPanelCommAndRec, gbl, recLbl, 0, 3, 2, 1, 0.0, 0.0, 20, 10, 0, 10,
            GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
    GUITools.addComponent(tabPanelCommAndRec, gbl, recBx, 0, 4, 2, 1, 1.0, 0.0, 5, 10, 0, 10,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
    GUITools.addComponent(tabPanelCommAndRec, gbl, meetCommLbl, 0, 5, 1, 1, 1.0, 0.0, 25, 10, 0, 10,
            GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
    GUITools.addComponent(tabPanelCommAndRec, gbl, meetCommScrllPn, 0, 6, 1, 1, 1.0, 1.0, 5, 10, 0, 10,
            GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
    GUITools.addComponent(tabPanelCommAndRec, gbl, protCommLbl, 1, 5, 1, 1, 1.0, 0.0, 25, 10, 0, 10,
            GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
    GUITools.addComponent(tabPanelCommAndRec, gbl, protCommScrllPn, 1, 6, 1, 1, 1.0, 1.0, 5, 10, 0, 10,
            GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);

    tabPanelCommAndRec.setBorder(new EmptyBorder(0, 10, 20, 10));
}

From source file:org.rimudb.editor.DescriptorEditor.java

/**
 * Build the panel//from  w  ww.j  a  va  2  s.c o m
 */
private JPanel createColumnTablePanel() {
    JPanel columnPanel = new JPanel();
    columnPanel.setLayout(new BoxLayout(columnPanel, BoxLayout.Y_AXIS));

    // Create the property table panel
    propertyModel = new PropertyTableModel();

    // Add a listener to set the changed state
    propertyModel.addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent e) {
            markChanged();

            if (e instanceof PropertyTableModelEvent) {
                PropertyTableModelEvent ptme = (PropertyTableModelEvent) e;

                // If the columnName column was changed then check it isn't
                // a PK
                if (ptme.getColumn() == 1) {

                    String beforeColumnName = (String) ptme.getBeforeValue();
                    String afterColumnName = (String) ptme.getAfterValue();

                    // Is the field entry in the list of primary keys?
                    for (int i = 0; i < pkListModel.getSize(); i++) {
                        String pkColumnName = (String) pkListModel.get(i);
                        // If it's found then remove it
                        if (beforeColumnName.equals(pkColumnName)) {
                            pkListModel.set(i, afterColumnName);
                            break;
                        }
                    }

                }

            }
        }
    });

    table = new ATable(getPropertyModel());
    table.setName("ColumnTable");
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            int selectedRowCount = table.getSelectedRowCount();
            removeColumnBtn.setEnabled(selectedRowCount > 0);
            moveUpBtn.setEnabled(selectedRowCount > 0);
            moveDownBtn.setEnabled(selectedRowCount > 0);
        }
    });
    table.setTransferHandler(new TransferHandler() {

        public int getSourceActions(JComponent c) {
            return COPY;
        }

        protected Transferable createTransferable(JComponent c) {
            ATable columnTable = (ATable) c;
            int row = columnTable.getSelectedRow();
            String columnName = getPropertyModel().getRow(row).getColumnName();
            return new StringSelection(columnName);
        }
    });
    table.setDragEnabled(true);

    JScrollPane sp = new JScrollPane(table);
    sp.setMaximumSize(new Dimension(Short.MAX_VALUE, 325));
    sp.setPreferredSize(new Dimension(Short.MAX_VALUE, 325));
    sp.setMinimumSize(new Dimension(Short.MAX_VALUE, 325));

    JComboBox typeCB = new JComboBox(DatabaseTypes.getAllTypes());
    typeCB.setEditable(false);

    javax.swing.table.TableColumn typeColumn = table.getColumnModel().getColumn(2);
    typeColumn.setCellEditor(new DefaultCellEditor(typeCB));

    // Create the popup menu and set it on the table
    propertyPopup = new TablePopupMenu(this, table);
    table.addMouseListener(propertyPopup);
    sp.addMouseListener(propertyPopup);
    sp.setAlignmentX(LEFT_ALIGNMENT);

    columnPanel.add(sp);

    columnPanel.add(Box.createVerticalStrut(10));

    JLabel pkLabel = new JLabel("Primary Key Columns", SwingConstants.LEFT);
    pkLabel.setAlignmentX(LEFT_ALIGNMENT);
    columnPanel.add(pkLabel);

    pkListModel = new DefaultListModel();
    pkListModel.addListDataListener(new ListDataListener() {
        public void intervalRemoved(ListDataEvent e) {
            markChanged();
        }

        public void intervalAdded(ListDataEvent e) {
            markChanged();
        }

        public void contentsChanged(ListDataEvent e) {
            markChanged();
        }
    });

    pkList = new JList(pkListModel);
    pkList.setName("pkList");
    pkList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    pkList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            int selectedRowCount = pkList.getSelectedIndex();
            removePkBtn.setEnabled(selectedRowCount > -1);
        }
    });
    pkList.setTransferHandler(new TransferHandler() {

        public boolean canImport(TransferHandler.TransferSupport info) {
            // we only import Strings
            if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                return false;
            }

            JList.DropLocation dl = (JList.DropLocation) info.getDropLocation();
            if (dl.getIndex() == -1) {
                return false;
            }
            return true;
        }

        public boolean importData(TransferHandler.TransferSupport info) {
            if (!info.isDrop()) {
                return false;
            }

            // Check for String flavor
            if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                displayDropLocation("List doesn't accept a drop of this type.");
                return false;
            }

            JList.DropLocation dl = (JList.DropLocation) info.getDropLocation();
            DefaultListModel listModel = (DefaultListModel) pkList.getModel();
            int index = dl.getIndex();

            // Get the string that is being dropped.
            Transferable t = info.getTransferable();
            String data;
            try {
                data = (String) t.getTransferData(DataFlavor.stringFlavor);
            } catch (Exception e) {
                return false;
            }

            // If this is a copy action then check we don't already have that String
            if (info.getDropAction() == COPY && listModel.indexOf(data) > -1) {
                displayDropLocation("The column " + data + " is already a primary key");
                return false;
            }

            // Perform the actual import. 
            if (dl.isInsert()) {
                int oldIndex = listModel.indexOf(data);
                if (oldIndex < index) {
                    listModel.add(index, data);
                    listModel.remove(oldIndex);
                } else {
                    listModel.remove(oldIndex);
                    listModel.add(index, data);
                }
            } else {
                // Don't handle replacements
            }
            return true;
        }

        public int getSourceActions(JComponent c) {
            return MOVE;
        }

        protected Transferable createTransferable(JComponent c) {
            JList list = (JList) c;
            Object[] values = list.getSelectedValues();

            StringBuffer buff = new StringBuffer();

            for (int i = 0; i < values.length; i++) {
                Object val = values[i];
                buff.append(val == null ? "" : val.toString());
                if (i != values.length - 1) {
                    buff.append("\n");
                }
            }
            return new StringSelection(buff.toString());
        }
    });
    pkList.setDropMode(DropMode.INSERT);
    pkList.setDragEnabled(true);

    JScrollPane pkScrollPanel = new JScrollPane(pkList);
    pkScrollPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 100));
    pkScrollPanel.setAlignmentX(LEFT_ALIGNMENT);

    columnPanel.add(pkScrollPanel);

    return columnPanel;
}