Search in sources :

Example 16 with JTextField

use of javax.swing.JTextField in project gitblit by gitblit.

the class SettingsPanel method initialize.

private void initialize() {
    JButton refreshSettings = new JButton(Translation.get("gb.refresh"));
    refreshSettings.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            refreshSettings();
        }
    });
    final JButton editSetting = new JButton(Translation.get("gb.edit"));
    editSetting.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int viewRow = table.getSelectedRow();
            int modelRow = table.convertRowIndexToModel(viewRow);
            String key = tableModel.keys.get(modelRow);
            SettingModel setting = tableModel.settings.get(key);
            editSetting(setting);
        }
    });
    NameRenderer nameRenderer = new NameRenderer();
    final SettingPanel settingPanel = new SettingPanel();
    tableModel = new SettingsTableModel();
    defaultSorter = new TableRowSorter<SettingsTableModel>(tableModel);
    table = Utils.newTable(tableModel, Utils.DATE_FORMAT);
    table.setDefaultRenderer(SettingModel.class, new SettingCellRenderer());
    String name = table.getColumnName(UsersTableModel.Columns.Name.ordinal());
    table.getColumn(name).setCellRenderer(nameRenderer);
    table.setRowSorter(defaultSorter);
    table.getRowSorter().toggleSortOrder(SettingsTableModel.Columns.Name.ordinal());
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            boolean singleSelection = table.getSelectedRows().length == 1;
            editSetting.setEnabled(singleSelection);
            if (singleSelection) {
                int viewRow = table.getSelectedRow();
                int modelRow = table.convertRowIndexToModel(viewRow);
                SettingModel setting = tableModel.get(modelRow);
                settingPanel.setSetting(setting);
            } else {
                settingPanel.clear();
            }
        }
    });
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                int viewRow = table.getSelectedRow();
                int modelRow = table.convertRowIndexToModel(viewRow);
                SettingModel setting = tableModel.get(modelRow);
                editSetting(setting);
            }
        }
    });
    filterTextfield = new JTextField();
    filterTextfield.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            filterSettings(filterTextfield.getText());
        }
    });
    filterTextfield.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            filterSettings(filterTextfield.getText());
        }
    });
    JPanel settingFilterPanel = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN));
    settingFilterPanel.add(new JLabel(Translation.get("gb.filter")), BorderLayout.WEST);
    settingFilterPanel.add(filterTextfield, BorderLayout.CENTER);
    JPanel settingsTablePanel = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN));
    settingsTablePanel.add(settingFilterPanel, BorderLayout.NORTH);
    settingsTablePanel.add(new JScrollPane(table), BorderLayout.CENTER);
    settingsTablePanel.add(settingPanel, BorderLayout.SOUTH);
    JPanel settingsControls = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
    settingsControls.add(refreshSettings);
    settingsControls.add(editSetting);
    setLayout(new BorderLayout(Utils.MARGIN, Utils.MARGIN));
    header = new HeaderPanel(Translation.get("gb.settings"), "settings_16x16.png");
    add(header, BorderLayout.NORTH);
    add(settingsTablePanel, BorderLayout.CENTER);
    add(settingsControls, BorderLayout.SOUTH);
}
Also used : SettingModel(com.gitblit.models.SettingModel) JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) ListSelectionEvent(javax.swing.event.ListSelectionEvent) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) ListSelectionListener(javax.swing.event.ListSelectionListener) KeyEvent(java.awt.event.KeyEvent) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout)

Example 17 with JTextField

use of javax.swing.JTextField in project binnavi by google.

the class ErrorDialog method createGui.

