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:es.emergya.ui.gis.popups.GenericDialog.java

protected void addJoinedRow(String[][] pairs, Integer[] colsLength) {
    if (pairs == null || pairs.length == 0 || pairs.length != colsLength.length)
        return;/*from  ww w .  j  a va 2 s.  c  o  m*/
    rows++;

    int contador = 0;
    for (int i : colsLength)
        contador += i;
    final FlowLayout flowLayout = new FlowLayout();
    JPanel panel = new JPanel(flowLayout);
    panel.setOpaque(false);
    JTextField jtextField = new JTextField(pairs[0][1]);
    jtextField.setEditable(true);
    jtextField.setColumns(colsLength[0]);
    panel.add(jtextField);
    mid.add(new JLabel(i18n.getString(pairs[0][0]), JLabel.RIGHT));

    for (int i = 1; i < pairs.length; i++) {
        String[] pair = pairs[i];
        if (pair.length != 2)
            log.error("Par desconocido");
        else {
            panel.add(new JLabel(i18n.getString(pair[0]), JLabel.RIGHT));
            jtextField = new JTextField(pair[1]);
            jtextField.setEditable(true);
            panel.add(jtextField);
            jtextField.setColumns(colsLength[i]);
        }
    }
    if (contador < 100)
        for (int i = contador; i < 100; i += 5)
            panel.add(new JLabel("        "));

    mid.add(panel);

    for (int i = 2; i < cols; i++)
        mid.add(Box.createHorizontalGlue());
}

From source file:pcgen.gui2.dialog.ExportDialog.java

private void initLayout() {
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    Box topPanel = Box.createHorizontalBox();
    topPanel.add(new JLabel("Select Character:"));
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(characterBox);/*from  w  w w  .  j av a  2 s  .  co m*/
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(partyBox);
    topPanel.add(Box.createHorizontalGlue());
    topPanel.add(Box.createHorizontalStrut(50));
    topPanel.add(new JLabel("Export to:"));
    topPanel.add(Box.createHorizontalStrut(5));
    topPanel.add(exportBox);
    contentPane.add(topPanel, BorderLayout.NORTH);

    JScrollPane scrollPane = new JScrollPane(fileList);
    scrollPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Templates"),
            scrollPane.getBorder()));
    contentPane.add(scrollPane, BorderLayout.CENTER);

    Box bottomPanel = Box.createHorizontalBox();
    bottomPanel.add(progressBar);
    bottomPanel.add(Box.createHorizontalGlue());
    bottomPanel.add(Box.createHorizontalStrut(5));
    bottomPanel.add(exportButton);
    bottomPanel.add(Box.createHorizontalStrut(5));
    bottomPanel.add(closeButton);
    contentPane.add(bottomPanel, BorderLayout.SOUTH);

    topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bottomPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    pack();
}

From source file:verdandi.ui.ProjectViewerPanel.java

