Search in sources :

Example 1 with Hyperactive

use of pcgen.gui2.tools.Hyperactive in project pcgen by PCGen.

the class TipOfTheDay method initUI.

//
// initialize the dialog
//
private void initUI() {
    final JPanel panel = new JPanel(new BorderLayout(2, 2));
    panel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    JLabel iconLabel;
    final Icon icon = Icons.TipOfTheDay24.getImageIcon();
    iconLabel = icon != null ? new JLabel(icon) : new JLabel("TipOfTheDay24.gif");
    iconLabel.setOpaque(true);
    panel.add(iconLabel, BorderLayout.WEST);
    final JLabel lblDidYouKnow = new JLabel("    " + LanguageBundle.getString("in_tod_didyouknow"));
    FontManipulation.xxlarge(lblDidYouKnow);
    lblDidYouKnow.setOpaque(true);
    tipText = new JLabelPane();
    tipText.setBorder(null);
    tipText.setFocusable(false);
    tipText.addHyperlinkListener(new Hyperactive());
    final JScrollPane pane = new JScrollPane(tipText);
    pane.setBorder(null);
    final JPanel content = new JPanel(new BorderLayout(0, 2));
    content.add(lblDidYouKnow, BorderLayout.NORTH);
    content.add(pane, BorderLayout.CENTER);
    content.setPreferredSize(new Dimension(585, 230));
    panel.add(content, BorderLayout.CENTER);
    chkShowTips = new JCheckBox(LanguageBundle.getString("in_tod_showTips"), propertyContext.initBoolean("showTipOfTheDay", true));
    final JButton btnClose = new JButton(LanguageBundle.getString("in_close"));
    btnClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close"));
    btnClose.addActionListener(this);
    // TODO give focus to close button
    final JButton btnPrevTip = new JButton(LanguageBundle.getString("in_tod_prevTip"));
    btnPrevTip.setMnemonic(LanguageBundle.getMnemonic("in_mn_tod_prevTip"));
    btnPrevTip.addActionListener(this);
    btnPrevTip.setActionCommand(PREV);
    final JButton btnNextTip = new JButton(LanguageBundle.getString("in_tod_nextTip"));
    btnNextTip.setMnemonic(LanguageBundle.getMnemonic("in_mn_tod_nextTip"));
    btnNextTip.addActionListener(this);
    btnNextTip.setActionCommand(NEXT);
    final JPanel actions = new JPanel(new GridBagLayout());
    final GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0);
    actions.add(chkShowTips, c);
    final JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttons.add(btnPrevTip);
    buttons.add(btnNextTip);
    buttons.add(btnClose);
    c.gridx = 1;
    c.anchor = GridBagConstraints.EAST;
    actions.add(buttons, c);
    panel.add(actions, BorderLayout.SOUTH);
    setContentPane(panel);
    getRootPane().setDefaultButton(btnClose);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            quit();
        }
    });
    addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                quit();
            }
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JLabelPane(pcgen.gui2.util.JLabelPane) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) JCheckBox(javax.swing.JCheckBox) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) Hyperactive(pcgen.gui2.tools.Hyperactive) WindowEvent(java.awt.event.WindowEvent) Icon(javax.swing.Icon)

Aggregations

BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 FlowLayout (java.awt.FlowLayout)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 Icon (javax.swing.Icon)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 Hyperactive (pcgen.gui2.tools.Hyperactive)1 JLabelPane (pcgen.gui2.util.JLabelPane)1