Search in sources :

Example 11 with Border

use of javax.swing.border.Border in project pcgen by PCGen.

the class SummaryInfoTab method highlightBorder.

private void highlightBorder(final JComponent comp) {
    final Border oldBorder = comp.getBorder();
    Border highlightBorder = BorderFactory.createLineBorder(Color.GREEN, 3);
    comp.setBorder(highlightBorder);
    SwingUtilities.invokeLater(() -> {
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
        // Ignored as we'll exit shortly anyway.
        }
        comp.setBorder(oldBorder);
    });
}
Also used : Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder)

Example 12 with Border

use of javax.swing.border.Border in project pcgen by PCGen.

the class CharacterStatsPanel method initComponents.

/**
	 * Build and initialise the user interface.
	 */
private void initComponents() {
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    JLabel label;
    ButtonGroup exclusiveGroup;
    Border etched = null;
    TitledBorder title1 = BorderFactory.createTitledBorder(etched, in_abilities);
    title1.setTitleJustification(TitledBorder.LEFT);
    this.setBorder(title1);
    this.setLayout(gridbag);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(2, 2, 2, 2);
    final GameMode gameMode = SettingsHandler.getGame();
    int row = 0;
    exclusiveGroup = new ButtonGroup();
    Utility.buildConstraints(c, 0, row++, 3, 1, 0, 0);
    label = new JLabel(LanguageBundle.getFormattedString("in_Prefs_abilitiesGenLabel", //$NON-NLS-1$
    gameMode.getDisplayName()));
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 0, row, 1, 1, 0, 0);
    label = new JLabel("  ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
    abilitiesUserRolledButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesUserRolled"));
    gridbag.setConstraints(abilitiesUserRolledButton, c);
    this.add(abilitiesUserRolledButton);
    exclusiveGroup.add(abilitiesUserRolledButton);
    Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
    abilitiesAllSameButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesAllSame") + ": ");
    gridbag.setConstraints(abilitiesAllSameButton, c);
    this.add(abilitiesAllSameButton);
    exclusiveGroup.add(abilitiesAllSameButton);
    Utility.buildConstraints(c, 1, row, 1, 1, 0, 0);
    label = new JLabel("  ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
    abilityScoreCombo = new JComboBoxEx();
    for (int i = gameMode.getStatMin(); i <= gameMode.getStatMax(); ++i) {
        abilityScoreCombo.addItem(String.valueOf(i));
    }
    gridbag.setConstraints(abilityScoreCombo, c);
    this.add(abilityScoreCombo);
    ReferenceManufacturer<RollMethod> mfg = gameMode.getModeContext().getReferenceContext().getManufacturer(RollMethod.class);
    List<RollMethod> rollMethods = mfg.getOrderSortedObjects();
    if (!rollMethods.isEmpty()) {
        Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
        abilitiesRolledButton = new JRadioButton("Rolled:");
        gridbag.setConstraints(abilitiesRolledButton, c);
        this.add(abilitiesRolledButton);
        exclusiveGroup.add(abilitiesRolledButton);
        Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
        abilityRolledModeCombo = new JComboBoxEx();
        for (RollMethod rm : rollMethods) {
            abilityRolledModeCombo.addItem(rm.getDisplayName());
        }
        gridbag.setConstraints(abilityRolledModeCombo, c);
        this.add(abilityRolledModeCombo);
    }
    Collection<PointBuyMethod> methods = SettingsHandler.getGame().getModeContext().getReferenceContext().getConstructedCDOMObjects(PointBuyMethod.class);
    final int purchaseMethodCount = methods.size();
    Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
    abilitiesPurchasedButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesPurchased") + ": ");
    gridbag.setConstraints(abilitiesPurchasedButton, c);
    this.add(abilitiesPurchasedButton);
    exclusiveGroup.add(abilitiesPurchasedButton);
    Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
    pMode = new String[purchaseMethodCount];
    pModeMethodName = new String[purchaseMethodCount];
    int i = 0;
    for (PointBuyMethod pbm : methods) {
        pMode[i] = pbm.getDescription();
        pModeMethodName[i] = pbm.getDisplayName();
        i++;
    }
    abilityPurchaseModeCombo = new JComboBoxEx(pMode);
    gridbag.setConstraints(abilityPurchaseModeCombo, c);
    this.add(abilityPurchaseModeCombo);
    //
    if (purchaseMethodCount == 0) {
        abilityPurchaseModeCombo.setVisible(false);
        abilitiesPurchasedButton.setVisible(false);
    }
    Utility.buildConstraints(c, 1, row++, 1, 1, 0, 0);
    label = new JLabel(" ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 1, row++, 3, 1, 0, 0);
    JButton purchaseModeButton = new JButton(LanguageBundle.getString("in_Prefs_purchaseModeConfig"));
    gridbag.setConstraints(purchaseModeButton, c);
    this.add(purchaseModeButton);
    purchaseModeButton.addActionListener(new PurchaseModeButtonListener());
    Utility.buildConstraints(c, 5, 20, 1, 1, 1, 1);
    c.fill = GridBagConstraints.BOTH;
    label = new JLabel(" ");
    gridbag.setConstraints(label, c);
    this.add(label);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) RollMethod(pcgen.cdom.content.RollMethod) GridBagLayout(java.awt.GridBagLayout) PointBuyMethod(pcgen.core.PointBuyMethod) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder) GameMode(pcgen.core.GameMode) ButtonGroup(javax.swing.ButtonGroup) JComboBoxEx(pcgen.gui2.util.JComboBoxEx) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder)

