use of javax.swing.plaf.ColorUIResource 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.plaf.ColorUIResource in project Botnak by Gocnak.
the class AbstractTheme method setUpColor.
public void setUpColor() {
windowDecoration = true;
macStyleWindowDecoration = JTattooUtilities.isMac();
linuxStyleScrollBar = !JTattooUtilities.isWindows();
dynamicLayout = true;
textShadow = false;
textAntiAliasing = false;
textAntiAliasingMode = TEXT_ANTIALIAS_HRGB;
backgroundPattern = true;
brightMode = false;
showFocusFrame = false;
drawSquareButtons = false;
toolbarDecorated = true;
menuOpaque = true;
menuAlpha = 0.9f;
logoString = "";
controlFont = null;
systemFont = null;
userFont = null;
smallFont = null;
menuFont = null;
windowTitleFont = null;
foregroundColor = black;
backgroundColor = extraLightGray;
backgroundColorLight = white;
backgroundColorDark = extraLightGray;
alterBackgroundColor = lightGray;
disabledForegroundColor = gray;
disabledBackgroundColor = superLightGray;
inputBackgroundColor = white;
inputForegroundColor = black;
selectionForegroundColor = black;
selectionBackgroundColor = lightGray;
selectionBackgroundColorLight = extraLightGray;
selectionBackgroundColorDark = lightGray;
focusColor = orange;
focusCellColor = orange;
focusFrameColor = new ColorUIResource(230, 191, 116);
focusBackgroundColor = new ColorUIResource(255, 250, 212);
focusForegroundColor = black;
frameColor = darkGray;
gridColor = gray;
shadowColor = new ColorUIResource(0, 24, 0);
rolloverForegroundColor = black;
rolloverColor = extraLightGray;
rolloverColorLight = white;
rolloverColorDark = extraLightGray;
pressedForegroundColor = black;
buttonForegroundColor = black;
buttonBackgroundColor = lightGray;
buttonColorLight = white;
buttonColorDark = lightGray;
controlForegroundColor = black;
controlBackgroundColor = lightGray;
controlHighlightColor = white;
controlShadowColor = lightGray;
controlDarkShadowColor = darkGray;
controlColorLight = white;
controlColorDark = lightGray;
windowTitleForegroundColor = black;
windowTitleBackgroundColor = blue;
windowTitleColorLight = extraLightGray;
windowTitleColorDark = lightGray;
windowBorderColor = lightGray;
windowIconColor = black;
windowIconShadowColor = white;
windowIconRolloverColor = red;
windowInactiveTitleForegroundColor = black;
windowInactiveTitleBackgroundColor = extraLightGray;
windowInactiveTitleColorLight = white;
windowInactiveTitleColorDark = extraLightGray;
windowInactiveBorderColor = extraLightGray;
menuForegroundColor = black;
menuBackgroundColor = extraLightGray;
menuSelectionForegroundColor = black;
menuSelectionBackgroundColor = lightGray;
menuSelectionBackgroundColorLight = extraLightGray;
menuSelectionBackgroundColorDark = lightGray;
menuColorLight = extraLightGray;
menuColorDark = lightGray;
toolbarForegroundColor = black;
toolbarBackgroundColor = lightGray;
toolbarColorLight = white;
toolbarColorDark = lightGray;
tabAreaBackgroundColor = backgroundColor;
tabSelectionForegroundColor = selectionForegroundColor;
desktopColor = darkBlue;
tooltipForegroundColor = black;
tooltipBackgroundColor = yellow;
tooltipBorderSize = 6;
tooltipShadowSize = 6;
tooltipCastShadow = false;
textureSet = "Default";
darkTexture = true;
}
use of javax.swing.plaf.ColorUIResource in project Botnak by Gocnak.
the class GraphiteDefaultTheme method setUpColor.
public void setUpColor() {
super.setUpColor();
// showFocusFrame = true;
foregroundColor = black;
backgroundColor = new ColorUIResource(224, 224, 224);
backgroundColorLight = white;
backgroundColorDark = lightGray;
alterBackgroundColor = new ColorUIResource(220, 220, 220);
disabledForegroundColor = new ColorUIResource(128, 128, 128);
disabledBackgroundColor = new ColorUIResource(240, 240, 240);
inputBackgroundColor = white;
inputForegroundColor = black;
selectionForegroundColor = white;
selectionBackgroundColor = new ColorUIResource(80, 80, 80);
selectionBackgroundColorLight = new ColorUIResource(96, 96, 96);
selectionBackgroundColorDark = new ColorUIResource(64, 64, 64);
focusColor = orange;
focusCellColor = orange;
frameColor = new ColorUIResource(144, 144, 144);
gridColor = new ColorUIResource(200, 200, 200);
rolloverColor = orange;
rolloverColorLight = new ColorUIResource(255, 213, 113);
rolloverColorDark = new ColorUIResource(240, 168, 0);
buttonForegroundColor = black;
buttonBackgroundColor = extraLightGray;
buttonColorLight = white;
buttonColorDark = extraLightGray;
controlForegroundColor = black;
controlBackgroundColor = extraLightGray;
controlShadowColor = new ColorUIResource(164, 164, 164);
controlDarkShadowColor = new ColorUIResource(64, 64, 64);
controlColorLight = new ColorUIResource(96, 96, 96);
controlColorDark = new ColorUIResource(40, 40, 40);
windowTitleForegroundColor = white;
windowTitleBackgroundColor = gray;
windowTitleColorLight = new ColorUIResource(88, 88, 88);
windowTitleColorDark = new ColorUIResource(24, 24, 24);
windowBorderColor = black;
windowIconColor = white;
windowIconShadowColor = black;
windowIconRolloverColor = orange;
windowInactiveTitleForegroundColor = white;
windowInactiveTitleBackgroundColor = new ColorUIResource(224, 224, 224);
windowInactiveTitleColorLight = new ColorUIResource(64, 64, 64);
windowInactiveTitleColorDark = new ColorUIResource(0, 0, 0);
windowInactiveBorderColor = black;
menuForegroundColor = black;
menuBackgroundColor = new ColorUIResource(240, 240, 240);
menuSelectionForegroundColor = black;
menuSelectionBackgroundColor = new ColorUIResource(32, 32, 32);
menuSelectionBackgroundColorLight = new ColorUIResource(255, 213, 113);
menuSelectionBackgroundColorDark = new ColorUIResource(240, 168, 0);
menuColorLight = new ColorUIResource(240, 240, 240);
menuColorDark = new ColorUIResource(220, 220, 220);
toolbarForegroundColor = black;
toolbarBackgroundColor = backgroundColor;
toolbarColorLight = menuColorLight;
toolbarColorDark = menuColorDark;
tabAreaBackgroundColor = backgroundColor;
tabSelectionForegroundColor = white;
desktopColor = backgroundColor;
tooltipForegroundColor = black;
tooltipBackgroundColor = yellow;
controlFont = new FontUIResource("Dialog", Font.PLAIN, 13);
systemFont = new FontUIResource("Dialog", Font.PLAIN, 13);
userFont = new FontUIResource("Dialog", Font.PLAIN, 13);
smallFont = new FontUIResource("Dialog", Font.PLAIN, 12);
menuFont = new FontUIResource("Dialog", Font.PLAIN, 13);
windowTitleFont = new FontUIResource("Dialog", Font.BOLD, 13);
}
use of javax.swing.plaf.ColorUIResource in project java-swing-tips by aterai.
the class MainPanel method makeTable.
public static JTable makeTable(TableModel model) {
return new JTable(model) {
@Override
public void updateUI() {
// [JDK-6788475] Changing to Nimbus LAF and back doesn't reset look and feel of JTable completely - Java Bug System
// https://bugs.openjdk.java.net/browse/JDK-6788475
// XXX: set dummy ColorUIResource
setSelectionForeground(new ColorUIResource(Color.RED));
setSelectionBackground(new ColorUIResource(Color.RED));
super.updateUI();
TableModel m = getModel();
for (int i = 0; i < m.getColumnCount(); i++) {
TableCellRenderer r = getDefaultRenderer(m.getColumnClass(i));
if (r instanceof Component) {
SwingUtilities.updateComponentTreeUI((Component) r);
}
}
}
@Override
public Component prepareEditor(TableCellEditor editor, int row, int column) {
Component cmp = super.prepareEditor(editor, row, column);
if (convertColumnIndexToModel(column) == BOOLEAN_COLUMN) {
// System.out.println("JTable: prepareEditor");
JCheckBox c = (JCheckBox) cmp;
c.setBackground(c.isSelected() ? Color.ORANGE : getBackground());
}
return cmp;
}
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component c = super.prepareRenderer(renderer, row, column);
boolean isChecked = (boolean) model.getValueAt(convertRowIndexToModel(row), BOOLEAN_COLUMN);
c.setForeground(getForeground());
c.setBackground(isChecked ? Color.ORANGE : getBackground());
return c;
}
};
}
use of javax.swing.plaf.ColorUIResource in project java-swing-tips by aterai.
the class FileListTable method updateUI.
@Override
public void updateUI() {
// [JDK-6788475]
// Changing to Nimbus LAF and back doesn't reset look and feel of JTable completely
// https://bugs.openjdk.java.net/browse/JDK-6788475
// XXX: set dummy ColorUIResource
setSelectionForeground(new ColorUIResource(Color.RED));
setSelectionBackground(new ColorUIResource(Color.RED));
removeMouseMotionListener(rbl);
removeMouseListener(rbl);
setDefaultRenderer(Object.class, null);
super.updateUI();
rbl = new RubberBandingListener();
addMouseMotionListener(rbl);
addMouseListener(rbl);
putClientProperty("Table.isFileList", Boolean.TRUE);
setCellSelectionEnabled(true);
setIntercellSpacing(new Dimension());
setShowGrid(false);
setAutoCreateRowSorter(true);
setFillsViewportHeight(true);
TableCellRenderer r = new DefaultTableCellRenderer();
setDefaultRenderer(Object.class, (table, value, isSelected, hasFocus, row, column) -> r.getTableCellRendererComponent(table, value, false, false, row, column));
TableColumn col = getColumnModel().getColumn(0);
col.setCellRenderer(new FileNameRenderer(this));
col.setPreferredWidth(200);
col = getColumnModel().getColumn(1);
col.setPreferredWidth(300);
}
Aggregations