Example usage for javax.swing Box createHorizontalGlue

List of usage examples for javax.swing Box createHorizontalGlue

Introduction

In this page you can find the example usage for javax.swing Box createHorizontalGlue.

Prototype

public static Component createHorizontalGlue() 

Source Link

Document

Creates a horizontal glue component.

Usage

From source file:com.diversityarrays.dal.server.SqlDialog.java

SqlDialog(JFrame owner, SqlDalDatabase db) {
    super(owner, "SQL", ModalityType.MODELESS);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    this.database = db;

    runner = new DefaultBackgroundRunner("SQL Command", this);
    setGlassPane(runner.getBlockingPane());

    sqlCommands.setFont(GuiUtil.createMonospacedFont(12));

    includeHeadingsInCopy.addItemListener(new ItemListener() {
        @Override// ww w . j  av  a2 s  . c om
        public void itemStateChanged(ItemEvent e) {
            boolean b = includeHeadingsInCopy.isSelected();
            for (int n = tabbedPane.getTabCount(); --n >= 0;) {
                Component c = tabbedPane.getComponentAt(n);
                if (c instanceof SqlResultsPanel) {
                    ((SqlResultsPanel) c).setIncludeHeadings(b);
                }
            }
        }
    });

    tabbedPane.addContainerListener(new ContainerListener() {
        @Override
        public void componentRemoved(ContainerEvent e) {
            updateClosePanelAction();
        }

        @Override
        public void componentAdded(ContainerEvent e) {
            updateClosePanelAction();
        }
    });
    updateClosePanelAction();

    Box buttons = Box.createHorizontalBox();
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(new JButton(runAction));
    buttons.add(Box.createHorizontalStrut(20));
    buttons.add(new JButton(closePanelAction));

    buttons.add(Box.createHorizontalGlue());
    buttons.add(includeHeadingsInCopy);
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(new JButton(helpAction));
    buttons.add(Box.createHorizontalStrut(10));

    JPanel top = new JPanel(new BorderLayout());
    top.add(BorderLayout.CENTER, new JScrollPane(sqlCommands));
    top.add(BorderLayout.SOUTH, buttons);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, top, tabbedPane);
    splitPane.setResizeWeight(0.25);

    setContentPane(splitPane);

    pack();

    setSize(800, 600);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            splitPane.setDividerLocation(0.25);
            removeWindowListener(this);
        }

    });
}

From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java

private void addCloseButton() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    panel.add(Box.createHorizontalGlue());
    JButton button = new JButton(i18n.getString(I18n.BUTTON_CLOSE_ID));
    panel.add(button);/*w ww. jav  a  2s .com*/
    panel.add(Box.createHorizontalGlue());
    button.addActionListener(closeAction());

    panel.setBorder(BorderFactory.createEmptyBorder(border, 0, 0, 0));
    add(panel, BorderLayout.SOUTH);
}

From source file:plugins.ImageRectificationPanel.java