private JToolBar getToolbar() {
    // JPanel toolbar = new JPanel();
    // toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.LINE_AXIS));
    JToolBar toolbar = new JToolBar(SwingConstants.HORIZONTAL);

    toolbar.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;/*from   ww  w .  j  av  a 2  s . co  m*/
    c.gridy = 0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    c.weightx = 0.0;
    c.weighty = 0.0;

    URL imageURL = null;
    imageURL = Thread.currentThread().getContextClassLoader()
            .getResource(THEME_RC.getString("icon.project.add"));
    ImageIcon addProjectIcon = new ImageIcon(imageURL, "add");

    JButton addProject = new JButton(addProjectIcon);
    addProject.setActionCommand(CMD_ADD_PROJECT);
    addProject.setToolTipText(RB.getString("projectviewer.add.tooltip"));
    addProject.addActionListener(this);
    toolbar.add(addProject, c);
    c.gridx++;

    imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.project.edit"));
    ImageIcon editProjectIcon = new ImageIcon(imageURL, "edit");

    JButton editProject = new JButton(editProjectIcon);
    editProject.setActionCommand(CMD_EDIT_PROJECT);
    editProject.setToolTipText(RB.getString("projectviewer.edit.tooltip"));
    editProject.addActionListener(this);
    toolbar.add(editProject, c);
    c.gridx++;

    imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.projects.import"));
    ImageIcon importProjectIcon = new ImageIcon(imageURL, "import");
    JButton importProject = new JButton(importProjectIcon);
    importProject.setActionCommand(CMD_IMPORT_PROJECT);
    importProject.setToolTipText(RB.getString("projectviewer.import.tooltip"));
    importProject.addActionListener(this);
    toolbar.add(importProject, c);
    c.gridx++;

    // THEME_RC.getString("")
    imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.projects.export"));
    ImageIcon exportProjectIcon = new ImageIcon(imageURL, "export");
    JButton exportProject = new JButton(exportProjectIcon);
    exportProject.setActionCommand(CMD_EXPORT_PROJECT);
    exportProject.setToolTipText(RB.getString("projectviewer.export.tooltip"));
    exportProject.addActionListener(this);
    toolbar.add(exportProject, c);
    c.gridx++;

    toolbar.add(new JToolBar.Separator(), c);
    c.gridx++;

    imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.project.hide.active"));
    hideActiveIcon = new ImageIcon(imageURL, "hide active");
    imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.project.show.active"));
    showActiveIcon = new ImageIcon(imageURL, "show active");
    toggleShowActive = new JToggleButton(hideActiveIcon);
    toggleShowActive.setActionCommand(CMD_TOGGLE_SHOW_ACTIVE);
    toggleShowActive.setToolTipText(RB.getString("projectviewer.toggleshowactive.tooltip"));
    toggleShowActive.addActionListener(this);
    toolbar.add(toggleShowActive, c);
    c.gridx++;

    c.weightx = 0.5;
    toolbar.add(Box.createHorizontalGlue(), c);
    c.weightx = 0.0;
    c.gridx++;

    c.insets = new Insets(0, 5, 0, 5);
    toolbar.add(new JLabel("Filter"), c);
    c.gridx++;
    c.insets = new Insets(0, 0, 0, 0);
    searchField = new JTextField(10);
    searchField.getDocument().addDocumentListener(this);
    searchField.setToolTipText(RB.getString("projectviewer.searchfield.tooltip"));
    toolbar.add(searchField, c);

    toolbar.setFloatable(false);
    return toolbar;
}

From source file:edu.ku.brc.specify.ui.treetables.TreeDefinitionEditor.java

/**
* @param isEditMode whether to enable editing.
*///w w  w. ja  va  2  s  . co m
protected void initUI() {
    this.setLayout(new BorderLayout());

    Dimension horizSpacer = new Dimension(5, 0);

    statusBar = UIRegistry.getStatusBar();

    // create north panel
    titlePanel = new JPanel();
    titlePanel.setLayout(new BoxLayout(titlePanel, BoxLayout.LINE_AXIS));

    defNameLabel = createLabel(""); //$NON-NLS-1$

    titlePanel.add(Box.createHorizontalGlue());
    titlePanel.add(defNameLabel);
    titlePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 4, 0));

    if (isEditMode) {
        //editDefButton = createButton(editIcon);
        editDefButton = UIHelper.createIconBtn("EditIcon", "TTV_EDIT_TREDEF_TITLE", new ActionListener() //$NON-NLS-1$ //$NON-NLS-2$
        {
            public void actionPerformed(ActionEvent ae) {
                showDefEditDialog(displayedDef);
            }
        });
        editDefButton.setEnabled(true);

        // add north panel widgets
        titlePanel.add(Box.createRigidArea(horizSpacer));
        titlePanel.add(editDefButton);

    } else {
        editDefButton = null;
    }
    titlePanel.add(Box.createHorizontalGlue());

    if (isEditMode) {
        // create south panel
        ActionListener deleteAction = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                deleteItem(defItemsTable.getSelectedRow());
            }
        };
        ActionListener newItemAction = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                newItem(defItemsTable.getSelectedRow());
            }
        };

        ActionListener editItemAction = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                editTreeDefItem(defItemsTable.getSelectedRow());
            }
        };

        edaPanel = new EditDeleteAddPanel(editItemAction, deleteAction, newItemAction, "TTV_EDIT_TDI", //$NON-NLS-1$
                "TTV_DEL_TDI", "TTV_NEW_TDI"); //$NON-NLS-1$ //$NON-NLS-2$
    }
}

From source file:org.apache.tika.gui.TikaGUI.java

