Search in sources :

Example 1 with CheckBoxIcon

use of com.jsql.view.swing.ui.CheckBoxIcon 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);
}
Also used : BasicStroke(java.awt.BasicStroke) ImageIcon(javax.swing.ImageIcon) Insets(java.awt.Insets) CheckBoxIcon(com.jsql.view.swing.ui.CheckBoxIcon) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) Color(java.awt.Color) IOException(java.io.IOException) GraphicsEnvironment(java.awt.GraphicsEnvironment) FontFormatException(java.awt.FontFormatException) ColorUIResource(javax.swing.plaf.ColorUIResource) Font(java.awt.Font) AbstractBorder(javax.swing.border.AbstractBorder) Graphics2D(java.awt.Graphics2D) Graphics(java.awt.Graphics) BufferedInputStream(java.io.BufferedInputStream) Component(java.awt.Component) CustomBasicComboBoxUI(com.jsql.view.swing.ui.CustomBasicComboBoxUI) SwingAppender(com.jsql.view.swing.console.SwingAppender)

Aggregations

SwingAppender (com.jsql.view.swing.console.SwingAppender)1 CheckBoxIcon (com.jsql.view.swing.ui.CheckBoxIcon)1 CustomBasicComboBoxUI (com.jsql.view.swing.ui.CustomBasicComboBoxUI)1 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 Component (java.awt.Component)1 Font (java.awt.Font)1 FontFormatException (java.awt.FontFormatException)1 Graphics (java.awt.Graphics)1 Graphics2D (java.awt.Graphics2D)1 GraphicsEnvironment (java.awt.GraphicsEnvironment)1 Insets (java.awt.Insets)1 BufferedInputStream (java.io.BufferedInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ImageIcon (javax.swing.ImageIcon)1 AbstractBorder (javax.swing.border.AbstractBorder)1 ColorUIResource (javax.swing.plaf.ColorUIResource)1