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);
});
}
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);
}
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;
}
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;
}
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;
}
Aggregations