private void addMenuBar() {
    JMenuBar bar = new JMenuBar();

    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    addMenuItem(file, "Open...", "openfile", KeyEvent.VK_O);
    addMenuItem(file, "Open URL...", "openurl", KeyEvent.VK_U);
    file.addSeparator();//from   w  w w  .  ja va  2s .c om
    addMenuItem(file, "Exit", "exit", KeyEvent.VK_X);
    bar.add(file);

    JMenu view = new JMenu("View");
    view.setMnemonic(KeyEvent.VK_V);
    addMenuItem(view, "Metadata", "metadata", KeyEvent.VK_M);
    addMenuItem(view, "Formatted text", "html", KeyEvent.VK_F);
    addMenuItem(view, "Plain text", "text", KeyEvent.VK_P);
    addMenuItem(view, "Main content", "main", KeyEvent.VK_C);
    addMenuItem(view, "Structured text", "xhtml", KeyEvent.VK_S);
    addMenuItem(view, "Recursive JSON", "json", KeyEvent.VK_J);
    bar.add(view);

    bar.add(Box.createHorizontalGlue());
    JMenu help = new JMenu("Help");
    help.setMnemonic(KeyEvent.VK_H);
    addMenuItem(help, "About Tika", "about", KeyEvent.VK_A);
    bar.add(help);

    setJMenuBar(bar);
}

From source file:aurelienribon.gdxsetupui.ui.panels.LibrarySelectionPanel.java

private void buildLibraryPanel(final String libraryName) {
    ActionListener nameChkAL = new ActionListener() {
        @Override/*from   w w  w  .  j a va 2 s  .  co  m*/
        public void actionPerformed(ActionEvent e) {
            if (((CompactCheckBox) e.getSource()).isSelected()) {
                if (!Ctx.cfgSetup.libraries.contains(libraryName))
                    Ctx.cfgSetup.libraries.add(libraryName);
                if (!Ctx.cfgUpdate.libraries.contains(libraryName))
                    Ctx.cfgUpdate.libraries.add(libraryName);
            } else {
                Ctx.cfgSetup.libraries.remove(libraryName);
                Ctx.cfgUpdate.libraries.remove(libraryName);
            }

            Ctx.fireCfgSetupChanged();
            Ctx.fireCfgUpdateChanged();
        }
    };

    Action infoAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            showInfo(libraryName);
        }
    };
    Action browseAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            browse(libraryName);
        }
    };
    Action getStableAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getStable(libraryName);
        }
    };
    Action getLatestAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getLatest(libraryName);
        }
    };

    LibraryDef def = Ctx.libs.getDef(libraryName);

    CompactCheckBox nameChk = new CompactCheckBox(def.name + " ");
    JLabel html5Label = new JLabel(Res.getImage("gfx/ic_html5.png"));
    JButton infoBtn = new JButton(infoAction);
    JButton browseBtn = new JButton(browseAction);
    JButton getStableBtn = new JButton(getStableAction);
    JButton getLatestBtn = new JButton(getLatestAction);

    nameChk.addActionListener(nameChkAL);
    nameChk.setForeground(LIB_NOTFOUND_COLOR);
    html5Label.setToolTipText("Compatible with HTML backend");
    infoBtn.setIcon(Res.getImage("gfx/ic_info.png"));
    browseBtn.setIcon(Res.getImage("gfx/ic_browse.png"));
    getStableBtn.setIcon(Res.getImage("gfx/ic_download_stable.png"));
    getLatestBtn.setIcon(Res.getImage("gfx/ic_download_nightlies.png"));
    infoBtn.setFocusable(false);
    browseBtn.setFocusable(false);
    getStableBtn.setFocusable(false);
    getLatestBtn.setFocusable(false);

    JToolBar toolBar = new JToolBar();
    toolBar.setOpaque(false);
    toolBar.setFloatable(false);
    toolBar.add(Box.createHorizontalGlue());
    toolBar.add(infoBtn);
    toolBar.add(browseBtn);
    if (def.stableUrl != null)
        toolBar.add(getStableBtn);
    else
        toolBar.add(Box.createHorizontalStrut(libgdxGetStableBtn.getPreferredSize().width));
    if (def.latestUrl != null)
        toolBar.add(getLatestBtn);
    else
        toolBar.add(Box.createHorizontalStrut(libgdxGetNightliesBtn.getPreferredSize().width));

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.setOpaque(false);
    leftPanel.add(nameChk, BorderLayout.CENTER);
    if (def.gwtModuleName != null)
        leftPanel.add(html5Label, BorderLayout.EAST);

    JPanel panel = new JPanel(new BorderLayout());
    panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
    panel.setOpaque(false);
    panel.add(leftPanel, BorderLayout.WEST);
    panel.add(toolBar, BorderLayout.CENTER);

    librariesPanel.add(panel);

    Style.apply(librariesPanel, style);
    libsNamesCmps.put(libraryName, nameChk);
}

