Example usage for javax.swing SwingConstants CENTER

List of usage examples for javax.swing SwingConstants CENTER

Introduction

In this page you can find the example usage for javax.swing SwingConstants CENTER.

Prototype

int CENTER

To view the source code for javax.swing SwingConstants CENTER.

Click Source Link

Document

The central position in an area.

Usage

From source file:org.spoutcraft.launcher.skin.components.BackgroundImage.java

public BackgroundImage(int width, int height) {
    setVerticalAlignment(SwingConstants.CENTER);
    setHorizontalAlignment(SwingConstants.CENTER);
    setBounds(0, 0, width, height);/*from ww  w .j a  va2s . c om*/

    setIcon(new ImageIcon(getBackgroundImage().getScaledInstance(width, height, Image.SCALE_SMOOTH)));
    setVerticalAlignment(SwingConstants.TOP);
    setHorizontalAlignment(SwingConstants.LEFT);
}

From source file:org.vpac.grisu.client.view.swing.mainPanel.Grisu.java

/**
 * This method initializes aboutVersionLabel
 * /*from w  ww .  j av  a2s .  c  o  m*/
 * @return javax.swing.JLabel
 */
private JLabel getAboutVersionLabel() {
    if (aboutVersionLabel == null) {
        aboutVersionLabel = new JLabel();
        aboutVersionLabel.setText(GRISU_VERSION);
        aboutVersionLabel.setHorizontalAlignment(SwingConstants.CENTER);
    }
    return aboutVersionLabel;
}

From source file:org.vpac.grix.view.swing.Grix.java

/**
 * This method initializes aboutVersionLabel
 * /*from  ww  w.ja v  a  2 s  .c  om*/
 * @return javax.swing.JLabel
 */
private JLabel getAboutVersionLabel() {
    if (aboutVersionLabel == null) {
        aboutVersionLabel = new JLabel();
        aboutVersionLabel.setText("Grix " + GRIX_VERSION);
        aboutVersionLabel.setHorizontalAlignment(SwingConstants.CENTER);
    }
    return aboutVersionLabel;
}

From source file:org.yccheok.jstock.gui.portfolio.DividendSummaryJDialog.java