private void createGui() {
    final JPanel topPanel = new JPanel(new BorderLayout());
    final JPanel messagePanel = new JPanel(new BorderLayout());
    final JTextField messageField = new JTextField();
    messageField.setEditable(false);
    messageField.setText(message);
    messageField.setBackground(Color.WHITE);
    messagePanel.add(messageField);
    messagePanel.setBorder(new TitledBorder("Error Message"));
    topPanel.add(messagePanel, BorderLayout.NORTH);
    final JTabbedPane tabbedPane = new JTabbedPane();
    final JTextArea descriptionArea = new JTextArea();
    descriptionArea.setEditable(false);
    descriptionArea.setText(description);
    descriptionArea.setLineWrap(true);
    descriptionArea.setWrapStyleWord(true);
    tabbedPane.addTab("Description", descriptionArea);
    if (exception != null) {
        final JTextArea traceArea = new JTextArea();
        traceArea.setEditable(false);
        traceArea.setText(StackTrace.toString(exception.getStackTrace()));
        tabbedPane.addTab("Stack Trace", new JScrollPane(traceArea));
    }
    add(topPanel, BorderLayout.NORTH);
    add(tabbedPane);
    final JPanel bottomButtonPanel = new JPanel(new BorderLayout());
    final JPanel leftButtonPanelBottom = new JPanel();
    final JButton reportButton = new JButton(new ReportAction());
    reportButton.setMinimumSize(new Dimension(180, reportButton.getHeight()));
    leftButtonPanelBottom.add(reportButton);
    bottomButtonPanel.add(leftButtonPanelBottom, BorderLayout.WEST);
    final JPanel rightButtonPanelBottom = new JPanel();
    final JButton okButton = new JButton(new CloseButtonListener());
    getRootPane().setDefaultButton(okButton);
    rightButtonPanelBottom.add(okButton);
    bottomButtonPanel.add(rightButtonPanelBottom, BorderLayout.EAST);
    add(bottomButtonPanel, BorderLayout.SOUTH);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) BorderLayout(java.awt.BorderLayout) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) TitledBorder(javax.swing.border.TitledBorder)

Example 18 with JTextField

use of javax.swing.JTextField in project binnavi by google.

the class AtomicTypePanel method createControls.

private void createControls() {
    setLayout(new BorderLayout());
    final JPanel contentPanel = new JPanel();
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    add(contentPanel, BorderLayout.CENTER);
    final GridBagLayout gbl_m_contentPanel = new GridBagLayout();
    gbl_m_contentPanel.columnWidths = new int[] { 0, 0, 0 };
    gbl_m_contentPanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0 };
    gbl_m_contentPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gbl_m_contentPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
    contentPanel.setLayout(gbl_m_contentPanel);
    final JLabel lblNewLabel = new JLabel("Name:");
    final GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
    gbc_lblNewLabel.anchor = GridBagConstraints.WEST;
    gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
    gbc_lblNewLabel.gridx = 0;
    gbc_lblNewLabel.gridy = 0;
    contentPanel.add(lblNewLabel, gbc_lblNewLabel);
    name = new JTextField();
    name.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(final KeyEvent e) {
            updatePreview();
        }
    });
    final GridBagConstraints gbc_m_name = new GridBagConstraints();
    gbc_m_name.insets = new Insets(0, 0, 5, 0);
    gbc_m_name.fill = GridBagConstraints.HORIZONTAL;
    gbc_m_name.gridx = 1;
    gbc_m_name.gridy = 0;
    contentPanel.add(name, gbc_m_name);
    name.setColumns(10);
    final JLabel lblSize = new JLabel("Size (bits):");
    final GridBagConstraints gbc_lblSize = new GridBagConstraints();
    gbc_lblSize.anchor = GridBagConstraints.WEST;
    gbc_lblSize.insets = new Insets(0, 0, 5, 5);
    gbc_lblSize.gridx = 0;
    gbc_lblSize.gridy = 1;
    contentPanel.add(lblSize, gbc_lblSize);
    size = new JTextField();
    final GridBagConstraints gbc_m_size = new GridBagConstraints();
    gbc_m_size.insets = new Insets(0, 0, 5, 0);
    gbc_m_size.fill = GridBagConstraints.HORIZONTAL;
    gbc_m_size.gridx = 1;
    gbc_m_size.gridy = 1;
    contentPanel.add(size, gbc_m_size);
    size.setColumns(10);
    signed = new JCheckBox("Signed");
    final GridBagConstraints gbc_m_signed = new GridBagConstraints();
    gbc_m_signed.anchor = GridBagConstraints.WEST;
    gbc_m_signed.insets = new Insets(0, 0, 5, 5);
    gbc_m_signed.gridx = 0;
    gbc_m_signed.gridy = 2;
    contentPanel.add(signed, gbc_m_signed);
    lblPreview = new JLabel("Preview:");
    final GridBagConstraints gbc_lblPreview = new GridBagConstraints();
    gbc_lblPreview.insets = new Insets(0, 0, 5, 5);
    gbc_lblPreview.gridx = 0;
    gbc_lblPreview.gridy = 3;
    contentPanel.add(lblPreview, gbc_lblPreview);
    preview = new JTextArea();
    preview.setEditable(false);
    final GridBagConstraints gbc_preview = new GridBagConstraints();
    gbc_preview.insets = new Insets(0, 0, 5, 0);
    gbc_preview.fill = GridBagConstraints.BOTH;
    gbc_preview.gridx = 1;
    gbc_preview.gridy = 3;
    contentPanel.add(preview, gbc_preview);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) KeyAdapter(java.awt.event.KeyAdapter) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) KeyEvent(java.awt.event.KeyEvent) JCheckBox(javax.swing.JCheckBox) BorderLayout(java.awt.BorderLayout) EmptyBorder(javax.swing.border.EmptyBorder)