From source file:com.diversityarrays.kdxplore.field.FieldViewDialog.java

public FieldViewDialog(Window owner, String title, SampleGroupChoice sgcSamples, Trial trial,
        SampleGroupChoice sgcNewMedia, KDSmartDatabase db) throws IOException {
    super(owner, title, ModalityType.MODELESS);

    advanceRetreatControls = Box.createHorizontalBox();
    advanceRetreatControls.add(new JButton(retreatAction));
    advanceRetreatControls.add(new JButton(advanceAction));

    autoAdvanceControls = Box.createHorizontalBox();
    autoAdvanceControls.add(new JButton(autoAdvanceAction));

    autoAdvanceOption.addActionListener(new ActionListener() {
        @Override/*ww  w .  java 2s. co  m*/
        public void actionPerformed(ActionEvent e) {
            updateMovementControls();
        }
    });

    this.database = db;
    this.sampleGroupChoiceForSamples = sgcSamples;
    this.sampleGroupChoiceForNewMedia = sgcNewMedia;

    NumberSpinner fontSpinner = new NumberSpinner(new SpinnerNumberModel(), "0.00");

    this.fieldViewPanel = FieldViewPanel.create(database, trial, SeparatorVisibilityOption.VISIBLE, null,
            Box.createHorizontalGlue(), new JButton(showInfoAction), Box.createHorizontalGlue(),
            new JLabel("Font Size:"), fontSpinner, Box.createHorizontalGlue(), advanceRetreatControls,
            autoAdvanceOption, autoAdvanceControls);

    initialiseAction(advanceAction, "ic_object_advance_black.png", "Auto-Advance");

    this.xyProvider = fieldViewPanel.getXYprovider();
    this.traitMap = fieldViewPanel.getTraitMap();

    fieldLayoutTable = fieldViewPanel.getFieldLayoutTable();

    JScrollPane scrollPane = fieldViewPanel.getFieldTableScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    fieldLayoutTable.setTransferHandler(flth);
    fieldLayoutTable.setDropMode(DropMode.ON);

    fieldLayoutTable.addMouseListener(new MouseAdapter() {
        JPopupMenu popupMenu;

        @Override
        public void mouseClicked(MouseEvent e) {
            if (!SwingUtilities.isRightMouseButton(e) || 1 != e.getClickCount()) {
                return;
            }
            Point pt = e.getPoint();
            int row = fieldLayoutTable.rowAtPoint(pt);
            if (row >= 0) {
                int col = fieldLayoutTable.columnAtPoint(pt);
                if (col >= 0) {
                    Plot plot = fieldViewPanel.getPlotAt(col, row);
                    if (plot != null) {
                        if (popupMenu == null) {
                            popupMenu = new JPopupMenu("View Attachments");
                        }
                        popupMenu.removeAll();

                        Set<File> set = plot.getMediaFiles();
                        if (Check.isEmpty(set)) {
                            popupMenu.add(new JMenuItem("No Attachments available"));
                        } else {
                            for (File file : set) {
                                Action a = new AbstractAction(file.getName()) {
                                    @Override
                                    public void actionPerformed(ActionEvent e) {
                                        try {
                                            Desktop.getDesktop().browse(file.toURI());
                                        } catch (IOException e1) {
                                            MsgBox.warn(FieldViewDialog.this, e1, file.getName());
                                        }
                                    }
                                };
                                popupMenu.add(new JMenuItem(a));
                            }
                        }
                        popupMenu.show(fieldLayoutTable, pt.x, pt.y);
                    }
                }
            }
        }

    });
    Font font = fieldLayoutTable.getFont();
    float fontSize = font.getSize2D();

    fontSizeModel = new SpinnerNumberModel(fontSize, fontSize, 50.0, 1.0);
    fontSpinner.setModel(fontSizeModel);
    fontSizeModel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            float fsize = fontSizeModel.getNumber().floatValue();
            System.out.println("Using fontSize=" + fsize);
            Font font = fieldLayoutTable.getFont().deriveFont(fsize);
            fieldLayoutTable.setFont(font);
            FontMetrics fm = fieldLayoutTable.getFontMetrics(font);
            int lineHeight = fm.getMaxAscent() + fm.getMaxDescent();
            fieldLayoutTable.setRowHeight(4 * lineHeight);

            //                GuiUtil.initialiseTableColumnWidths(fieldLayoutTable, false);

            fieldLayoutTable.repaint();
        }
    });

    fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    fieldLayoutTable.setResizable(true, true);
    fieldLayoutTable.getTableColumnResizer().setResizeAllColumns(true);

    advanceAction.setEnabled(false);
    fieldLayoutTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                handlePlotSelection();
            }
        }
    });
    TableColumnModel columnModel = fieldLayoutTable.getColumnModel();
    columnModel.addColumnModelListener(new TableColumnModelListener() {
        @Override
        public void columnSelectionChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                handlePlotSelection();
            }
        }

        @Override
        public void columnRemoved(TableColumnModelEvent e) {
        }

        @Override
        public void columnMoved(TableColumnModelEvent e) {
        }

        @Override
        public void columnMarginChanged(ChangeEvent e) {
        }

        @Override
        public void columnAdded(TableColumnModelEvent e) {
        }
    });

    PropertyChangeListener listener = new PropertyChangeListener() {
        // Use a timer and redisplay other columns when delay is GT 100 ms

        Timer timer = new Timer(true);
        TimerTask timerTask;
        long lastActive;
        boolean busy = false;
        private int eventColumnWidth;
        private TableColumn eventColumn;

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (busy) {
                return;
            }

            if (evt.getSource() instanceof TableColumn && "width".equals(evt.getPropertyName())) {

                eventColumn = (TableColumn) evt.getSource();
                eventColumnWidth = eventColumn.getWidth();

                lastActive = System.currentTimeMillis();
                if (timerTask == null) {
                    timerTask = new TimerTask() {
                        @Override
                        public void run() {
                            if (System.currentTimeMillis() - lastActive > 200) {
                                timerTask.cancel();
                                timerTask = null;

                                busy = true;
                                try {
                                    for (Enumeration<TableColumn> en = columnModel.getColumns(); en
                                            .hasMoreElements();) {
                                        TableColumn tc = en.nextElement();
                                        if (tc != eventColumn) {
                                            tc.setWidth(eventColumnWidth);
                                        }
                                    }
                                } finally {
                                    busy = false;
                                }
                            }
                        }
                    };
                    timer.scheduleAtFixedRate(timerTask, 100, 150);
                }
            }
        }
    };
    for (Enumeration<TableColumn> en = columnModel.getColumns(); en.hasMoreElements();) {
        TableColumn tc = en.nextElement();
        tc.addPropertyChangeListener(listener);
    }

    Map<Integer, Plot> plotById = new HashMap<>();
    for (Plot plot : fieldViewPanel.getFieldLayout()) {
        plotById.put(plot.getPlotId(), plot);
    }

    TrialItemVisitor<Sample> sampleVisitor = new TrialItemVisitor<Sample>() {
        @Override
        public void setExpectedItemCount(int count) {
        }

        @Override
        public boolean consumeItem(Sample sample) throws IOException {

            Plot plot = plotById.get(sample.getPlotId());
            if (plot == null) {
                throw new IOException("Missing plot for plotId=" + sample.getPlotId() + " sampleIdent="
                        + Util.createUniqueSampleKey(sample));
            }
            plot.addSample(sample);

            SampleCounts counts = countsByTraitId.get(sample.getTraitId());
            if (counts == null) {
                counts = new SampleCounts();
                countsByTraitId.put(sample.getTraitId(), counts);
            }
            if (sample.hasBeenScored()) {
                ++counts.scored;
            } else {
                ++counts.unscored;
            }
            return true;
        }
    };
    database.visitSamplesForTrial(sampleGroupChoiceForSamples, trial.getTrialId(),
            SampleOrder.ALL_BY_PLOT_ID_THEN_TRAIT_ID_THEN_INSTANCE_NUMBER_ORDER_THEN_SPECIMEN_NUMBER,
            sampleVisitor);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    this.trial = trial;

    KDClientUtils.initAction(ImageId.SETTINGS_24, showInfoAction, "Trial Summary");

    Action clear = new AbstractAction("Clear") {
        @Override
        public void actionPerformed(ActionEvent e) {
            infoTextArea.setText("");
        }
    };
    JPanel bottom = new JPanel(new BorderLayout());
    bottom.add(GuiUtil.createLabelSeparator("Plot Details", new JButton(clear)), BorderLayout.NORTH);
    bottom.add(new JScrollPane(infoTextArea), BorderLayout.CENTER);
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, fieldViewPanel,
            new JScrollPane(infoTextArea));
    splitPane.setResizeWeight(0.0);
    splitPane.setOneTouchExpandable(true);

    setContentPane(splitPane);

    updateMovementControls();
    pack();
}