/** This method is called from within the constructor to
 * initialize the form.//from  ww w .  ja  va  2 s  . c  o  m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jXHeader1 = new org.jdesktop.swingx.JXHeader();
    jPanel2 = new javax.swing.JPanel();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jPanel1 = new javax.swing.JPanel();
    jPanel3 = new javax.swing.JPanel();
    jButton3 = new javax.swing.JButton();
    jButton4 = new javax.swing.JButton();
    jButton5 = new javax.swing.JButton();
    jPanel4 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTable1 = new javax.swing.JTable();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui"); // NOI18N
    setTitle(bundle.getString("DividendSummaryJDialog_DividendPayout")); // NOI18N
    setIconImage(null);
    setResizable(false);
    addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            formMouseClicked(evt);
        }
    });
    getContentPane().setLayout(new java.awt.BorderLayout(5, 5));

    jXHeader1.setDescription(bundle.getString("DividendSummaryJDialog_Description")); // NOI18N
    jXHeader1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/32x32/money2.png"))); // NOI18N
    jXHeader1.setTitle(bundle.getString("DividendSummaryJDialog_Dividend")); // NOI18N
    getContentPane().add(jXHeader1, java.awt.BorderLayout.NORTH);

    jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/apply.png"))); // NOI18N
    jButton1.setText(bundle.getString("DividendSummary_OK")); // NOI18N
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });
    jPanel2.add(jButton1);

    jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/button_cancel.png"))); // NOI18N
    jButton2.setText(bundle.getString("DividendSummary_Cancel")); // NOI18N
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });
    jPanel2.add(jButton2);

    getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);

    jPanel1.setLayout(new java.awt.BorderLayout(5, 5));

    jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/filenew.png"))); // NOI18N
    jButton3.setText(bundle.getString("DividendSummaryJDialog_New")); // NOI18N
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
        }
    });
    jPanel3.add(jButton3);

    jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/editdelete.png"))); // NOI18N
    jButton4.setText(bundle.getString("DividendSummaryJDialog_Delete")); // NOI18N
    jButton4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton4ActionPerformed(evt);
        }
    });
    jPanel3.add(jButton4);

    jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/auto-dividend.png"))); // NOI18N
    jButton5.setText(bundle.getString("DividendSummaryJDialog_AutoDividend...")); // NOI18N
    jButton5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton5ActionPerformed(evt);
        }
    });
    jPanel3.add(jButton5);

    jPanel1.add(jPanel3, java.awt.BorderLayout.NORTH);

    jLabel1.setForeground(new java.awt.Color(0, 0, 255));
    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setText(bundle.getString("DividendSummaryJDialog_TotalDividend")); // NOI18N
    jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jPanel4.add(jLabel1);

    jLabel2.setForeground(new java.awt.Color(0, 0, 255));
    jLabel2.setText(getDividendSummaryText());
    jLabel2.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jLabel2MouseClicked(evt);
        }

        public void mouseEntered(java.awt.event.MouseEvent evt) {
            jLabel2MouseEntered(evt);
        }

        public void mouseExited(java.awt.event.MouseEvent evt) {
            jLabel2MouseExited(evt);
        }
    });
    jPanel4.add(jLabel2);

    jPanel1.add(jPanel4, java.awt.BorderLayout.PAGE_END);

    jTable1.setModel(new DividendSummaryTableModel(this.dividendSummary));
    org.yccheok.jstock.gui.table.CurrencyRenderer currencyRenderer = new org.yccheok.jstock.gui.table.CurrencyRenderer();
    org.yccheok.jstock.gui.table.NonNegativeEmptyDoubleEditor currencyEditor = new org.yccheok.jstock.gui.table.NonNegativeEmptyDoubleEditor();
    currencyRenderer.setHorizontalAlignment(org.yccheok.jstock.gui.table.CurrencyRenderer.RIGHT);
    ((JTextField) currencyEditor.getComponent()).setHorizontalAlignment(SwingConstants.RIGHT);
    jTable1.setDefaultEditor(Double.class, currencyEditor);
    jTable1.setDefaultRenderer(Double.class, currencyRenderer);
    jTable1.setDefaultEditor(StockInfo.class, new org.yccheok.jstock.gui.table.StockInfoEditor(
            this.portfolioManagementJPanel.getStockInfosFromPortfolios()));
    jTable1.setDefaultRenderer(StockInfo.class, new StockInfoRenderer());

    // JTableCustomizer.setEditorForRow(jTable1, 1);
    // Do not use JTableCustomizer. We need to have our own implementation to decide 
    // row background color.
    JTableUtilities.setDateEditorAndRendererForRow(jTable1, 0);
    jTable1.setAutoCreateRowSorter(true);
    jTable1.addMouseListener(new TableRowPopupListener());

    if (JStock.instance().getJStockOptions().useLargeFont()) {
        this.jTable1.setRowHeight((int) (this.jTable1.getRowHeight() * Constants.FONT_ENLARGE_FACTOR));
    }
    jTable1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            jTable1PropertyChange(evt);
        }
    });
    jTable1.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            jTable1KeyPressed(evt);
        }
    });
    jScrollPane1.setViewportView(jTable1);

    jPanel1.add(jScrollPane1, java.awt.BorderLayout.CENTER);

    getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

    setSize(new java.awt.Dimension(339, 373));
    setLocationRelativeTo(null);
}

From source file:pcgen.gui2.PCGenFrame.java

private void showMatureDialog(String text) {
    Logging.errorPrint("Warning: The following datasets contains mature themes. User discretion is advised.");
    Logging.errorPrint(text);// w w  w.j  av  a  2  s . co m

    final JDialog aFrame = new JDialog(this, LanguageBundle.getString("in_matureTitle"), true);

    final JPanel jPanel1 = new JPanel();
    final JPanel jPanel3 = new JPanel();
    final JLabel jLabel1 = new JLabel(LanguageBundle.getString("in_matureWarningLine1"), //$NON-NLS-1$
            SwingConstants.CENTER);
    final JLabel jLabel2 = new JLabel(LanguageBundle.getString("in_matureWarningLine2"), //$NON-NLS-1$
            SwingConstants.CENTER);
    final JCheckBox jCheckBox1 = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad")); //$NON-NLS-1$
    final JButton jClose = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$
    jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$

    jPanel1.setLayout(new BorderLayout());
    jPanel1.add(jLabel1, BorderLayout.NORTH);
    jPanel1.add(jLabel2, BorderLayout.SOUTH);

    HtmlPanel htmlPanel = new HtmlPanel();
    HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel,
            new SimpleUserAgentContext());
    htmlPanel.setHtml(text, "", theRendererContext);

    jPanel3.add(jCheckBox1);
    jPanel3.add(jClose);

    final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT;
    jCheckBox1.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD));

    jClose.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            aFrame.dispose();
        }

    });

    jCheckBox1.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent evt) {
            context.setBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD, jCheckBox1.isSelected());
        }

    });

    aFrame.getContentPane().setLayout(new BorderLayout());
    aFrame.getContentPane().add(jPanel1, BorderLayout.NORTH);
    aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER);
    aFrame.getContentPane().add(jPanel3, BorderLayout.SOUTH);

    aFrame.setSize(new Dimension(456, 176));
    Utility.setComponentRelativeLocation(this, aFrame);
    aFrame.setVisible(true);
}

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.  ja v a2s. co m*/
    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);
}

