Example usage for javax.swing JList VERTICAL_WRAP

List of usage examples for javax.swing JList VERTICAL_WRAP

Introduction

In this page you can find the example usage for javax.swing JList VERTICAL_WRAP.

Prototype

int VERTICAL_WRAP

To view the source code for javax.swing JList VERTICAL_WRAP.

Click Source Link

Document

Indicates a "newspaper style" layout with cells flowing vertically then horizontally.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String[] items = { "A", "B", "C", "D" };
    JList list = new JList(items);
    JScrollPane scrollingList = new JScrollPane(list);

    // Change orientation to top-to-bottom, left-to-right layout
    list.setLayoutOrientation(JList.VERTICAL_WRAP);
}

From source file:ListTest.java

public ListFrame() {
    setTitle("ListTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    String[] words = { "quick", "brown", "hungry", "wild", "silent", "huge", "private", "abstract", "static",
            "final" };

    wordList = new JList(words);
    wordList.setVisibleRowCount(4);//w  ww. j av  a2 s .  c o  m
    JScrollPane scrollPane = new JScrollPane(wordList);

    listPanel = new JPanel();
    listPanel.add(scrollPane);
    wordList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {
            Object[] values = wordList.getSelectedValues();

            StringBuilder text = new StringBuilder(prefix);
            for (int i = 0; i < values.length; i++) {
                String word = (String) values[i];
                text.append(word);
                text.append(" ");
            }
            text.append(suffix);

            label.setText(text.toString());
        }
    });

    buttonPanel = new JPanel();
    group = new ButtonGroup();
    makeButton("Vertical", JList.VERTICAL);
    makeButton("Vertical Wrap", JList.VERTICAL_WRAP);
    makeButton("Horizontal Wrap", JList.HORIZONTAL_WRAP);

    add(listPanel, BorderLayout.NORTH);
    label = new JLabel(prefix + suffix);
    add(label, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
}

From source file:fungus.MycoNodeFrame.java

public MycoNodeFrame(MycoNode node) {
    this.node = node;
    this.setTitle("Node " + node.getID());

    graph = JungGraphObserver.getGraph();

    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    JPanel labelPane = new JPanel();
    labelPane.setLayout(new GridLayout(7, 2));
    JPanel neighborPane = new JPanel();
    neighborPane.setLayout(new BoxLayout(neighborPane, BoxLayout.PAGE_AXIS));
    JPanel logPane = new JPanel();
    logPane.setLayout(new BoxLayout(logPane, BoxLayout.PAGE_AXIS));
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    loggingTextArea = new JTextArea("", 25, 100);
    loggingTextArea.setLineWrap(true);/*ww  w .  java2s  .  c  o  m*/
    loggingTextArea.setEditable(false);
    handler = new MycoNodeLogHandler(node, loggingTextArea);
    handler.addChangeListener(this);
    JScrollPane logScrollPane = new JScrollPane(loggingTextArea);
    logScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    logPane.add(logScrollPane);

    contentPane.add(labelPane);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(neighborPane);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(logPane);
    contentPane.add(buttonPane);

    data = node.getHyphaData();
    link = node.getHyphaLink();
    mycocast = node.getMycoCast();

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    stateLabel = new JLabel();
    typeLabel = new JLabel();
    queueLengthLabel = new JLabel();
    sameLabel = new JLabel();
    differentLabel = new JLabel();
    maxCapacityLabel = new JLabel();
    idealImmobileLabel = new JLabel();
    idealHyphaeLabel = new JLabel();
    idealBiomassLabel = new JLabel();
    degreeLabel = new JLabel();
    hyphaDegreeLabel = new JLabel();
    biomassDegreeLabel = new JLabel();
    hyphaUtilizationLabel = new JLabel();
    biomassUtilizationLabel = new JLabel();
    capacityUtilizationLabel = new JLabel();

    labelPane.add(new JLabel("state"));
    labelPane.add(stateLabel);
    labelPane.add(new JLabel("type"));
    labelPane.add(typeLabel);
    labelPane.add(new JLabel("queue"));
    labelPane.add(queueLengthLabel);
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel("same"));
    labelPane.add(sameLabel);
    labelPane.add(new JLabel("different"));
    labelPane.add(differentLabel);
    //labelPane.add(new JLabel("immobile"));
    //labelPane.add(idealImmobileLabel);
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel("actual"));
    labelPane.add(new JLabel("ideal"));
    labelPane.add(new JLabel("utilization"));
    labelPane.add(new JLabel("hyphae"));
    labelPane.add(hyphaDegreeLabel);
    labelPane.add(idealHyphaeLabel);
    labelPane.add(hyphaUtilizationLabel);
    labelPane.add(new JLabel("biomass"));
    labelPane.add(biomassDegreeLabel);
    labelPane.add(idealBiomassLabel);
    labelPane.add(biomassUtilizationLabel);
    labelPane.add(new JLabel("capacity"));
    labelPane.add(degreeLabel);
    labelPane.add(maxCapacityLabel);
    labelPane.add(capacityUtilizationLabel);

    neighborListControl = new JList();
    neighborListControl.setLayoutOrientation(JList.VERTICAL_WRAP);
    neighborListControl.setVisibleRowCount(-1);

    neighborListScroller = new JScrollPane(neighborListControl);
    neighborListScroller.setPreferredSize(new Dimension(250, 150));
    neighborListScroller.setMinimumSize(new Dimension(250, 150));

    neighborPane.add(neighborListScroller);

    JButton updateButton = new JButton("Refresh");
    ActionListener updater = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            refreshData();
        }
    };
    updateButton.addActionListener(updater);

    JButton closeButton = new JButton("Close");
    ActionListener closer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeFrame();
        }
    };
    closeButton.addActionListener(closer);

    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(updateButton);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(closeButton);

    refreshData();

    JungGraphObserver.addChangeListener(this);

    this.pack();
    this.setVisible(true);
}