public final void createGui() {
    this.removeAll();

    if (imageGCPsXCoords == null) {
        return;//from   www  .  j  av a 2s.  co m
    }
    int i;
    int newN = 0;
    for (i = 0; i < imageGCPsXCoords.length; i++) {
        if (useGCP[i]) {
            newN++;
        }
    }
    double[] X1 = new double[newN];
    double[] Y1 = new double[newN];
    double[] X2 = new double[newN];
    double[] Y2 = new double[newN];

    int j = 0;
    for (i = 0; i < imageGCPsXCoords.length; i++) {
        if (useGCP[i]) {
            X1[j] = imageGCPsXCoords[i];
            Y1[j] = imageGCPsYCoords[i];
            X2[j] = mapGCPsXCoords[i];
            Y2[j] = mapGCPsYCoords[i];
            j++;
        }
    }

    calculateEquations(X1, Y1, X2, Y2);

    // gui stuff
    this.setLayout(new BorderLayout());

    DecimalFormat df = new DecimalFormat("###,###,##0.000");

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
    JButton btnOK = createButton(bundle.getString("OK"), bundle.getString("OK"), "ok");
    JButton btnExit = createButton(bundle.getString("Close"), bundle.getString("Close"), "close");
    //JButton btnRefresh = createButton("Cancel", "Cancel");

    buttonPane.add(Box.createHorizontalStrut(10));
    buttonPane.add(btnOK);
    buttonPane.add(Box.createHorizontalStrut(5));
    //buttonPane.add(btnRefresh);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(btnExit);
    buttonPane.add(Box.createHorizontalGlue());

    progressBar = new JProgressBar(0, 100);
    buttonPane.add(progressBar);
    buttonPane.add(Box.createHorizontalStrut(5));
    cancel = new JLabel(bundle.getString("Cancel"));
    cancel.setForeground(Color.BLUE.darker());
    cancel.addMouseListener(this);
    buttonPane.add(cancel);
    buttonPane.add(Box.createHorizontalStrut(10));

    this.add(buttonPane, BorderLayout.SOUTH);

    Box mainBox = Box.createVerticalBox();
    mainBox.add(Box.createVerticalStrut(10));

    Box box1 = Box.createHorizontalBox();
    box1.add(Box.createHorizontalStrut(10));
    box1.add(new JLabel(bundle.getString("PolynomialOrder") + ": "));
    SpinnerModel model = new SpinnerNumberModel(polyOrder, //initial value
            1, //min
            5, //max
            1); //step

    polyOrderSpinner = new JSpinner(model);
    polyOrderSpinner.setPreferredSize(new Dimension(15, polyOrderSpinner.getPreferredSize().height));
    polyOrderSpinner.addChangeListener(this);

    JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) polyOrderSpinner.getEditor();
    editor.getTextField().setEnabled(true);
    editor.getTextField().setEditable(false);

    box1.add(polyOrderSpinner);
    box1.add(Box.createHorizontalGlue());
    JLabel label = new JLabel("RMSE: " + df.format(overallRMSE));
    box1.add(label);
    box1.add(Box.createHorizontalStrut(10));
    mainBox.add(box1);

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

    // Create columns names
    int numPoints = imageGCPsXCoords.length;
    Object dataValues[][] = new Object[numPoints][7];
    j = 0;
    for (i = 0; i < numPoints; i++) {
        dataValues[i][0] = i + 1;
        dataValues[i][1] = df.format(imageGCPsXCoords[i]);
        dataValues[i][2] = df.format(imageGCPsYCoords[i]);
        dataValues[i][3] = df.format(mapGCPsXCoords[i]);
        dataValues[i][4] = df.format(mapGCPsYCoords[i]);
        if (useGCP[i]) {
            dataValues[i][5] = df.format(residualsXY[j]);
            j++;
        } else {
            dataValues[i][5] = null;
        }
        dataValues[i][6] = useGCP[i];
    }

    String columnNames[] = { "GCP", bundle.getString("Image") + " X", bundle.getString("Image") + " Y",
            bundle.getString("Map") + " X", bundle.getString("Map") + " Y", messages.getString("Error"),
            "Use" };

    DefaultTableModel tableModel = new DefaultTableModel(dataValues, columnNames);

    dataTable = new JTable(tableModel) {
        private static final long serialVersionUID = 1L;

        @Override
        public Class getColumnClass(int column) {
            switch (column) {
            case 0:
                return Integer.class;
            case 1:
                return String.class; //Double.class;
            case 2:
                return String.class; //Double.class;
            case 3:
                return String.class; //Double.class;
            case 4:
                return String.class; //Double.class;
            case 5:
                return String.class; //Double.class;
            case 6:
                return Boolean.class;
            default:
                return String.class; //Double.class;
            }
        }

        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int index_row, int index_col) {
            Component comp = super.prepareRenderer(renderer, index_row, index_col);
            //even index, selected or not selected

            if (index_row % 2 == 0) {
                comp.setBackground(Color.WHITE);
                comp.setForeground(Color.BLACK);
            } else {
                comp.setBackground(new Color(225, 245, 255)); //new Color(210, 230, 255));
                comp.setForeground(Color.BLACK);
            }
            if (isCellSelected(index_row, index_col)) {
                comp.setForeground(Color.RED);
            }
            return comp;
        }
    };

    tableModel.addTableModelListener(this);

    TableCellRenderer rend = dataTable.getTableHeader().getDefaultRenderer();
    TableColumnModel tcm = dataTable.getColumnModel();
    //for (int j = 0; j < tcm.getColumnCount(); j += 1) {
    TableColumn tc = tcm.getColumn(0);
    TableCellRenderer rendCol = tc.getHeaderRenderer(); // likely null  
    if (rendCol == null) {
        rendCol = rend;
    }
    Component c = rendCol.getTableCellRendererComponent(dataTable, tc.getHeaderValue(), false, false, 0, 0);
    tc.setPreferredWidth(35);

    tc = tcm.getColumn(6);
    rendCol = tc.getHeaderRenderer(); // likely null  
    if (rendCol == null) {
        rendCol = rend;
    }
    c = rendCol.getTableCellRendererComponent(dataTable, tc.getHeaderValue(), false, false, 0, 6);
    tc.setPreferredWidth(35);

    JScrollPane scroll = new JScrollPane(dataTable);
    mainBox.add(scroll);

    this.add(mainBox, BorderLayout.CENTER);

    this.validate();
}