From source file:pcgen.gui2.tabs.SummaryInfoTab.java

private void initRightPanel(JPanel rightPanel) {
    rightPanel.setLayout(new GridBagLayout());
    /*/*  w  ww . j  a  va  2s . c  o  m*/
     * initialize Components
     */
    racePanel.setOpaque(false);
    classPanel.setOpaque(false);
    ageField.setHorizontalAlignment(SwingConstants.RIGHT);
    expField.setHorizontalAlignment(SwingConstants.RIGHT);
    nextlevelField.setHorizontalAlignment(SwingConstants.RIGHT);
    nextlevelField.setEnabled(false);
    expmodField.setHorizontalAlignment(SwingConstants.RIGHT);

    raceComboBox.setPrototypeDisplayValue("PrototypeDisplayValue"); //$NON-NLS-1$
    classComboBox.setPrototypeDisplayValue("PrototypeDisplayValue"); //$NON-NLS-1$

    expaddButton.setMargin(new Insets(0, 8, 0, 8));
    expsubtractButton.setMargin(new Insets(0, 8, 0, 8));
    hpButton.setMargin(new Insets(0, 0, 0, 0));

    JPanel expmodPanel = new JPanel(new GridBagLayout());
    JPanel levelPanel = new JPanel();
    JLabel raceLabel = createLabel("in_sumRace"); //$NON-NLS-1$
    JLabel ageLabel = createLabel("in_sumAge"); //$NON-NLS-1$
    JLabel classLabel = createLabel("in_sumClass"); //$NON-NLS-1$
    JLabel hpLabel = createLabel("in_sumTotalHP"); //$NON-NLS-1$
    JLabel expLabel = createLabel("in_sumCurrentXp"); //$NON-NLS-1$
    JLabel nextlevelLabel = createLabel("in_sumNextlevel"); //$NON-NLS-1$
    JLabel xpTableLabel = createLabel("in_sumXpTable"); //$NON-NLS-1$
    JLabel expmodLabel = createLabel("in_sumExpMod"); //$NON-NLS-1$
    expmodLabel.setHorizontalAlignment(SwingConstants.CENTER);
    initLevelPanel(levelPanel);
    /*
     * initialize constant variables
     */
    Insets racePanelInsets = racePanel.getInsets();
    Insets classPanelInsets = classPanel.getInsets();
    /*
     * racePanel
     */
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(racePanelInsets.top, racePanelInsets.left, 0, 0);
    gbc.gridwidth = 2;
    rightPanel.add(raceLabel, gbc);
    gbc.insets = new Insets(racePanelInsets.top, 1, 1, racePanelInsets.right);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    rightPanel.add(raceComboBox, gbc);
    gbc.insets = new Insets(0, racePanelInsets.left, 0, 1);
    gbc.gridwidth = 1;
    rightPanel.add(ageLabel, gbc);
    gbc.insets = new Insets(1, 1, 1, 1);
    rightPanel.add(ageField, gbc);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(1, 1, 1, racePanelInsets.right);
    rightPanel.add(ageComboBox, gbc);
    gbc.insets = new Insets(1, racePanelInsets.left, racePanelInsets.bottom, racePanelInsets.right);
    rightPanel.add(createMonsterButton, gbc);
    /*
     * classPanel
     */
    gbc.gridwidth = 2;
    gbc.insets = new Insets(classPanelInsets.top, classPanelInsets.left, 0, 0);
    rightPanel.add(classLabel, gbc);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(classPanelInsets.top, 0, 0, classPanelInsets.right);
    rightPanel.add(classComboBox, gbc);

    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(7, classPanelInsets.left, 0, classPanelInsets.right);
    rightPanel.add(levelPanel, gbc);
    gbc.insets.top = 0;
    gbc.insets.bottom = 10;
    gbc.weighty = 0;
    {
        JPanel hpPanel = new JPanel(new FlowLayout());
        hpPanel.add(hpLabel);
        hpPanel.add(Box.createHorizontalStrut(3));
        hpPanel.add(totalHPLabel);
        hpPanel.add(hpButton);
        rightPanel.add(hpPanel, gbc);
    }
    gbc.insets.bottom = 0;
    GridBagConstraints leftgbc = new GridBagConstraints();
    leftgbc.insets = new Insets(0, classPanelInsets.left, 0, 0);
    leftgbc.gridwidth = 2;
    leftgbc.fill = GridBagConstraints.BOTH;

    GridBagConstraints rightgbc = new GridBagConstraints();
    rightgbc.insets = new Insets(0, 0, 0, classPanelInsets.right);
    rightgbc.gridwidth = GridBagConstraints.REMAINDER;
    rightgbc.fill = GridBagConstraints.BOTH;

    rightPanel.add(expLabel, leftgbc);
    rightPanel.add(expField, rightgbc);
    rightPanel.add(nextlevelLabel, leftgbc);
    rightPanel.add(nextlevelField, rightgbc);
    rightPanel.add(xpTableLabel, leftgbc);
    rightPanel.add(xpTableComboBox, rightgbc);

    gbc.insets.top = 10;
    rightPanel.add(expmodLabel, gbc);
    {
        GridBagConstraints gbc2 = new GridBagConstraints();
        gbc2.fill = GridBagConstraints.HORIZONTAL;
        gbc2.weightx = 1.0;
        gbc2.insets = new Insets(0, 1, 0, 1);
        expmodPanel.add(expaddButton, gbc2);
        expmodPanel.add(expsubtractButton, gbc2);
    }
    leftgbc.insets.bottom = classPanelInsets.bottom;
    leftgbc.weightx = 0.3;
    rightPanel.add(expmodPanel, leftgbc);
    rightgbc.insets.bottom = classPanelInsets.bottom;
    rightgbc.weightx = 0.7;
    rightPanel.add(expmodField, rightgbc);

    gbc = new GridBagConstraints();
    gbc.gridx = gbc.gridy = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = 3;
    gbc.fill = GridBagConstraints.BOTH;
    rightPanel.add(racePanel, gbc);

    gbc.gridy = 3;
    gbc.gridheight = GridBagConstraints.REMAINDER;
    rightPanel.add(classPanel, gbc);
}