From source file:BRHInit.java

public void showVPSPrompt(JSONArray vps) throws Exception {
    vps_list = vps;//  ww w . j  a v a2 s.  c  o  m

    if (vps_list_window == null) {
        vps_list_window = new JFrame("BRH Console");
        vps_list_window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel top_panel = new JPanel();
        vps_list_window.getContentPane().add(top_panel);

        top_panel.setLayout(new BoxLayout(top_panel, BoxLayout.Y_AXIS));
        top_panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

        Vector values = new Vector();
        for (int idx = 0; idx < vps_list.length(); ++idx) {
            JSONArray row = vps_list.getJSONArray(idx);
            values.addElement(row.getString(1));
        }

        vps_list_box = new JList(values);
        top_panel.add(new JScrollPane(vps_list_box));

        vps_list_box.setVisibleRowCount(10);

        JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

        JPanel col_panel = new JPanel();
        p.add(col_panel);
        col_panel.setLayout(new BoxLayout(col_panel, BoxLayout.Y_AXIS));

        col_panel.add(new JLabel("email"));
        col_panel.add(Box.createRigidArea(new Dimension(0, 5)));
        col_panel.add(new JLabel("password"));

        p.add(Box.createRigidArea(new Dimension(5, 0)));

        col_panel = new JPanel();
        p.add(col_panel);
        col_panel.setLayout(new BoxLayout(col_panel, BoxLayout.Y_AXIS));

        col_panel.add(email = new JTextField(20));
        col_panel.add(Box.createRigidArea(new Dimension(0, 5)));
        col_panel.add(password = new JPasswordField());

        top_panel.add(Box.createRigidArea(new Dimension(0, 10)));

        p = new JPanel();
        top_panel.add(p);
        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

        p.add(Box.createHorizontalGlue());
        p.add(vps_list_ok = new JButton("OK"));
        p.add(Box.createRigidArea(new Dimension(5, 0)));
        p.add(vps_list_cancel = new JButton("Cancel"));
        p.add(Box.createHorizontalGlue());

        vps_list_ok.addActionListener(this);
        vps_list_cancel.addActionListener(this);

        vps_list_window.pack();
    }

    vps_list_window.setVisible(true);
}

