Search in sources :

Example 16 with ActionEvent

use of java.awt.event.ActionEvent in project pcgen by PCGen.

the class PCGenFrame method showMatureDialog.

private void showMatureDialog(String text) {
    Logging.errorPrint("Warning: The following datasets contains mature themes. User discretion is advised.");
    Logging.errorPrint(text);
    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 //$NON-NLS-1$
    JLabel(//$NON-NLS-1$
    LanguageBundle.getString("in_matureWarningLine1"), SwingConstants.CENTER);
    final JLabel jLabel2 = new //$NON-NLS-1$
    JLabel(//$NON-NLS-1$
    LanguageBundle.getString("in_matureWarningLine2"), SwingConstants.CENTER);
    //$NON-NLS-1$
    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"));
    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);
}
Also used : SimpleHtmlRendererContext(org.lobobrowser.html.test.SimpleHtmlRendererContext) HtmlRendererContext(org.lobobrowser.html.HtmlRendererContext) SimpleHtmlRendererContext(org.lobobrowser.html.test.SimpleHtmlRendererContext) JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) SimpleUserAgentContext(org.lobobrowser.html.test.SimpleUserAgentContext) Dimension(java.awt.Dimension) JCheckBox(javax.swing.JCheckBox) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) HtmlPanel(org.lobobrowser.html.gui.HtmlPanel) PropertyContext(pcgen.system.PropertyContext) ItemListener(java.awt.event.ItemListener) JDialog(javax.swing.JDialog)

Example 17 with ActionEvent

use of java.awt.event.ActionEvent in project pcgen by PCGen.

the class GameModePanel method setupDisplay.

@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
    panel.setLayout(layout);
    JLabel introLabel = new JLabel("Please select the Game Mode to Convert:");
    panel.add(introLabel);
    layout.putConstraint(SpringLayout.NORTH, introLabel, 50, SpringLayout.NORTH, panel);
    layout.putConstraint(SpringLayout.WEST, introLabel, 25, SpringLayout.WEST, panel);
    List<GameMode> games = SystemCollections.getUnmodifiableGameModeList();
    gameModeCombo = new JComboBoxEx(games.toArray());
    gameModeCombo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            getSelection(pc);
            saveGameMode(pc);
        }
    });
    PCGenSettings context = PCGenSettings.getInstance();
    SettingsHandler.setGame(context.initProperty(PCGenSettings.CONVERT_GAMEMODE, SettingsHandler.getGame().getName()));
    GameMode currGame = SettingsHandler.getGame();
    if (pc.get(ObjectKey.GAME_MODE) != null) {
        currGame = pc.get(ObjectKey.GAME_MODE);
    }
    gameModeCombo.setSelectedItem(currGame);
    getSelection(pc);
    saveGameMode(pc);
    panel.add(gameModeCombo);
    layout.putConstraint(SpringLayout.NORTH, gameModeCombo, 20, SpringLayout.SOUTH, introLabel);
    layout.putConstraint(SpringLayout.WEST, gameModeCombo, 25, SpringLayout.WEST, panel);
}
Also used : GameMode(pcgen.core.GameMode) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JComboBoxEx(pcgen.gui2.util.JComboBoxEx) PCGenSettings(pcgen.system.PCGenSettings)

Example 18 with ActionEvent

use of java.awt.event.ActionEvent in project pcgen by PCGen.

the class SpellsKnownTab method initComponents.

private void initComponents() {
    availableTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setRowSorter(new SortableTableRowSorter() {

        @Override
        public SortableTableModel getModel() {
            return (SortableTableModel) selectedTable.getModel();
        }
    });
    selectedTable.getRowSorter().toggleSortOrder(0);
    FilterBar<CharacterFacade, SuperNode> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    //$NON-NLS-1$
    qFilterButton.setText(LanguageBundle.getString("in_igQualFilter"));
    filterBar.addDisplayableFilter(qFilterButton);
    FlippingSplitPane upperPane = new FlippingSplitPane("SpellsKnownTop");
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTable, filterBar);
    Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(2));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(autoKnownBox);
        hbox.add(Box.createHorizontalGlue());
        box.add(hbox);
    }
    //box.add(Box.createVerticalStrut(2));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(slotsBox);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(addButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    availPanel.add(box, BorderLayout.SOUTH);
    upperPane.setLeftComponent(availPanel);
    box = Box.createVerticalBox();
    box.add(new JScrollPane(selectedTable));
    box.add(Box.createVerticalStrut(4));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(removeButton);
        hbox.add(Box.createHorizontalStrut(10));
        JButton spellSheetButton = new JButton(LanguageBundle.getString("InfoSpells.select.spellsheet"));
        spellSheetButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                selectSpellSheetButton();
            }
        });
        hbox.add(spellSheetButton);
        hbox.add(Box.createHorizontalStrut(3));
        String text = PCGenSettings.getSelectedSpellSheet();
        if (text != null) {
            text = new File(text).getName();
        }
        spellSheetField.setEditable(false);
        spellSheetField.setText(text);
        spellSheetField.setToolTipText(text);
        hbox.add(spellSheetField);
        hbox.add(Box.createHorizontalStrut(3));
        previewSpellsButton = new JButton(Icons.PrintPreview16.getImageIcon());
        hbox.add(previewSpellsButton);
        hbox.add(Box.createHorizontalStrut(3));
        exportSpellsButton = new JButton(Icons.Print16.getImageIcon());
        hbox.add(exportSpellsButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setRightComponent(box);
    upperPane.setResizeWeight(0);
    setTopComponent(upperPane);
    FlippingSplitPane bottomPane = new FlippingSplitPane("SpellsKnownBottom");
    bottomPane.setLeftComponent(spellsPane);
    bottomPane.setRightComponent(classPane);
    setBottomComponent(bottomPane);
    setOrientation(VERTICAL_SPLIT);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) SuperNode(pcgen.facade.core.SpellSupportFacade.SuperNode) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) CharacterFacade(pcgen.facade.core.CharacterFacade) FlippingSplitPane(pcgen.gui2.tools.FlippingSplitPane) FilterBar(pcgen.gui2.filter.FilterBar) ActionListener(java.awt.event.ActionListener) SearchFilterPanel(pcgen.gui2.filter.SearchFilterPanel) File(java.io.File)