Example 13 with Border

use of javax.swing.border.Border in project pcgen by PCGen.

the class Utils method buildFloatField.

/**
	 * <p>Builds a formatted text field with specified min and max</p>
	 * 
	 * @param min minimum value
	 * @param max maximum value
	 * @return JFormattedTextField
	 */
public static JFormattedTextField buildFloatField(float min, float max) {
    java.text.NumberFormat numberFormat = java.text.NumberFormat.getNumberInstance();
    // numberFormat.setParseIntegerOnly(false);
    NumberFormatter formatter = new NumberFormatter(numberFormat);
    //formatter.getCommitsOnValidEdit();
    formatter.setMinimum(min);
    formatter.setMaximum(max);
    final JFormattedTextField returnValue = new JFormattedTextField(formatter);
    returnValue.setColumns(4);
    returnValue.addPropertyChangeListener(new PropertyChangeListener() {

        Border m_originalBorder = returnValue.getBorder();

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName() != null && evt.getPropertyName().equals("editValid")) {
                if (evt.getNewValue() != null && evt.getNewValue() instanceof Boolean) {
                    if (((Boolean) evt.getNewValue()).booleanValue()) {
                        returnValue.setBorder(m_originalBorder);
                    } else {
                        returnValue.setBorder(BorderFactory.createLineBorder(Color.red));
                    }
                }
            }
        }
    });
    return returnValue;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) JFormattedTextField(javax.swing.JFormattedTextField) Border(javax.swing.border.Border) NumberFormatter(javax.swing.text.NumberFormatter)

Example 14 with Border

use of javax.swing.border.Border in project intellij-community by JetBrains.

the class DebuggerTreeBase method createToolTip.