From source file:savant.plugin.builtin.SAFEBrowser.java

void initSafe(final String username, final String password)
        throws MalformedURLException, JDOMException, IOException {

    safeCard.removeAll();/*from  w ww. j  a v  a2  s  . c  o m*/
    safeCard.setLayout(new BorderLayout());

    File f = NetworkUtils.downloadFile(
            new URL(BrowserSettings.SAFE_URL + "?type=list&username=" + username + "&password=" + password),
            DirectorySettings.getTmpDirectory(), null);

    if (!wereCredentialsValid(f)) {
        DialogUtils.displayMessage("Login failed.");
        return;
    }

    final Component mainp = getCenterPanel(getDownloadTreeRows(f));
    safeCard.add(mainp, BorderLayout.CENTER);

    JMenuBar bottombar = new JMenuBar();
    bottombar.setAlignmentX(RIGHT_ALIGNMENT);
    bottombar.add(Box.createHorizontalGlue());

    /*
    JButton refbutt = new JButton("Refresh");
    refbutt.putClientProperty( "JButton.buttonType", "default" );
    refbutt.addActionListener(new ActionListener() {
            
    @Override
    public void actionPerformed(ActionEvent e) {
        try {
            System.out.println("Refreshing");
            safeCard.remove(mainp);
            File f = DownloadFile.downloadFile(new URL("http://savantbrowser.com/safe/savantsafe.php?username=" + username + "&password=" + password), System.getProperty("java.io.tmpdir"));
            Component newmainp = getCenterPanel(getDownloadTreeRows(f));
            safeCard.add(newmainp, BorderLayout.CENTER);
            container.invalidate();
            System.out.println("Done Refreshing");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    });
    bottombar.add(refbutt);
     *
     */

    JButton addgroupbutt = new JButton("Create group");
    addgroupbutt.putClientProperty("JButton.buttonType", "default");
    addgroupbutt.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                addGroup(username, password);
            } catch (Exception ex) {
                LOG.error("Unable to create group: " + ex.getLocalizedMessage());
            }
        }
    });
    bottombar.add(addgroupbutt);

    JButton logoutbutt = new JButton("Logout");
    logoutbutt.putClientProperty("JButton.buttonType", "default");
    logoutbutt.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            layout.show(container, "login");
        }
    });
    bottombar.add(logoutbutt);

    JButton openbutt = new JButton("Load Track");
    openbutt.putClientProperty("JButton.buttonType", "default");
    openbutt.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            actOnSelectedItem(false);
        }
    });
    bottombar.add(openbutt);

    safeCard.add(bottombar, BorderLayout.SOUTH);

    layout.show(container, "safe");
}