From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java

/**
 * @param viewType//from ww w  .  j a v  a  2s .co m
 */
public void setViewType(int viewType) {
    int oldValue = this.viewType;

    if (viewType == oldValue) {
        return;
    }

    this.viewType = viewType;

    if (viewType == VIEWTYPE_LIST) {
        if (viewPanels[viewType] == null) {
            JPanel p = fileChooserUIAccessor.createList();

            if (p == null) {
                p = createList();
            }

            setViewPanel(viewType, p);
        }

        list.setLayoutOrientation(JList.VERTICAL_WRAP);
    } else if (viewType == VIEWTYPE_DETAILS) {
        if (viewPanels[viewType] == null) {
            JPanel p = fileChooserUIAccessor.createDetailsView();

            if (p == null) {
                p = createDetailsView();
            }

            setViewPanel(viewType, p);
        }
    }

    JPanel oldViewPanel = currentViewPanel;
    currentViewPanel = viewPanels[viewType];

    if (currentViewPanel != oldViewPanel) {
        if (oldViewPanel != null) {
            remove(oldViewPanel);
        }

        add(currentViewPanel, BorderLayout.CENTER);
        revalidate();
        repaint();
    }

    updateViewMenu();
    firePropertyChange("viewType", oldValue, viewType);
}

From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java

public JPanel createList() {
    JPanel p = new JPanel(new BorderLayout());
    final VFSJFileChooser fileChooser = getFileChooser();
    final JList aList = new JList() {
        @Override/*from w  ww  .  j  ava2s .  co m*/
        public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
            ListModel model = getModel();
            int max = model.getSize();

            if ((prefix == null) || (startIndex < 0) || (startIndex >= max)) {
                throw new IllegalArgumentException();
            }

            // start search from the next element before/after the selected element
            boolean backwards = (bias == Position.Bias.Backward);

            for (int i = startIndex; backwards ? (i >= 0) : (i < max); i += (backwards ? (-1) : 1)) {
                String filename = fileChooser.getName((FileObject) model.getElementAt(i));

                if (filename.regionMatches(true, 0, prefix, 0, prefix.length())) {
                    return i;
                }
            }

            return -1;
        }
    };

    aList.setCellRenderer(new FileRenderer());
    aList.setLayoutOrientation(JList.VERTICAL_WRAP);

    // 4835633 : tell BasicListUI that this is a file list
    aList.putClientProperty("List.isFileList", Boolean.TRUE);

    if (listViewWindowsStyle) {
        aList.addFocusListener(repaintListener);
    }

    updateListRowCount(aList);

    getModel().addListDataListener(new ListDataListener() {
        public void intervalAdded(ListDataEvent e) {
            updateListRowCount(aList);
        }

        public void intervalRemoved(ListDataEvent e) {
            updateListRowCount(aList);
        }

        public void contentsChanged(ListDataEvent e) {
            if (isShowing()) {
                clearSelection();
            }

            updateListRowCount(aList);
        }
    });

    getModel().addPropertyChangeListener(this);

    if (fileChooser.isMultiSelectionEnabled()) {
        aList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    } else {
        aList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }

    aList.setModel(getModel());

    aList.addListSelectionListener(createListSelectionListener());
    aList.addMouseListener(getMouseHandler());

    JScrollPane scrollpane = new JScrollPane(aList);

    if (listViewBackground != null) {
        aList.setBackground(listViewBackground);
    }

    if (listViewBorder != null) {
        scrollpane.setBorder(listViewBorder);
    }

    p.add(scrollpane, BorderLayout.CENTER);

    return p;
}

