Example usage for javax.swing JSplitPane setUI

List of usage examples for javax.swing JSplitPane setUI

Introduction

In this page you can find the example usage for javax.swing JSplitPane setUI.

Prototype

public void setUI(SplitPaneUI ui) 

Source Link

Document

Sets the L&F object that renders this component.

Usage

From source file:Main.java

public static void flattenSplitPane(JSplitPane jSplitPane) {
    UIDefaults defaults = javax.swing.UIManager.getDefaults();
    final Color light = defaults.getColor("SplitPane.highlight");
    final Color dark = defaults.getColor("SplitPane.darkShadow");

    // *//w w w . j  a  v a2  s . c om
    jSplitPane.setUI(new BasicSplitPaneUI() {
        public BasicSplitPaneDivider createDefaultDivider() {
            BasicSplitPaneDivider divider = new BasicSplitPaneDivider(this) {
                private static final long serialVersionUID = 1L;

                @Override
                public int getDividerSize() {
                    return 5;
                }

                @Override
                public void paint(Graphics g) {
                    // super.paint(g);
                    int orientation = this.getBasicSplitPaneUI().getOrientation();

                    Dimension size = this.getSize();

                    if (orientation == JSplitPane.VERTICAL_SPLIT) {
                        int[] lines = new int[2];
                        lines[0] = 0;
                        lines[1] = size.height - 2;

                        for (int i = 0; i < size.width; i += 4) {
                            for (int j = 0; j < lines.length; j++) {
                                int y = lines[j];
                                g.setColor(light);
                                g.fillRect(i, y, 2, 2);
                                g.setColor(dark);
                                g.fillRect(i, y, 1, 1);
                            }
                        }
                    } else {
                        int[] rows = new int[2];
                        rows[0] = 0;
                        rows[1] = size.width - 2;

                        for (int i = 0; i < size.height; i += 4) {
                            for (int j = 0; j < rows.length; j++) {
                                int x = rows[j];
                                g.setColor(light);
                                g.fillRect(x, i, 2, 2);
                                g.setColor(dark);
                                g.fillRect(x, i, 1, 1);
                            }
                        }
                    }
                }
            };
            return divider;
        }
    });
    jSplitPane.setBorder(null);
    // */
}

From source file:com.clank.launcher.swing.SwingHelper.java

public static void flattenJSplitPane(JSplitPane splitPane) {
    splitPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    BasicSplitPaneUI flatDividerSplitPaneUI = new BasicSplitPaneUI() {
        @Override// w  w  w  .  j  a v  a  2s .co m
        public BasicSplitPaneDivider createDefaultDivider() {
            return new BasicSplitPaneDivider(this) {
                @Override
                public void setBorder(Border b) {
                }
            };
        }
    };
    splitPane.setUI(flatDividerSplitPaneUI);
    splitPane.setBorder(null);
}

From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java

private void customiseJSplitPaneLookAndFeel(JSplitPane splitPane) {

    BasicSplitPaneUI paneUI = new BasicSplitPaneUI() {
        @Override/*from  w  w  w.ja va2 s  .  c o  m*/
        public BasicSplitPaneDivider createDefaultDivider() {
            return new CustomSplitPaneDivider(this);
        }
    };

    splitPane.setUI(paneUI);
    splitPane.setBackground(UIHelper.BG_COLOR);

    splitPane.setBorder(new EmptyBorder(1, 1, 10, 1));
}