From source file:es.emergya.ui.gis.popups.GenericDialog.java

protected void addRow(String[][] pairs) {
    rows++;/*ww  w  .j a  va  2 s .co  m*/
    if (pairs.length > cols)
        log.error("Se va a descuadrar");

    int columnas = 0;
    for (String[] pair : pairs) {
        if (pair.length != 2)
            log.error("Par desconocido");
        else {
            columnas += 2;
            mid.add(new JLabel(i18n.getString(pair[0]), JLabel.RIGHT));
            JTextField jtextField = new JTextField(pair[1]);
            jtextField.setEditable(true);
            mid.add(jtextField);
        }
    }
    while (columnas < cols) {
        mid.add(Box.createHorizontalGlue());
        columnas++;
    }
}

From source file:es.emergya.ui.plugins.forms.FormGeneric.java

protected void addComboBox(Object selected, Object[] options, String title) {
    rows++;//from   w  ww  .j a va2  s .c  om
    mid.add(new JLabel(i18n.getString(title), JLabel.RIGHT));
    JComboBox cb = new JComboBox(options);
    cb.setSelectedItem(selected);
    cb.setName(title);
    componentes.add(cb);
    mid.add(cb);
    for (int i = 2; i < cols; i++)
        mid.add(Box.createHorizontalGlue());
}