From source file:components.ListDialog.java

private ListDialog(Frame frame, Component locationComp, String labelText, String title, Object[] data,
        String initialValue, String longValue) {
    super(frame, title, true);

    //Create and initialize the buttons.
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);
    ///*from   ww w .  ja  v  a 2s. c o  m*/
    final JButton setButton = new JButton("Set");
    setButton.setActionCommand("Set");
    setButton.addActionListener(this);
    getRootPane().setDefaultButton(setButton);

    //main part of the dialog
    list = new JList(data) {
        //Subclass JList to workaround bug 4832765, which can cause the
        //scroll pane to not let the user easily scroll up to the beginning
        //of the list.  An alternative would be to set the unitIncrement
        //of the JScrollBar to a fixed value. You wouldn't get the nice
        //aligned scrolling, but it should work.
        public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
            int row;
            if (orientation == SwingConstants.VERTICAL && direction < 0
                    && (row = getFirstVisibleIndex()) != -1) {
                Rectangle r = getCellBounds(row, row);
                if ((r.y == visibleRect.y) && (row != 0)) {
                    Point loc = r.getLocation();
                    loc.y--;
                    int prevIndex = locationToIndex(loc);
                    Rectangle prevR = getCellBounds(prevIndex, prevIndex);

                    if (prevR == null || prevR.y >= r.y) {
                        return 0;
                    }
                    return prevR.height;
                }
            }
            return super.getScrollableUnitIncrement(visibleRect, orientation, direction);
        }
    };

    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    if (longValue != null) {
        list.setPrototypeCellValue(longValue); //get extra space
    }
    list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    list.setVisibleRowCount(-1);
    list.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                setButton.doClick(); //emulate button click
            }
        }
    });
    JScrollPane listScroller = new JScrollPane(list);
    listScroller.setPreferredSize(new Dimension(250, 80));
    listScroller.setAlignmentX(LEFT_ALIGNMENT);

    //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));
    JLabel label = new JLabel(labelText);
    label.setLabelFor(list);
    listPane.add(label);
    listPane.add(Box.createRigidArea(new Dimension(0, 5)));
    listPane.add(listScroller);
    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);
    buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPane.add(setButton);

    //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.
    setValue(initialValue);
    pack();
    setLocationRelativeTo(locationComp);
}

From source file:org.ut.biolab.medsavant.client.view.UpdatesPanel.java

private void showPopup(final int start) {
    popup = new JPopupMenu();
    popup.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1));

    if (notifications == null) {
        popup.add(new NotificationIcon(null, null));
    } else {/*from w w  w. j a  v  a  2s  .com*/

        //add notifications
        for (int i = start; i < Math.min(start + 5, notifications.length); i++) {
            popup.add(new NotificationIcon(notifications[i], popup));
            if (i != Math.min(start + 5, notifications.length) - 1) {
                popup.add(createSeparator());
            }
        }

        //add page header
        if (notifications.length > 5) {
            JPanel header = new JPanel();
            header.setMinimumSize(new Dimension(1, 15));
            header.setLayout(new BoxLayout(header, BoxLayout.X_AXIS));
            if (start >= 5) {
                JLabel prevButton = ViewUtil.createLabelButton("  Prev Page  ");
                prevButton.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        showPopup(start - 5);
                    }
                });
                header.add(prevButton);
            }
            header.add(Box.createHorizontalGlue());
            if (start + 5 < notifications.length) {
                JLabel nextButton = ViewUtil.createLabelButton("  Next Page  ");
                nextButton.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        showPopup(start + 5);
                    }
                });
                header.add(nextButton);
            }
            popup.add(createSeparator());
            popup.add(header);
        }
    }

    //int offset = -Math.min(5, notifications.length - start) * (MENU_ICON_SIZE.height + 2) -3 - (headerAdded ? 16 : 0);        
    popup.show(this, 0, this.getPreferredSize().height);
}