Example 19 with JTextField

use of javax.swing.JTextField in project binnavi by google.

the class ComplexTypePanel method createControls.

private void createControls(final List<BaseType> baseTypes) {
    setBorder(new EmptyBorder(5, 5, 5, 5));
    final GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 0, 0, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 1.0, 1.0, Double.MIN_VALUE };
    setLayout(gridBagLayout);
    final JLabel lblName = new JLabel("Name:");
    GridBagConstraints gbcLblName = new GridBagConstraints();
    gbcLblName.insets = new Insets(0, 0, 5, 5);
    gbcLblName.anchor = GridBagConstraints.WEST;
    gbcLblName.gridx = 0;
    gbcLblName.gridy = 0;
    add(lblName, gbcLblName);
    name = new JTextField();
    GridBagConstraints gbcName = new GridBagConstraints();
    gbcName.insets = new Insets(0, 0, 5, 0);
    gbcName.fill = GridBagConstraints.HORIZONTAL;
    gbcName.gridx = 1;
    gbcName.gridy = 0;
    add(name, gbcName);
    name.setColumns(10);
    final JLabel lblMembers = new JLabel("Members:");
    final GridBagConstraints gbcLblMembers = new GridBagConstraints();
    gbcLblMembers.anchor = GridBagConstraints.WEST;
    gbcLblMembers.insets = new Insets(0, 0, 5, 5);
    gbcLblMembers.gridx = 0;
    gbcLblMembers.gridy = 2;
    add(lblMembers, gbcLblMembers);
    final MemberTableModel model = new MemberTableModel();
    model.addTableModelListener(new MemberTableModelListener());
    members = new MemberTable(model, baseTypes);
    final TableRowSorter<MemberTableModel> sorter = new TableRowSorter<MemberTableModel>(model);
    // Triggers immediate re-sort when offset is updated.
    sorter.setSortsOnUpdates(true);
    sorter.setSortable(MemberTableModel.NAME_COLUMN, false);
    sorter.setSortable(MemberTableModel.TYPE_COLUMN, false);
    // Initial state is ascending sort order.
    sorter.toggleSortOrder(MemberTableModel.INDEX_COLUMN);
    members.setRowSorter(sorter);
    final GridBagConstraints gbcMembers = new GridBagConstraints();
    gbcMembers.insets = new Insets(0, 0, 5, 0);
    gbcMembers.fill = GridBagConstraints.BOTH;
    gbcMembers.gridx = 1;
    gbcMembers.gridy = 2;
    add(new JScrollPane(members), gbcMembers);
    final JLabel lblPreview = new JLabel("Preview:");
    final GridBagConstraints gbcLblPreview = new GridBagConstraints();
    gbcLblPreview.anchor = GridBagConstraints.WEST;
    gbcLblPreview.insets = new Insets(0, 0, 0, 5);
    gbcLblPreview.gridx = 0;
    gbcLblPreview.gridy = 3;
    add(lblPreview, gbcLblPreview);
    final JTextArea preview = new JTextArea();
    final GridBagConstraints gbcPreview = new GridBagConstraints();
    gbcPreview.fill = GridBagConstraints.BOTH;
    gbcPreview.gridx = 1;
    gbcPreview.gridy = 3;
    add(preview, gbcPreview);
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) EmptyBorder(javax.swing.border.EmptyBorder) TableRowSorter(javax.swing.table.TableRowSorter)