From source file:pl.kotcrab.arget.gui.dialog.CreateContactDialog.java

public CreateContactDialog(JFrame frame, String profilePublicKey, final ContactInfo contact,
        final CreateContactDialogFinished listener) {
    super(frame, true);

    this.profilePublicKey = profilePublicKey;

    changeListener = new FieldsChangeListener();

    setTitle("Edit Contact Details");
    setSize(477, 261);//from   ww w . j  a va2s.com
    setMinimumSize(new Dimension(300, 250));
    setPositionToCenter(frame);

    JPanel mainPanel = new JPanel();
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(mainPanel, BorderLayout.CENTER);

    nickTextField = new JTextField();

    keyTextArea = new JTextArea();
    keyTextArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
    keyTextArea.setLineWrap(true);

    nickTextField.getDocument().addDocumentListener(changeListener);
    keyTextArea.getDocument().addDocumentListener(changeListener);

    statusLabel = new JLabel("Nickname cannot be empty");
    statusLabel.setForeground(Color.RED);
    statusLabel.setBorder(new EmptyBorder(0, 6, 0, 0));

    JButton cancelButton = new JButton("Cancel");
    okButton = new JButton("OK");
    okButton.setEnabled(false);

    mainPanel.setLayout(new MigLayout("", "[55.00px][][390px,grow]", "[20px][15px][135px,grow][]"));

    mainPanel.add(new JLabel("Nickname:"), "cell 0 0,grow");
    mainPanel.add(new JLabel("Public key:", SwingConstants.CENTER), "cell 0 1 3 1,grow");
    mainPanel.add(nickTextField, "cell 1 0 2 1,grow");
    mainPanel.add(new JScrollPane(keyTextArea), "cell 0 2 3 1,grow");
    mainPanel.add(statusLabel, "cell 0 3 2 1");
    mainPanel.add(cancelButton, "flowx,cell 2 3,alignx right");
    mainPanel.add(okButton, "cell 2 3,alignx right");

    okButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (listener != null) {
                ContactInfo contact = new ContactInfo(nickTextField.getText(), keyTextArea.getText());
                listener.finished(contact);
            }

            if (contact != null) {
                contact.name = nickTextField.getText();
                contact.publicProfileKey = keyTextArea.getText();
            }

            dispose();
        }
    });

    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });

    if (contact != null) {
        nickTextField.setText(contact.name);
        keyTextArea.setText(contact.publicProfileKey);
    }

    setVisible(true);
}

