use of javax.swing.border.AbstractBorder in project jdk8u_jdk by JetBrains.
the class Test4856008 method main.
public static void main(String[] args) {
for (Border border : BORDERS) {
System.out.println(border.getClass());
test(border, border.getBorderInsets(getComponent(border)));
if (border instanceof AbstractBorder) {
test((AbstractBorder) border);
}
}
}
use of javax.swing.border.AbstractBorder in project intellij-community by JetBrains.
the class CodeStyleAbstractPanel method installPreviewPanel.
protected void installPreviewPanel(final JPanel previewPanel) {
previewPanel.setLayout(new BorderLayout());
previewPanel.add(getEditor().getComponent(), BorderLayout.CENTER);
previewPanel.setBorder(new AbstractBorder() {
private static final int LEFT_WHITE_SPACE = 2;
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Editor editor = getEditor();
if (editor instanceof EditorEx) {
g.setColor(((EditorEx) editor).getBackgroundColor());
g.fillRect(x + 1, y, LEFT_WHITE_SPACE, height);
}
g.setColor(OnePixelDivider.BACKGROUND);
g.fillRect(x, y, 1, height);
}
@Override
public Insets getBorderInsets(Component c, Insets insets) {
insets.set(0, 1 + LEFT_WHITE_SPACE, 0, 0);
return insets;
}
});
}
use of javax.swing.border.AbstractBorder in project jsql-injection by ron190.
the class RendererComplexCell method getListCellRendererComponent.
@SuppressWarnings("serial")
@Override
public Component getListCellRendererComponent(JList<? extends ItemList> list, ItemList value, int index, boolean isSelected, boolean isFocused) {
JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, isFocused);
renderer.setFont(HelperUi.FONT_SEGOE);
if (isSelected) {
if (list.isFocusOwner()) {
renderer.setBackground(HelperUi.COLOR_FOCUS_GAINED);
} else {
renderer.setBackground(HelperUi.COLOR_FOCUS_LOST);
}
} else {
renderer.setBackground(Color.WHITE);
}
if (value.getIsVulnerable()) {
renderer.setForeground(HelperUi.COLOR_GREEN);
} else if (value.getIsDatabaseConfirmed()) {
renderer.setForeground(Color.BLUE);
}
if (isSelected) {
if (list.isFocusOwner()) {
renderer.setBorder(HelperUi.BORDER_FOCUS_GAINED);
} else {
renderer.setBorder(HelperUi.BORDER_FOCUS_LOST);
}
} else if (isFocused) {
renderer.setBorder(BorderFactory.createCompoundBorder(new AbstractBorder() {
@Override
public void paintBorder(Component comp, Graphics g, int x, int y, int w, int h) {
Graphics2D gg = (Graphics2D) g;
gg.setColor(Color.GRAY);
gg.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 1 }, 0));
gg.drawRect(x, y, w - 1, h - 1);
}
}, BorderFactory.createEmptyBorder(0, 1, 0, 0)));
} else {
renderer.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
}
return renderer;
}
use of javax.swing.border.AbstractBorder in project jsql-injection by ron190.
the class HelperUi method prepareGUI.
/**
* Change the default style of various components.
*/
public static void prepareGUI() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
try (InputStream fontStream = new BufferedInputStream(SwingAppender.class.getResourceAsStream("/com/jsql/view/swing/resources/font/UbuntuMono-R-ctrlchar.ttf"))) {
Font ubuntuFont = Font.createFont(Font.TRUETYPE_FONT, fontStream);
ge.registerFont(ubuntuFont);
} catch (FontFormatException | IOException e) {
LOGGER.warn("Loading Font Ubuntu Mono with control characters failed", e);
}
try (InputStream fontStream = new BufferedInputStream(SwingAppender.class.getResourceAsStream("/com/jsql/view/swing/resources/font/Ubuntu-R.ttf"))) {
Font ubuntuFont = Font.createFont(Font.TRUETYPE_FONT, fontStream);
ge.registerFont(ubuntuFont);
} catch (FontFormatException | IOException e) {
LOGGER.warn("Loading Font Ubuntu failed", e);
}
// Custom tooltip
// timer before showing tooltip
ToolTipManager.sharedInstance().setInitialDelay(750);
// timer before closing automatically tooltip
ToolTipManager.sharedInstance().setDismissDelay(30000);
// timer used when mouse move to another component, show tooltip immediately if timer is not expired
ToolTipManager.sharedInstance().setReshowDelay(1);
UIManager.put("ToolTip.background", new Color(255, 255, 225));
UIManager.put("ToolTip.backgroundInactive", new Color(255, 255, 225));
UIManager.put("ToolTip.foreground", Color.BLACK);
UIManager.put("ToolTip.foregroundInactive", Color.BLACK);
UIManager.put("ToolTip.font", HelperUi.FONT_SEGOE);
// Custom button
// Change border of button in default Save as, Confirm dialogs
UIManager.put("Button.border", HelperUi.BORDER_BLU);
UIManager.put("Button.select", new Color(155, 193, 232));
// Change border of button in Save as dialog
UIManager.put("ToggleButton.border", HelperUi.BORDER_BLU);
// No bold for menu + round corner
UIManager.put("Menu.font", HelperUi.FONT_SEGOE);
UIManager.put("Menu.selectionBackground", HelperUi.COLOR_FOCUS_GAINED);
UIManager.put("Menu.borderPainted", false);
UIManager.put("PopupMenu.font", HelperUi.FONT_SEGOE);
UIManager.put("RadioButtonMenuItem.selectionBackground", HelperUi.COLOR_FOCUS_GAINED);
UIManager.put("RadioButtonMenuItem.font", HelperUi.FONT_SEGOE);
UIManager.put("RadioButtonMenuItem.borderPainted", false);
UIManager.put("MenuItem.selectionBackground", HelperUi.COLOR_FOCUS_GAINED);
UIManager.put("MenuItem.font", HelperUi.FONT_SEGOE);
UIManager.put("MenuItem.borderPainted", false);
UIManager.put("MenuItem.disabledAreNavigable", Boolean.TRUE);
UIManager.put("CheckBoxMenuItem.selectionBackground", HelperUi.COLOR_FOCUS_GAINED);
UIManager.put("CheckBoxMenuItem.font", HelperUi.FONT_SEGOE);
UIManager.put("CheckBoxMenuItem.borderPainted", false);
UIManager.put("CheckBoxMenuItem.checkIcon", new CheckBoxIcon());
// Custom tab
UIManager.put("TabbedPane.contentAreaColor", HelperUi.FONT_UBUNTU_MONO);
UIManager.put("TabbedPane.font", HelperUi.FONT_SEGOE);
// margin of current tab panel
UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));
// margin above tabs
UIManager.put("TabbedPane.tabAreaInsets", new Insets(3, 2, 0, 2));
// margin around tab name
UIManager.put("TabbedPane.tabInsets", new Insets(2, 3 + 5, 2, 3));
// lighter unselected tab border
UIManager.put("TabbedPane.darkShadow", new Color(190, 198, 205));
UIManager.put("Button.font", HelperUi.FONT_SEGOE);
UIManager.put("CheckBox.font", HelperUi.FONT_SEGOE);
UIManager.put("RadioButton.font", HelperUi.FONT_SEGOE);
UIManager.put("TitledBorder.font", HelperUi.FONT_SEGOE);
UIManager.put("Spinner.arrowButtonBorder", HelperUi.BORDER_BLU);
UIManager.put("Spinner.border", BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(HelperUi.COLOR_BLU), BorderFactory.createMatteBorder(2, 2, 2, 2, Color.WHITE)));
UIManager.put("FileChooser.listFont", HelperUi.FONT_SEGOE);
UIManager.put("FileChooser.listViewBorder", BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(HelperUi.COLOR_BLU), BorderFactory.createMatteBorder(2, 2, 2, 2, Color.WHITE)));
// Custom text component
// Admin page
UIManager.put("TextPane.selectionBackground", HelperUi.COLOR_FOCUS_GAINED);
UIManager.put("TextPane.font", HelperUi.FONT_UBUNTU_MONO);
UIManager.put("TextPane.selectionBackground", HelperUi.COLOR_FOCUS_GAINED);
UIManager.put("TextField.border", HelperUi.BORDER_BLU);
UIManager.put("TextField.selectionBackground", HelperUi.COLOR_FOCUS_GAINED);
UIManager.put("EditorPane.selectionBackground", HelperUi.COLOR_FOCUS_GAINED);
UIManager.put("TextArea.selectionBackground", HelperUi.COLOR_FOCUS_GAINED);
UIManager.put("TextArea.font", HelperUi.FONT_UBUNTU_MONO);
// Custom Label
UIManager.put("Label.font", HelperUi.FONT_SEGOE);
UIManager.put("Label.selectionBackground", HelperUi.COLOR_FOCUS_GAINED);
// Custom table
UIManager.put("Table.font", HelperUi.FONT_SEGOE);
UIManager.put("TableHeader.font", HelperUi.FONT_SEGOE);
UIManager.put("Table.selectionBackground", HelperUi.COLOR_FOCUS_GAINED);
UIManager.put("Table.focusCellHighlightBorder", BorderFactory.createCompoundBorder(new AbstractBorder() {
@Override
public void paintBorder(Component comp, Graphics g, int x, int y, int w, int h) {
Graphics2D gg = (Graphics2D) g;
gg.setColor(Color.GRAY);
gg.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 1 }, 0));
// Fix #42291: InternalError on drawRect()
try {
gg.drawRect(x, y, w - 1, h - 1);
} catch (InternalError e) {
LOGGER.error(e, e);
}
}
}, BorderFactory.createEmptyBorder(0, 1, 0, 0)));
// Custom tree
UIManager.put("Tree.expandedIcon", new ImageIcon(HelperUi.class.getResource("/com/jsql/view/swing/resources/images/icons/expanded.png")));
UIManager.put("Tree.collapsedIcon", new ImageIcon(HelperUi.class.getResource("/com/jsql/view/swing/resources/images/icons/collapsed.png")));
UIManager.put("Tree.lineTypeDashed", true);
// No default icon for tree nodes
UIManager.put("Tree.leafIcon", new ImageIcon());
UIManager.put("Tree.openIcon", new ImageIcon());
UIManager.put("Tree.closedIcon", new ImageIcon());
// Custom progress bar
UIManager.put("ProgressBar.border", BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(3, 0, 4, 0), BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.GRAY), BorderFactory.createLineBorder(Color.WHITE))));
UIManager.put("ProgressBar.foreground", new Color(136, 183, 104));
UIManager.put("ProgressBar.background", UIManager.get("Tree.background"));
// Custom ComboBox
UIManager.put("ComboBox.font", HelperUi.FONT_SEGOE);
UIManager.put("ComboBox.selectionBackground", HelperUi.COLOR_FOCUS_GAINED);
// Use ColorUIResource to preserve the background color for arrow
UIManager.put("ComboBox.background", new ColorUIResource(Color.WHITE));
UIManager.put("ComboBox.border", HelperUi.BORDER_BLU);
UIManager.put("ComboBoxUI", CustomBasicComboBoxUI.class.getName());
UIManager.put("swing.boldMetal", Boolean.FALSE);
UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);
}
use of javax.swing.border.AbstractBorder in project cayenne by apache.
the class OSXPlatformInitializer method overrideUIDefaults.
private void overrideUIDefaults() {
Color lightGrey = new Color(0xEEEEEE);
Color darkGrey = new Color(225, 225, 225);
Border darkBorder = BorderFactory.createLineBorder(darkGrey);
UIManager.put("ToolBarSeparatorUI", OSXToolBarSeparatorUI.class.getName());
UIManager.put("PanelUI", OSXPanelUI.class.getName());
// next two is custom made for Cayenne's MainToolBar
UIManager.put("MainToolBar.background", UIManager.get("ToolBar.background"));
UIManager.put("MainToolBar.border", BorderFactory.createEmptyBorder(0, 7, 0, 7));
UIManager.put("ToolBar.background", lightGrey);
UIManager.put("ToolBar.border", darkBorder);
UIManager.put("ScrollPane.border", darkBorder);
UIManager.put("Table.scrollPaneBorder", darkBorder);
UIManager.put("SplitPane.border", BorderFactory.createEmptyBorder());
UIManager.put("SplitPane.background", darkGrey);
UIManager.put("Tree.rendererFillBackground", Boolean.TRUE);
UIManager.put("ComboBox.background", Color.WHITE);
UIManager.put("ComboBox.selectionBackground", darkGrey);
UIManager.put("ComboBox.selectionForeground", Color.BLACK);
UIManager.put("Tree.selectionForeground", Color.BLACK);
UIManager.put("Tree.selectionBackground", lightGrey);
UIManager.put("Tree.selectionBorderColor", lightGrey);
UIManager.put("Table.selectionForeground", Color.BLACK);
UIManager.put("Table.selectionBackground", lightGrey);
UIManager.put("Table.focusCellHighlightBorder", BorderFactory.createEmptyBorder());
// MacOS BigSur needs additional style tweaking for the tabs active state
OSXVersion version = OSXVersion.fromSystemProperties();
if (version.gt(OSXVersion.CATALINA)) {
UIManager.put("TabbedPane.selectedTabTitlePressedColor", Color.BLACK);
UIManager.put("TabbedPane.selectedTabTitleNormalColor", Color.BLACK);
UIManager.put("TabbedPane.selectedTabTitleShadowDisabledColor", new Color(0, 0, 0, 0));
UIManager.put("TabbedPane.selectedTabTitleShadowNormalColor", new Color(0, 0, 0, 0));
}
Border backgroundPainter = new AbstractBorder() {
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
g.setColor(lightGrey);
g.fillRect(0, 0, width - 1, height - 1);
}
};
UIManager.put("MenuItem.selectedBackgroundPainter", backgroundPainter);
UIManager.put("MenuItem.selectionForeground", Color.BLACK);
}
Aggregations