Example 20 with JTextField

use of javax.swing.JTextField in project binnavi by google.

the class MemberDialog method createControls.

private void createControls(final TypeManager typeManager) {
    setBounds(100, 100, 450, 215);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    final GridBagLayout gbl_contentPanel = new GridBagLayout();
    gbl_contentPanel.columnWidths = new int[] { 0, 0, 0 };
    gbl_contentPanel.rowHeights = new int[] { 0, 0, 0, 0 };
    gbl_contentPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
    contentPanel.setLayout(gbl_contentPanel);
    {
        final JLabel lblMemberName = new JLabel("Member name:");
        final GridBagConstraints gbc_lblMemberName = new GridBagConstraints();
        gbc_lblMemberName.insets = new Insets(0, 0, 5, 5);
        gbc_lblMemberName.anchor = GridBagConstraints.EAST;
        gbc_lblMemberName.gridx = 0;
        gbc_lblMemberName.gridy = 0;
        contentPanel.add(lblMemberName, gbc_lblMemberName);
    }
    {
        memberName = new JTextField();
        final GridBagConstraints gbc_memberName = new GridBagConstraints();
        gbc_memberName.insets = new Insets(0, 0, 5, 0);
        gbc_memberName.fill = GridBagConstraints.HORIZONTAL;
        gbc_memberName.gridx = 1;
        gbc_memberName.gridy = 0;
        contentPanel.add(memberName, gbc_memberName);
        memberName.setColumns(10);
    }
    {
        final JLabel lblMemberType = new JLabel("Member type:");
        final GridBagConstraints gbc_lblMemberType = new GridBagConstraints();
        gbc_lblMemberType.anchor = GridBagConstraints.EAST;
        gbc_lblMemberType.insets = new Insets(0, 0, 5, 5);
        gbc_lblMemberType.gridx = 0;
        gbc_lblMemberType.gridy = 1;
        contentPanel.add(lblMemberType, gbc_lblMemberType);
    }
    {
        memberType = new TypeComboBox(new TypeListModel(typeManager.getTypes(), new TypeListModel.PrototypesFilter()));
        final GridBagConstraints gbc_memberType = new GridBagConstraints();
        gbc_memberType.insets = new Insets(0, 0, 5, 0);
        gbc_memberType.fill = GridBagConstraints.HORIZONTAL;
        gbc_memberType.gridx = 1;
        gbc_memberType.gridy = 1;
        contentPanel.add(memberType, gbc_memberType);
    }
    {
        final JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            final JButton okButton = new JButton("OK");
            okButton.addActionListener(new OkActionListener());
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            final JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(final ActionEvent e) {
                    dispose();
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

JTextField (javax.swing.JTextField)311 JLabel (javax.swing.JLabel)188 JPanel (javax.swing.JPanel)173 JButton (javax.swing.JButton)107 BorderLayout (java.awt.BorderLayout)85 JCheckBox (javax.swing.JCheckBox)58 Dimension (java.awt.Dimension)57 ActionEvent (java.awt.event.ActionEvent)56 ActionListener (java.awt.event.ActionListener)49 JScrollPane (javax.swing.JScrollPane)47 BoxLayout (javax.swing.BoxLayout)41 Insets (java.awt.Insets)37 GridBagLayout (java.awt.GridBagLayout)36 FlowLayout (java.awt.FlowLayout)35 GridBagConstraints (java.awt.GridBagConstraints)35 JComboBox (javax.swing.JComboBox)29 JTextArea (javax.swing.JTextArea)28 JRadioButton (javax.swing.JRadioButton)23 GridLayout (java.awt.GridLayout)22 JTable (javax.swing.JTable)22