From source file:be.agiv.security.demo.Main.java

private void addMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);//from  w w w . j  a  va 2 s. co m

    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);
    this.preferencesMenuItem = new JMenuItem("Preferences");
    fileMenu.add(this.preferencesMenuItem);
    this.preferencesMenuItem.addActionListener(this);
    fileMenu.addSeparator();
    this.exitMenuItem = new JMenuItem("Exit");
    fileMenu.add(this.exitMenuItem);
    this.exitMenuItem.addActionListener(this);

    JMenu ipStsMenu = new JMenu("IP-STS");
    menuBar.add(ipStsMenu);
    this.ipStsIssueMenuItem = new JMenuItem("Issue token");
    ipStsMenu.add(this.ipStsIssueMenuItem);
    this.ipStsIssueMenuItem.addActionListener(this);
    this.ipStsViewMenuItem = new JMenuItem("View token");
    ipStsMenu.add(this.ipStsViewMenuItem);
    this.ipStsViewMenuItem.addActionListener(this);
    this.ipStsViewMenuItem.setEnabled(false);

    JMenu rStsMenu = new JMenu("R-STS");
    menuBar.add(rStsMenu);
    this.rStsIssueMenuItem = new JMenuItem("Issue token");
    rStsMenu.add(this.rStsIssueMenuItem);
    this.rStsIssueMenuItem.addActionListener(this);
    this.rStsIssueMenuItem.setEnabled(false);
    this.rStsViewMenuItem = new JMenuItem("View token");
    rStsMenu.add(this.rStsViewMenuItem);
    this.rStsViewMenuItem.addActionListener(this);
    this.rStsViewMenuItem.setEnabled(false);

    JMenu secConvMenu = new JMenu("Secure Conversation");
    menuBar.add(secConvMenu);
    this.secConvIssueMenuItem = new JMenuItem("Issue token");
    secConvMenu.add(this.secConvIssueMenuItem);
    this.secConvIssueMenuItem.addActionListener(this);
    this.secConvIssueMenuItem.setEnabled(false);
    this.secConvViewMenuItem = new JMenuItem("View token");
    secConvMenu.add(this.secConvViewMenuItem);
    this.secConvViewMenuItem.addActionListener(this);
    this.secConvViewMenuItem.setEnabled(false);
    this.secConvCancelMenuItem = new JMenuItem("Cancel token");
    secConvMenu.add(this.secConvCancelMenuItem);
    this.secConvCancelMenuItem.addActionListener(this);
    this.secConvCancelMenuItem.setEnabled(false);

    JMenu servicesMenu = new JMenu("Services");
    menuBar.add(servicesMenu);
    this.claimsAwareServiceMenuItem = new JMenuItem("Claims aware service");
    servicesMenu.add(this.claimsAwareServiceMenuItem);
    this.claimsAwareServiceMenuItem.addActionListener(this);

    menuBar.add(Box.createHorizontalGlue());
    JMenu helpMenu = new JMenu("Help");
    menuBar.add(helpMenu);
    this.aboutMenuItem = new JMenuItem("About");
    helpMenu.add(this.aboutMenuItem);
    this.aboutMenuItem.addActionListener(this);
}

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);//from w w  w  .  j a  v  a 2s  . 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:org.ut.biolab.medsavant.client.view.dialog.FamilySelector.java

