use of javax.swing.border.Border in project jdk8u_jdk by JetBrains.
the class AquaButtonUI method getPreferredSize.
public Dimension getPreferredSize(final JComponent c) {
final AbstractButton b = (AbstractButton) c;
// fix for Radar #3134273
final Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b, b.getIconTextGap());
if (d == null)
return null;
final Border border = b.getBorder();
if (border instanceof AquaButtonBorder) {
((AquaButtonBorder) border).alterPreferredSize(d);
}
return d;
}
use of javax.swing.border.Border in project jdk8u_jdk by JetBrains.
the class AquaButtonUI method paint.
// Paint Methods
public void paint(final Graphics g, final JComponent c) {
final AbstractButton b = (AbstractButton) c;
final ButtonModel model = b.getModel();
final Insets i = c.getInsets();
Rectangle viewRect = new Rectangle(b.getWidth(), b.getHeight());
Rectangle iconRect = new Rectangle();
Rectangle textRect = new Rectangle();
// a darkening effect. How can we avoid it. Try clear rect?
if (b.isOpaque()) {
g.setColor(c.getBackground());
g.fillRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
}
AquaButtonBorder aquaBorder = null;
if (((AbstractButton) c).isBorderPainted()) {
final Border border = c.getBorder();
if (border instanceof AquaButtonBorder) {
// only do this if borders are on!
// this also takes care of focus painting.
aquaBorder = (AquaButtonBorder) border;
aquaBorder.paintButton(c, g, viewRect.x, viewRect.y, viewRect.width, viewRect.height);
}
} else {
if (b.isOpaque()) {
viewRect.x = i.left - 2;
viewRect.y = i.top - 2;
viewRect.width = b.getWidth() - (i.right + viewRect.x) + 4;
viewRect.height = b.getHeight() - (i.bottom + viewRect.y) + 4;
if (b.isContentAreaFilled() || model.isSelected()) {
if (// Toggle buttons
model.isSelected())
g.setColor(c.getBackground().darker());
else
g.setColor(c.getBackground());
g.fillRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
}
}
// for now we don't know exactly what to do...we'll see!
if (b.isFocusPainted() && b.hasFocus()) {
// paint UI specific focus
paintFocus(g, b, viewRect, textRect, iconRect);
}
}
// performs icon and text rect calculations
final String text = layoutAndGetText(g, b, aquaBorder, i, viewRect, iconRect, textRect);
// Paint the Icon
if (b.getIcon() != null) {
paintIcon(g, b, iconRect);
}
if (textRect.width == 0) {
textRect.width = 50;
}
if (text != null && !text.equals("")) {
final View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
v.paint(g, textRect);
} else {
paintText(g, b, textRect, text);
}
}
}
use of javax.swing.border.Border in project jdk8u_jdk by JetBrains.
the class AquaButtonUI method installDefaults.
protected void installDefaults(final AbstractButton b) {
// load shared instance defaults
final String pp = getPropertyPrefix();
if (!defaults_initialized) {
defaultDisabledTextColor = UIManager.getColor(pp + "disabledText");
defaults_initialized = true;
}
setButtonMarginIfNeeded(b, UIManager.getInsets(pp + "margin"));
LookAndFeel.installColorsAndFont(b, pp + "background", pp + "foreground", pp + "font");
LookAndFeel.installProperty(b, "opaque", UIManager.getBoolean(pp + "opaque"));
final Object borderProp = b.getClientProperty(BUTTON_TYPE);
boolean hasBorder = false;
if (borderProp != null) {
hasBorder = setButtonType(b, borderProp);
}
if (!hasBorder)
setThemeBorder(b);
final Object segmentProp = b.getClientProperty(SEGMENTED_BUTTON_POSITION);
if (segmentProp != null) {
final Border border = b.getBorder();
if (!(border instanceof AquaBorder))
return;
b.setBorder(AquaButtonExtendedTypes.getBorderForPosition(b, b.getClientProperty(BUTTON_TYPE), segmentProp));
}
}
use of javax.swing.border.Border in project jdk8u_jdk by JetBrains.
the class AquaButtonLabeledUI method setThemeBorder.
protected void setThemeBorder(final AbstractButton b) {
super.setThemeBorder(b);
Border border = b.getBorder();
if (border == null || border instanceof UIResource) {
// Set the correct border
b.setBorder(AquaButtonBorder.getBevelButtonBorder());
}
}
use of javax.swing.border.Border in project jdk8u_jdk by JetBrains.
the class LaunchTool method configureAndConnect.
private void configureAndConnect(final Connector connector) {
final JDialog dialog = new JDialog();
final Map<String, Connector.Argument> args = connector.defaultArguments();
dialog.setModal(true);
dialog.setTitle("Connector Arguments");
Container content = dialog.getContentPane();
JPanel guts = new JPanel();
Border etched = BorderFactory.createEtchedBorder();
BorderFactory.createTitledBorder(etched, connector.description(), TitledBorder.LEFT, TitledBorder.TOP);
guts.setBorder(etched);
guts.setLayout(new BoxLayout(guts, BoxLayout.Y_AXIS));
// guts.add(new JLabel(connector.description()));
final List<ArgRep> argReps = new ArrayList<ArgRep>(args.size());
for (Connector.Argument arg : args.values()) {
ArgRep ar;
if (arg instanceof Connector.BooleanArgument) {
ar = new BooleanArgRep((Connector.BooleanArgument) arg, guts);
} else {
ar = new StringArgRep(arg, guts);
}
argReps.add(ar);
}
content.add(guts);
JPanel buttonPanel = okCancel(dialog, new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
for (ArgRep ar : argReps) {
if (!ar.isSpecified()) {
JOptionPane.showMessageDialog(dialog, ar.arg.label() + ": Argument must be specified", "No argument", JOptionPane.ERROR_MESSAGE);
return;
}
if (!ar.isValid()) {
JOptionPane.showMessageDialog(dialog, ar.arg.label() + ": Bad argument value: " + ar.getText(), "Bad argument", JOptionPane.ERROR_MESSAGE);
return;
}
ar.install();
}
try {
if (runtime.explictStart(connector, args)) {
dialog.setVisible(false);
dialog.dispose();
} else {
JOptionPane.showMessageDialog(dialog, "Bad arguments values: See diagnostics window.", "Bad arguments", JOptionPane.ERROR_MESSAGE);
}
} catch (VMLaunchFailureException exc) {
JOptionPane.showMessageDialog(dialog, "Launch Failure: " + exc, "Launch Failed", JOptionPane.ERROR_MESSAGE);
}
}
});
content.add(BorderLayout.SOUTH, buttonPanel);
dialog.pack();
dialog.setVisible(true);
}
Aggregations