From source file:pl.otros.logview.gui.message.editor.MessageColorizerBrowser.java

public MessageColorizerBrowser(OtrosApplication otrosApplication) {
    super(new BorderLayout());
    this.container = otrosApplication.getAllPluginables().getMessageColorizers();
    this.otrosApplication = otrosApplication;

    toolBar = new JToolBar();
    editor = new MessageColorizerEditor(container, otrosApplication.getStatusObserver());
    JLabel noEditable = new JLabel("Selected MessageColorizer is not editable.", SwingConstants.CENTER);
    JLabel nothingSelected = new JLabel("Nothing selected", SwingConstants.CENTER);

    listModel = new PluginableElementListModel<MessageColorizer>(container);
    jList = new JList(listModel);
    jList.setCellRenderer(new PluginableElementNameListRenderer());
    cardLayout = new CardLayout();
    contentPanel = new JPanel(cardLayout);
    contentPanel.add(editor, CARD_LAYOUT_EDITOR);
    contentPanel.add(noEditable, CARD_LAYOUT_NOT_EDITABLE);
    contentPanel.add(nothingSelected, CARD_LAYOUT_NO_SELECTED);
    cardLayout.show(contentPanel, CARD_LAYOUT_NOT_EDITABLE);
    JSplitPane mainSplitPane = new JSplitPane(SwingConstants.VERTICAL, new JScrollPane(jList), contentPanel);
    mainSplitPane.setDividerLocation(220);

    jList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override/*from  w w w. ja v a  2s .co  m*/
        public void valueChanged(ListSelectionEvent e) {
            showSelected();
            enableDisableButtonsForSelectedColorizer();
        }

    });

    jList.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            int keyCode = e.getKeyCode();
            if (keyCode == KeyEvent.VK_DELETE) {
                ActionEvent actionEvent = new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, "");
                deleteAction.actionPerformed(actionEvent);
            }
        }
    });

    JButton createNew = new JButton("Create new", Icons.ADD);
    createNew.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveAsButton.setEnabled(false);
            createNew();
        }
    });

    saveButton = new JButton("Save and use", Icons.DISK);
    saveButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            try {
                PropertyPatternMessageColorizer mc = editor.createMessageColorizer();
                File selectedFile = null;
                String f = mc.getFile();
                if (StringUtils.isNotBlank(f)) {
                    selectedFile = new File(mc.getFile());
                } else {
                    int response = chooser.showSaveDialog(MessageColorizerBrowser.this);
                    if (response != JFileChooser.APPROVE_OPTION) {
                        return;
                    }
                    selectedFile = chooser.getSelectedFile();
                    if (!selectedFile.getName().endsWith(".pattern")) {
                        selectedFile = new File(selectedFile.getParentFile(),
                                selectedFile.getName() + ".pattern");
                    }
                }
                removeMessageColorizerWithNullFile();
                applyMessageColorizer(selectedFile);
                saveMessageColorizer(selectedFile);
                jList.setSelectedValue(mc, true);
            } catch (ConfigurationException e1) {
                String errorMessage = String.format("Can't save message colorizer: %s", e1.getMessage());
                LOGGER.severe(errorMessage);
                MessageColorizerBrowser.this.otrosApplication.getStatusObserver().updateStatus(errorMessage,
                        StatusObserver.LEVEL_ERROR);
            }
        }
    });

    saveAsButton = new JButton("Save as", Icons.DISK_PLUS);
    saveAsButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                int response = chooser.showSaveDialog(MessageColorizerBrowser.this);
                if (response != JFileChooser.APPROVE_OPTION) {
                    return;
                }
                File selectedFile = chooser.getSelectedFile();
                selectedFile = chooser.getSelectedFile();
                if (!selectedFile.getName().endsWith(".pattern")) {
                    selectedFile = new File(selectedFile.getParentFile(), selectedFile.getName() + ".pattern");
                }
                removeMessageColorizerWithNullFile();
                applyMessageColorizer(selectedFile);
                saveMessageColorizer(selectedFile);
                jList.setSelectedValue(editor.createMessageColorizer(), true);
            } catch (ConfigurationException e1) {
                String errorMessage = String.format("Can't save message colorizer: %s", e1.getMessage());
                LOGGER.severe(errorMessage);
                MessageColorizerBrowser.this.otrosApplication.getStatusObserver().updateStatus(errorMessage,
                        StatusObserver.LEVEL_ERROR);
            }
        }
    });

    useButton = new JButton("Use without saving");
    useButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            try {
                removeMessageColorizerWithNullFile();
                applyMessageColorizer(File.createTempFile("messageColorizer", "pattern"));
            } catch (Exception e) {
                LOGGER.severe("Cannot create message colorizer: " + e.getMessage());
            }

        }
    });

    deleteAction = new DeleteSelected(otrosApplication);
    deleteButton = new JButton(deleteAction);

    toolBar.setFloatable(false);
    toolBar.add(createNew);
    toolBar.add(saveButton);
    toolBar.add(saveAsButton);
    toolBar.add(useButton);
    toolBar.add(deleteButton);
    enableDisableButtonsForSelectedColorizer();
    initFileChooser();
    this.add(mainSplitPane);
    this.add(toolBar, BorderLayout.SOUTH);
}

From source file:pl.otros.vfs.browser.VfsBrowser.java

License:asdf

private JLabel getTitleListLabel(String text, Icon icon) {
    JLabel jLabel = new JLabel(text, icon, SwingConstants.CENTER);
    Font font = jLabel.getFont();
    jLabel.setFont(font.deriveFont(Font.ITALIC | Font.BOLD, font.getSize() * 1.1f));
    jLabel.setBorder(BorderFactory.createEmptyBorder(10, 3, 0, 3));

    return jLabel;
}