private void initUI() {

    JPanel p = new JPanel();
    ViewUtil.applyVerticalBoxLayout(p);//  w w  w .  j  a  va2s .  com
    this.add(p);

    topPanel = ViewUtil.getClearPanel();
    middlePanel = ViewUtil.getClearPanel();
    bottomPanel = ViewUtil.getClearPanel();

    p.add(topPanel);
    p.add(middlePanel);
    p.add(bottomPanel);

    // middle
    middlePanel.setLayout(new BorderLayout());

    retriever = new FamilyReceiver();

    stp = new SearchableTablePanel("Individuals", COLUMN_NAMES, COLUMN_CLASSES, HIDDEN_COLUMNS, true, true,
            Integer.MAX_VALUE, false, SearchableTablePanel.TableSelectionType.ROW, Integer.MAX_VALUE,
            retriever);
    stp.setExportButtonVisible(false);

    middlePanel.add(stp, BorderLayout.CENTER);

    // bottom
    ViewUtil.applyVerticalBoxLayout(bottomPanel);

    numselections = ViewUtil.getTitleLabel("0 families selected");

    JPanel text = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(text);

    JButton clearIndividuals = ViewUtil
            .getIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.CLOSE));
    clearIndividuals.setToolTipText("Clear selections");
    clearIndividuals.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            clearSelections();
        }
    });

    text.add(numselections);
    text.add(Box.createHorizontalStrut(5));
    text.add(clearIndividuals);
    bottomPanel.add(ViewUtil.centerHorizontally(text));

    final JButton addAllIndividuals = ViewUtil.getSoftButton("Add All");
    bottomPanel.add(addAllIndividuals);

    final JButton addIndividuals = ViewUtil.getSoftButton("Add Selected");
    bottomPanel.add(addIndividuals);

    final JButton removeIndividuals = ViewUtil.getSoftButton("Remove Selected");
    bottomPanel.add(removeIndividuals);

    final JButton removeAllIndividuals = ViewUtil.getSoftButton("Remove All");
    bottomPanel.add(removeAllIndividuals);

    JPanel buttons = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(buttons);

    buttons.add(addAllIndividuals);
    buttons.add(addIndividuals);
    buttons.add(removeIndividuals);
    buttons.add(removeAllIndividuals);

    JPanel windowControlPanel = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(windowControlPanel);
    windowControlPanel.add(Box.createHorizontalGlue());

    JButton cancel = new JButton("Cancel");
    bottomPanel.add(ViewUtil.centerHorizontally(buttons));

    ok = new JButton("OK");
    bottomPanel.add(ViewUtil.alignRight(ok));
    ok.setEnabled(false);

    windowControlPanel.add(cancel);
    windowControlPanel.add(ok);

    bottomPanel.add(windowControlPanel);

    final JDialog instance = this;

    ok.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            instance.setVisible(false);
            setIndividualsChosen(true);
        }
    });

    cancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            instance.setVisible(false);
            setIndividualsChosen(false || hasMadeSelections);
        }
    });

    addIndividuals.setEnabled(false);
    removeIndividuals.setEnabled(false);

    stp.getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent lse) {
            if (!lse.getValueIsAdjusting()) {

                int rows[] = stp.getTable().getSelectedRows();

                boolean someSelection = rows.length > 0;

                addIndividuals.setEnabled(someSelection);
                removeIndividuals.setEnabled(someSelection);

                if (someSelection) {
                    addIndividuals.setText("Add Selected (" + rows.length + ")");
                    removeIndividuals.setText("Remove Selected (" + rows.length + ")");
                } else {
                    addIndividuals.setText("Add Selected");
                    removeIndividuals.setText("Remove Selected");
                }
            }
        }
    });

    stp.getTable().getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent tme) {
            //addAllIndividuals.setText("Add All (" + stp.getTable().getModel().getRowCount() + ")");
            //removeAllIndividuals.setText("Remove All (" + stp.getTable().getModel().getRowCount() + ")");
        }
    });

    ActionListener addAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            addSelections(false);
        }
    };

    ActionListener addAllAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            addSelections(true);
        }
    };

    ActionListener removeAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            removeSelections(false);
        }
    };

    ActionListener removeAllAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            removeSelections(true);
        }
    };

    addIndividuals.addActionListener(addAction);
    addAllIndividuals.addActionListener(addAllAction);
    removeIndividuals.addActionListener(removeAction);
    removeAllIndividuals.addActionListener(removeAllAction);

    this.pack();
    this.setLocationRelativeTo(MedSavantFrame.getInstance());
}