From source file:org.pdfsam.guiclient.commons.panels.JVisualPdfPageSelectionPanel.java

/**
 * panel initialization/*w  w w .  j ava  2  s  .c o  m*/
 */
private void init() {
    setLayout(new GridBagLayout());

    thumbnailList.setDrawDeletedItems(drawDeletedItems);
    if (dndSupport == DND_SUPPORT_FILES) {
        thumbnailList.setTransferHandler(new VisualListExportTransferHandler(pdfLoader));
    } else if (dndSupport == DND_SUPPORT_JAVAOBJECTS) {
        thumbnailList.setTransferHandler(new VisualListTransferHandler());
    } else if (dndSupport == DND_SUPPORT_FILES_AND_JAVAOBJECTS) {
        thumbnailList.setTransferHandler(new VisualListTransferHandler(pdfLoader));
    } else {
        thumbnailList.setTransferHandler(new VisualListExportTransferHandler(null));
    }
    thumbnailList.setDragEnabled(true);
    thumbnailList.setDropMode(DropMode.INSERT);
    pagesWorker = new PagesWorker(thumbnailList);
    thumbnailList.addKeyListener(new VisualPdfSelectionKeyAdapter(pagesWorker));
    thumbnailList.addMouseListener(new PageOpenerMouseAdapter(thumbnailList));

    if (showButtonPanel) {
        initButtonPanel(pagesWorker);
        initKeyListener();
    }

    //JList orientation
    if (HORIZONTAL_ORIENTATION == orientation) {
        thumbnailList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    } else {
        if (wrap) {
            thumbnailList.setLayoutOrientation(JList.VERTICAL_WRAP);
        }
    }

    topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS));
    topPanel.setPreferredSize(new Dimension(400, 30));

    pdfSelectionActionListener = new VisualPdfSelectionActionListener(this, pdfLoader);
    if (topPanelStyle >= STYLE_TOP_PANEL_FULL) {
        //load button
        loadFileButton.setMargin(new Insets(1, 1, 1, 1));
        loadFileButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Open"));
        loadFileButton.setPreferredSize(new Dimension(100, 30));
        loadFileButton
                .setToolTipText(GettextResource.gettext(config.getI18nResourceBundle(), "Load a pdf document"));
        loadFileButton.setIcon(new ImageIcon(this.getClass().getResource("/images/add.png")));
        loadFileButton.addKeyListener(new EnterDoClickListener(loadFileButton));
        loadFileButton.setAlignmentX(Component.CENTER_ALIGNMENT);
        loadFileButton.setAlignmentY(Component.CENTER_ALIGNMENT);
        loadFileButton.setActionCommand(VisualPdfSelectionActionListener.ADD);
        loadFileButton.addActionListener(pdfSelectionActionListener);
    }
    documentProperties.setIcon(new ImageIcon(this.getClass().getResource("/images/info.png")));
    documentProperties.setVisible(false);

    if (topPanelStyle >= STYLE_TOP_PANEL_MEDIUM) {
        clearButton.setMargin(new Insets(1, 1, 1, 1));
        clearButton.setMinimumSize(new Dimension(30, 30));
        clearButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Clear"));
        clearButton.setIcon(new ImageIcon(this.getClass().getResource("/images/clear.png")));
        clearButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                resetPanel();
            }
        });
    }

    zoomInButton.setMargin(new Insets(1, 1, 1, 1));
    zoomInButton.setMinimumSize(new Dimension(30, 30));
    zoomInButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Zoom in"));
    zoomInButton.setIcon(new ImageIcon(this.getClass().getResource("/images/zoomin.png")));
    zoomInButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                thumbnailList.incZoomLevel();
                zoomOutButton.setEnabled(true);
                if (thumbnailList.getCurrentZoomLevel() >= JVisualSelectionList.MAX_ZOOM_LEVEL) {
                    zoomInButton.setEnabled(false);
                }
                ((VisualListModel) thumbnailList.getModel()).elementsChanged();
            } catch (Exception ex) {
                log.error(GettextResource.gettext(config.getI18nResourceBundle(), "Error setting zoom level."),
                        ex);
            }
        }
    });

    zoomOutButton.setMargin(new Insets(1, 1, 1, 1));
    zoomOutButton.setMinimumSize(new Dimension(30, 30));
    zoomOutButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Zoom out"));
    zoomOutButton.setIcon(new ImageIcon(this.getClass().getResource("/images/zoomout.png")));
    zoomOutButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                thumbnailList.deincZoomLevel();
                zoomInButton.setEnabled(true);
                if (thumbnailList.getCurrentZoomLevel() <= JVisualSelectionList.MIN_ZOOM_LEVEL) {
                    zoomOutButton.setEnabled(false);
                }
                ((VisualListModel) thumbnailList.getModel()).elementsChanged();
            } catch (Exception ex) {
                log.error(GettextResource.gettext(config.getI18nResourceBundle(), "Error setting zoom level."),
                        ex);
            }
        }
    });

    thumbnailList.setModel(new VisualListModel());
    thumbnailList.setCellRenderer(new VisualListRenderer());
    thumbnailList.setVisibleRowCount(-1);
    thumbnailList.setSelectionMode(selectionType);
    JScrollPane listScroller = new JScrollPane(thumbnailList);

    //preview item   
    menuItemPreview.setIcon(new ImageIcon(this.getClass().getResource("/images/preview-viewer.png")));
    menuItemPreview.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Preview"));
    menuItemPreview.addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent e) {
            int[] selection = thumbnailList.getSelectedIndices();
            if (selection != null && selection.length == 1) {
                VisualPageListItem item = (VisualPageListItem) thumbnailList.getModel()
                        .getElementAt(selection[0]);
                PagePreviewOpener.getInstance().openPreview(item.getParentFileCanonicalPath(),
                        item.getDocumentPassword(), item.getPageNumber());
            }
        }
    });

    if (showContextMenu) {
        //popup
        final JMenuItem menuItemMoveUp = new JMenuItem();
        menuItemMoveUp.setIcon(new ImageIcon(this.getClass().getResource("/images/up.png")));
        menuItemMoveUp.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Move Up"));
        menuItemMoveUp.addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.MOVE_UP, pagesWorker));
        popupMenu.add(menuItemMoveUp);

        final JMenuItem menuItemMoveDown = new JMenuItem();
        menuItemMoveDown.setIcon(new ImageIcon(this.getClass().getResource("/images/down.png")));
        menuItemMoveDown.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Move Down"));
        menuItemMoveDown
                .addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.MOVE_DOWN, pagesWorker));
        popupMenu.add(menuItemMoveDown);

        final JMenuItem menuItemRemove = new JMenuItem();
        menuItemRemove.setIcon(new ImageIcon(this.getClass().getResource("/images/remove.png")));
        menuItemRemove.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Delete"));
        menuItemRemove.addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.REMOVE, pagesWorker));
        popupMenu.add(menuItemRemove);

        //if elements are physically deleted i don't need this item
        if (drawDeletedItems) {
            final JMenuItem menuItemUndelete = new JMenuItem();
            menuItemUndelete.setIcon(new ImageIcon(this.getClass().getResource("/images/remove.png")));
            menuItemUndelete.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Undelete"));
            menuItemUndelete
                    .addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.UNDELETE, pagesWorker));
            popupMenu.add(menuItemUndelete);
        }

        //rotate item   
        final JMenuItem menuItemRotate = new JMenuItem();
        menuItemRotate.setIcon(new ImageIcon(this.getClass().getResource("/images/clockwise.png")));
        menuItemRotate.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Rotate clockwise"));
        menuItemRotate
                .addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.ROTATE_CLOCK, pagesWorker));
        popupMenu.add(menuItemRotate);

        //rotate anticlock item   
        final JMenuItem menuItemAntiRotate = new JMenuItem();
        menuItemAntiRotate.setIcon(new ImageIcon(this.getClass().getResource("/images/anticlockwise.png")));
        menuItemAntiRotate
                .setText(GettextResource.gettext(config.getI18nResourceBundle(), "Rotate anticlockwise"));
        menuItemAntiRotate.addMouseListener(
                new VisualPdfSelectionMouseAdapter(PagesWorker.ROTATE_ANTICLOCK, pagesWorker));
        popupMenu.add(menuItemAntiRotate);

        //reverse item   
        final JMenuItem menuItemReverse = new JMenuItem();
        menuItemReverse.setIcon(new ImageIcon(this.getClass().getResource("/images/reverse.png")));
        menuItemReverse.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Reverse"));
        menuItemReverse.addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.REVERSE, pagesWorker));
        popupMenu.add(menuItemReverse);

        enableSetOutputPathMenuItem();

        addPopupShower();
    }

    popupMenu.add(menuItemPreview);

    if (topPanelStyle >= STYLE_TOP_PANEL_FULL) {
        topPanel.add(Box.createRigidArea(new Dimension(5, 0)));
        topPanel.add(loadFileButton);
    }
    if (topPanelStyle >= STYLE_TOP_PANEL_MEDIUM) {
        topPanel.add(Box.createRigidArea(new Dimension(5, 0)));
        topPanel.add(clearButton);
    }
    topPanel.add(Box.createRigidArea(new Dimension(5, 0)));
    topPanel.add(documentProperties);
    topPanel.add(Box.createHorizontalGlue());
    topPanel.add(zoomInButton);
    topPanel.add(Box.createRigidArea(new Dimension(5, 0)));
    topPanel.add(zoomOutButton);

    GridBagConstraints topConstraints = new GridBagConstraints();
    topConstraints.fill = GridBagConstraints.BOTH;
    topConstraints.gridx = 0;
    topConstraints.gridy = 0;
    topConstraints.gridwidth = 3;
    topConstraints.gridheight = 1;
    topConstraints.insets = new Insets(5, 5, 5, 5);
    topConstraints.weightx = 1.0;
    topConstraints.weighty = 0.0;
    if (topPanelStyle > STYLE_TOP_PANEL_HIDE) {
        add(topPanel, topConstraints);
    }

    GridBagConstraints thumbConstraints = new GridBagConstraints();
    thumbConstraints.fill = GridBagConstraints.BOTH;
    thumbConstraints.gridx = 0;
    thumbConstraints.gridy = 1;
    thumbConstraints.gridwidth = (showButtonPanel ? 2 : 3);
    thumbConstraints.gridheight = 2;
    thumbConstraints.insets = new Insets(5, 5, 5, 5);
    thumbConstraints.weightx = 1.0;
    thumbConstraints.weighty = 1.0;
    add(listScroller, thumbConstraints);

    if (showButtonPanel) {
        GridBagConstraints buttonsConstraints = new GridBagConstraints();
        buttonsConstraints.fill = GridBagConstraints.BOTH;
        buttonsConstraints.gridx = 2;
        buttonsConstraints.gridy = 1;
        buttonsConstraints.gridwidth = 1;
        buttonsConstraints.gridheight = 2;
        buttonsConstraints.insets = new Insets(5, 5, 5, 5);
        buttonsConstraints.weightx = 0.0;
        buttonsConstraints.weighty = 1.0;
        add(buttonPanel, buttonsConstraints);
    }
}