@Nullable
public JComponent createToolTip(MouseEvent e) {
    final DebuggerTreeNodeImpl node = getNodeToShowTip(e);
    if (node == null) {
        return null;
    }
    if (myCurrentTooltip != null && myCurrentTooltip.isShowing() && myCurrentTooltipNode == node) {
        return myCurrentTooltip;
    }
    myCurrentTooltipNode = node;
    final String toolTipText = getTipText(node);
    if (toolTipText == null) {
        return null;
    }
    final JComponent tipContent = createTipContent(toolTipText, node);
    final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(tipContent);
    scrollPane.setBorder(null);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    final Point point = e.getPoint();
    SwingUtilities.convertPointToScreen(point, e.getComponent());
    Rectangle tipRectangle = new Rectangle(point, tipContent.getPreferredSize());
    final Rectangle screen = ScreenUtil.getScreenRectangle(point.x, point.y);
    final JToolTip toolTip = new JToolTip();
    tipContent.addMouseListener(new HideTooltip(toolTip));
    final Border tooltipBorder = toolTip.getBorder();
    if (tooltipBorder != null) {
        final Insets borderInsets = tooltipBorder.getBorderInsets(this);
        tipRectangle.setSize(tipRectangle.width + borderInsets.left + borderInsets.right, tipRectangle.height + borderInsets.top + borderInsets.bottom);
    }
    toolTip.setLayout(new BorderLayout());
    toolTip.add(scrollPane, BorderLayout.CENTER);
    tipRectangle.height += scrollPane.getHorizontalScrollBar().getPreferredSize().height;
    tipRectangle.width += scrollPane.getVerticalScrollBar().getPreferredSize().width;
    final int maxWidth = (int) (screen.width - screen.width * .25);
    if (tipRectangle.width > maxWidth) {
        tipRectangle.width = maxWidth;
    }
    final Dimension prefSize = tipRectangle.getSize();
    ScreenUtil.cropRectangleToFitTheScreen(tipRectangle);
    if (prefSize.width > tipRectangle.width) {
        final int delta = prefSize.width - tipRectangle.width;
        tipRectangle.x -= delta;
        if (tipRectangle.x < screen.x) {
            tipRectangle.x = screen.x + maxWidth / 2;
            tipRectangle.width = screen.width - maxWidth / 2;
        } else {
            tipRectangle.width += delta;
        }
    }
    toolTip.setPreferredSize(tipRectangle.getSize());
    myCurrentTooltip = toolTip;
    return myCurrentTooltip;
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) Border(javax.swing.border.Border) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with Border

use of javax.swing.border.Border in project intellij-community by JetBrains.

the class DebuggerSteppingConfigurable method getComponent.