From source file:pcgen.gui2.sources.AdvancedSourceSelectionPanel.java

private void initComponents() {
    FlippingSplitPane mainPane = new FlippingSplitPane(JSplitPane.VERTICAL_SPLIT, "advSrcMain");
    FlippingSplitPane topPane = new FlippingSplitPane("advSrcTop");
    topPane.setResizeWeight(0.6);/*from w w  w.j  a  v  a 2s.  c om*/
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JLabel(LanguageBundle.getString("in_src_gameLabel")), BorderLayout.WEST); //$NON-NLS-1$

    FacadeComboBoxModel<GameModeDisplayFacade> gameModes = new FacadeComboBoxModel<>();
    gameModes.setListFacade(FacadeFactory.getGameModeDisplays());
    gameModeList.setModel(gameModes);
    gameModeList.addActionListener(this);
    panel.add(gameModeList, BorderLayout.CENTER);

    FilterBar<Object, CampaignFacade> bar = new FilterBar<>(false);
    bar.add(panel, BorderLayout.WEST);
    bar.addDisplayableFilter(new SearchFilterPanel());
    panel = new JPanel(new BorderLayout());
    panel.add(bar, BorderLayout.NORTH);

    availableTable.setDisplayableFilter(bar);
    availableTable.setTreeViewModel(availTreeViewModel);
    availableTable.getSelectionModel().addListSelectionListener(this);
    availableTable.setTreeCellRenderer(new CampaignRenderer());
    ((DynamicTableColumnModel) availableTable.getColumnModel()).getAvailableColumns().get(2)
            .setCellRenderer(new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));

    JScrollPane pane = new JScrollPane(availableTable);
    pane.setPreferredSize(new Dimension(600, 310));
    panel.add(pane, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    unloadAllButton.setAction(new UnloadAllAction());
    box.add(unloadAllButton);
    box.add(Box.createHorizontalGlue());
    addButton.setHorizontalTextPosition(SwingConstants.LEADING);
    addButton.setAction(new AddAction());
    box.add(addButton);
    box.add(Box.createHorizontalStrut(5));
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    panel.add(box, BorderLayout.SOUTH);

    topPane.setLeftComponent(panel);

    JPanel selPanel = new JPanel(new BorderLayout());
    FilterBar<Object, CampaignFacade> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    selectedTable.setDisplayableFilter(filterBar);

    selectedTable.setTreeViewModel(selTreeViewModel);
    selectedTable.getSelectionModel().addListSelectionListener(this);
    selectedTable.setTreeCellRenderer(new CampaignRenderer());
    ((DynamicTableColumnModel) selectedTable.getColumnModel()).getAvailableColumns().get(2)
            .setCellRenderer(new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
    JScrollPane scrollPane = new JScrollPane(selectedTable);
    scrollPane.setPreferredSize(new Dimension(300, 350));
    selPanel.add(scrollPane, BorderLayout.CENTER);
    box = Box.createHorizontalBox();
    box.add(Box.createHorizontalStrut(5));
    removeButton.setAction(new RemoveAction());
    box.add(removeButton);
    box.add(Box.createHorizontalGlue());
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    selPanel.add(box, BorderLayout.SOUTH);

    topPane.setRightComponent(selPanel);
    mainPane.setTopComponent(topPane);

    linkAction.install();
    infoPane.setPreferredSize(new Dimension(800, 150));
    mainPane.setBottomComponent(infoPane);
    mainPane.setResizeWeight(0.7);
    setLayout(new BorderLayout());
    add(mainPane, BorderLayout.CENTER);
}