Example 19 with ActionEvent

use of java.awt.event.ActionEvent in project pcgen by PCGen.

the class JListEx method fireActionEvent.

private void fireActionEvent(Object value, int id, String command) {
    ActionEvent e = null;
    // Guaranteed to return a non-null array
    Object[] listeners = listenerList.getListenerList();
    // those that are interested in this event
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == ActionListener.class) {
            // Lazily create the event:
            if (e == null) {
                e = new ActionEvent(value, id, command);
            }
            ((ActionListener) listeners[i + 1]).actionPerformed(e);
        }
    }
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) Point(java.awt.Point)

Example 20 with ActionEvent

use of java.awt.event.ActionEvent in project pcgen by PCGen.

the class AbstractDialog method initialize.

private void initialize() {
    okButton = new JButton(LanguageBundle.getString(getOkKey()));
    okButton.setMnemonic(LanguageBundle.getMnemonic(getOkMnKey()));
    okButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okButtonActionPerformed();
        }
    });
    JButton cancelButton = new JButton(LanguageBundle.getString(getCancelKey()));
    cancelButton.setMnemonic(LanguageBundle.getMnemonic(getCancelMnKey()));
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelButtonActionPerformed();
        }
    });
    JButton bApply = null;
    if (includeApplyButton()) {
        //$NON-NLS-1$
        bApply = new JButton(LanguageBundle.getString("in_apply"));
        //$NON-NLS-1$
        bApply.setMnemonic(LanguageBundle.getMnemonic("in_mn_apply"));
        bApply.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent evt) {
                applyButtonActionPerformed();
            }
        });
    }
    // initialize button panel
    JPanel buttonPanel = new JPanel();
    //$NON-NLS-1$
    buttonPanel.setBorder(UIManager.getBorder("OptionPane.border"));
    buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    // offer identical width for Preferred size if needed
    //$NON-NLS-1$
    boolean sameSize = UIManager.getBoolean("OptionPane.sameSizeButtons");
    if (sameSize) {
        int max = Math.max(okButton.getPreferredSize().width, cancelButton.getPreferredSize().width);
        if (includeApplyButton()) {
            max = Math.max(max, bApply.getPreferredSize().width);
            bApply.setPreferredSize(new Dimension(max, bApply.getPreferredSize().height));
        }
        okButton.setPreferredSize(new Dimension(max, okButton.getPreferredSize().height));
        cancelButton.setPreferredSize(new Dimension(max, cancelButton.getPreferredSize().height));
    }
    // add button, respecting OptionPane.isYesLast
    //$NON-NLS-1$
    boolean isYesLast = UIManager.getBoolean("OptionPane.isYesLast");
    //$NON-NLS-1$
    int padding = UIManager.getInt("OptionPane.buttonPadding");
    if (isYesLast) {
        if (includeApplyButton()) {
            buttonPanel.add(bApply);
            buttonPanel.add(Box.createHorizontalStrut(padding));
        }
        buttonPanel.add(cancelButton);
        buttonPanel.add(Box.createHorizontalStrut(padding));
        buttonPanel.add(okButton);
    } else {
        buttonPanel.add(okButton);
        buttonPanel.add(Box.createHorizontalStrut(padding));
        if (includeApplyButton()) {
            buttonPanel.add(bApply);
            buttonPanel.add(Box.createHorizontalStrut(padding));
        }
        buttonPanel.add(cancelButton);
    }
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(getCenter(), BorderLayout.CENTER);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    if (shouldSetOkAsDefault()) {
        setOkAsDefault();
    }
    if (shouldInstallEsc()) {
        Utility.installEscapeCloseOperation(this);
    }
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Dimension(java.awt.Dimension)

Aggregations

ActionEvent (java.awt.event.ActionEvent)3561 ActionListener (java.awt.event.ActionListener)2755 JButton (javax.swing.JButton)1116 JPanel (javax.swing.JPanel)961 JLabel (javax.swing.JLabel)606 JMenuItem (javax.swing.JMenuItem)550 Dimension (java.awt.Dimension)531 AbstractAction (javax.swing.AbstractAction)510 BorderLayout (java.awt.BorderLayout)381 GridBagConstraints (java.awt.GridBagConstraints)301 GridBagLayout (java.awt.GridBagLayout)292 Insets (java.awt.Insets)288 JScrollPane (javax.swing.JScrollPane)274 BoxLayout (javax.swing.BoxLayout)262 JTextField (javax.swing.JTextField)262 FlowLayout (java.awt.FlowLayout)257 JCheckBox (javax.swing.JCheckBox)242 JMenu (javax.swing.JMenu)217 Point (java.awt.Point)203 ImageIcon (javax.swing.ImageIcon)191