@Override
@NotNull
public JComponent getComponent() {
    final JPanel panel = new JPanel(new GridBagLayout());
    myCbSkipSyntheticMethods = new JCheckBox(DebuggerBundle.message("label.debugger.general.configurable.skip.synthetic.methods"));
    myCbSkipConstructors = new JCheckBox(DebuggerBundle.message("label.debugger.general.configurable.skip.constructors"));
    myCbSkipClassLoaders = new JCheckBox(DebuggerBundle.message("label.debugger.general.configurable.skip.classLoaders"));
    myCbSkipSimpleGetters = new JCheckBox(DebuggerBundle.message("label.debugger.general.configurable.skip.simple.getters"));
    myCbStepInfoFiltersEnabled = new JCheckBox(DebuggerBundle.message("label.debugger.general.configurable.step.filters.list.header"));
    panel.add(myCbSkipSyntheticMethods, new GridBagConstraints(0, RELATIVE, 1, 1, 1.0, 0.0, WEST, NONE, JBUI.emptyInsets(), 0, 0));
    panel.add(myCbSkipConstructors, new GridBagConstraints(0, RELATIVE, 1, 1, 1.0, 0.0, WEST, NONE, JBUI.emptyInsets(), 0, 0));
    panel.add(myCbSkipClassLoaders, new GridBagConstraints(0, RELATIVE, 1, 1, 1.0, 0.0, WEST, NONE, JBUI.emptyInsets(), 0, 0));
    panel.add(myCbSkipSimpleGetters, new GridBagConstraints(0, RELATIVE, 1, 1, 1.0, 0.0, WEST, NONE, JBUI.emptyInsets(), 0, 0));
    panel.add(myCbStepInfoFiltersEnabled, new GridBagConstraints(0, RELATIVE, 1, 1, 1.0, 0.0, WEST, NONE, JBUI.insetsTop(8), 0, 0));
    mySteppingFilterEditor = new ClassFilterEditor(JavaDebuggerSupport.getContextProjectForEditorFieldsInDebuggerConfigurables(), null, "reference.viewBreakpoints.classFilters.newPattern");
    panel.add(mySteppingFilterEditor, new GridBagConstraints(0, RELATIVE, 1, 1, 1.0, 1.0, CENTER, BOTH, JBUI.insetsLeft(5), 0, 0));
    myCbStepInfoFiltersEnabled.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            mySteppingFilterEditor.setEnabled(myCbStepInfoFiltersEnabled.isSelected());
        }
    });
    myRbEvaluateFinallyAlways = new JRadioButton(DebuggerBundle.message("label.debugger.general.configurable.evaluate.finally.always"));
    myRbEvaluateFinallyNever = new JRadioButton(DebuggerBundle.message("label.debugger.general.configurable.evaluate.finally.never"));
    myRbEvaluateFinallyAsk = new JRadioButton(DebuggerBundle.message("label.debugger.general.configurable.evaluate.finally.ask"));
    int cbLeftOffset = 0;
    final Border border = myCbSkipSimpleGetters.getBorder();
    if (border != null) {
        final Insets insets = border.getBorderInsets(myCbSkipSimpleGetters);
        if (insets != null) {
            cbLeftOffset = insets.left;
        }
    }
    final ButtonGroup group = new ButtonGroup();
    group.add(myRbEvaluateFinallyAlways);
    group.add(myRbEvaluateFinallyNever);
    group.add(myRbEvaluateFinallyAsk);
    final Box box = Box.createHorizontalBox();
    box.add(myRbEvaluateFinallyAlways);
    box.add(myRbEvaluateFinallyNever);
    box.add(myRbEvaluateFinallyAsk);
    final JPanel evalFinallyPanel = new JPanel(new BorderLayout());
    evalFinallyPanel.add(box, BorderLayout.CENTER);
    evalFinallyPanel.add(new JLabel(DebuggerBundle.message("label.debugger.general.configurable.evaluate.finally.on.pop")), BorderLayout.WEST);
    panel.add(evalFinallyPanel, new GridBagConstraints(0, RELATIVE, 1, 1, 1.0, 0.0, NORTHWEST, NONE, new Insets(4, cbLeftOffset, 0, 0), 0, 0));
    myCbResumeOnlyCurrentThread = new JCheckBox(DebuggerBundle.message("label.debugger.general.configurable.resume.only.current.thread"));
    panel.add(myCbResumeOnlyCurrentThread, new GridBagConstraints(0, RELATIVE, 1, 1, 1.0, 0.0, WEST, NONE, new Insets(0, 0, 0, 0), 0, 0));
    return panel;
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) ActionEvent(java.awt.event.ActionEvent) ClassFilterEditor(com.intellij.ui.classFilter.ClassFilterEditor) ActionListener(java.awt.event.ActionListener) Border(javax.swing.border.Border) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Border (javax.swing.border.Border)169 JPanel (javax.swing.JPanel)40 EmptyBorder (javax.swing.border.EmptyBorder)35 BoxLayout (javax.swing.BoxLayout)28 JLabel (javax.swing.JLabel)28 FlowLayout (java.awt.FlowLayout)24 Dimension (java.awt.Dimension)23 JScrollPane (javax.swing.JScrollPane)22 JButton (javax.swing.JButton)19 Container (java.awt.Container)18 CompoundBorder (javax.swing.border.CompoundBorder)17 BorderLayout (java.awt.BorderLayout)16 Insets (java.awt.Insets)16 ActionEvent (java.awt.event.ActionEvent)16 TitledBorder (javax.swing.border.TitledBorder)16 UIResource (javax.swing.plaf.UIResource)16 JTable (javax.swing.JTable)14 ActionListener (java.awt.event.ActionListener)13 LineBorder (javax.swing.border.LineBorder)13 TableColumnModel (javax.swing.table.TableColumnModel)13