From source file:org.shaman.rpg.editor.dialog.DialogVisualElement.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.//from   w  ww.  ja v  a2  s. c o  m
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    scrollPane = new javax.swing.JScrollPane();
    jLabel1 = new javax.swing.JLabel();
    nameTextField = new javax.swing.JTextField();
    jLabel2 = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    personsList = new javax.swing.JList();
    addButton = new javax.swing.JButton();
    removeButton = new javax.swing.JButton();

    org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle
            .getMessage(DialogVisualElement.class, "DialogVisualElement.jLabel1.text")); // NOI18N

    nameTextField.setText(org.openide.util.NbBundle.getMessage(DialogVisualElement.class,
            "DialogVisualElement.nameTextField.text")); // NOI18N

    org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle
            .getMessage(DialogVisualElement.class, "DialogVisualElement.jLabel2.text")); // NOI18N

    personsList.setModel(new DefaultListModel());
    personsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    personsList.setToolTipText(org.openide.util.NbBundle.getMessage(DialogVisualElement.class,
            "DialogVisualElement.personsList.toolTipText")); // NOI18N
    personsList.setLayoutOrientation(javax.swing.JList.VERTICAL_WRAP);
    personsList.setVisibleRowCount(-1);
    jScrollPane1.setViewportView(personsList);

    org.openide.awt.Mnemonics.setLocalizedText(addButton, org.openide.util.NbBundle
            .getMessage(DialogVisualElement.class, "DialogVisualElement.addButton.text")); // NOI18N
    addButton.setToolTipText(org.openide.util.NbBundle.getMessage(DialogVisualElement.class,
            "DialogVisualElement.addButton.toolTipText")); // NOI18N
    addButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            addButtonEvent(evt);
        }
    });

    org.openide.awt.Mnemonics.setLocalizedText(removeButton, org.openide.util.NbBundle
            .getMessage(DialogVisualElement.class, "DialogVisualElement.removeButton.text")); // NOI18N
    removeButton.setToolTipText(org.openide.util.NbBundle.getMessage(DialogVisualElement.class,
            "DialogVisualElement.removeButton.toolTipText")); // NOI18N
    removeButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            removeButtonEvent(evt);
        }
    });

    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(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel2)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(removeButton, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(addButton, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
            .addComponent(scrollPane));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel1)
                                    .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 61,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup().addComponent(addButton)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(removeButton)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)));
}

From source file:pcgen.gui.sources.SourceSelectionDialog.java

/**
 * This method is called from within the constructor to
 * initialize the form.//  www  .j  a v a 2 s .c o m
 */
private void initComponents() {
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    getContentPane().setLayout(new java.awt.GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(4, 4, 4, 4);

    JLabel jLabel1 = new JLabel(LanguageBundle.getString("in_qsrc_intro"));
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0.0, 0.0);
    getContentPane().add(jLabel1, gbc);

    sourceList = new javax.swing.JList();
    sourceModel = new DefaultListModel();
    List<String> strings = getSourceNames();
    for (String string : strings) {
        sourceModel.addElement(string);
    }
    sourceList.setModel(sourceModel);
    sourceList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    sourceList.setLayoutOrientation(JList.VERTICAL_WRAP);
    sourceList.setVisibleRowCount(2);
    sourceList.setCellRenderer(new SourceListCellRenderer());
    JScrollPane listScrollPane = new JScrollPane(sourceList);
    listScrollPane.setPreferredSize(new Dimension(480, 260));
    if (lastLoadedCollection != null && lastLoadedCollection.length() > 0) {
        sourceList.setSelectedValue(lastLoadedCollection, true);
    }

    Utility.buildRelativeConstraints(gbc, 2, 5, 100, 100, GridBagConstraints.BOTH, GridBagConstraints.WEST);
    getContentPane().add(listScrollPane, gbc);

    JButton addButton = new JButton(LanguageBundle.getString("in_add"));
    addButton.setActionCommand(ACTION_ADD);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    getContentPane().add(addButton, gbc);

    modifyButton = new JButton(LanguageBundle.getString("in_modify"));
    modifyButton.setActionCommand(ACTION_MODIFY);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    getContentPane().add(modifyButton, gbc);

    JButton hideButton = new JButton(LanguageBundle.getString("in_hide"));
    hideButton.setActionCommand(ACTION_HIDE);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.NORTH);
    getContentPane().add(hideButton, gbc);

    JButton unhideButton = new JButton(LanguageBundle.getString("in_unhide"));
    unhideButton.setActionCommand(ACTION_UNHIDE);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.NORTH);
    getContentPane().add(unhideButton, gbc);

    deleteButton = new JButton(LanguageBundle.getString("in_delete"));
    deleteButton.setActionCommand(ACTION_DELETE);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.NORTH);
    getContentPane().add(deleteButton, gbc);

    JButton advancedButton = new JButton(LanguageBundle.getString("in_qsrc_advanced"));
    advancedButton.setActionCommand(ACTION_ADVANCED);
    getRootPane().setDefaultButton(advancedButton);
    Utility.buildRelativeConstraints(gbc, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST);
    getContentPane().add(advancedButton, gbc);

    JButton loadButton = new JButton(LanguageBundle.getString("in_load"));
    loadButton.setActionCommand(ACTION_LOAD);
    getRootPane().setDefaultButton(loadButton);
    Utility.buildRelativeConstraints(gbc, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.EAST);
    getContentPane().add(loadButton, gbc);

    JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel"));
    cancelButton.setActionCommand(ACTION_CANCEL);
    Utility.buildRelativeConstraints(gbc, 1, 1, 0, 0);
    getContentPane().add(cancelButton, gbc);

    //Listen for actions on the buttons
    addButton.addActionListener(this);
    modifyButton.addActionListener(this);
    deleteButton.addActionListener(this);
    hideButton.addActionListener(this);
    unhideButton.addActionListener(this);
    advancedButton.addActionListener(this);
    loadButton.addActionListener(this);
    cancelButton.addActionListener(this);
    sourceList.addListSelectionListener(this);
    valueChanged(null);

    //Listen for actions on the list
    sourceList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            sourceListMouseClicked(evt);
        }
    });

    pack();
}