List of usage examples for javax.swing JLayer JLayer
public JLayer(V view, LayerUI<V> ui)
From source file:Main.java
public static void main(String[] args) { JTabbedPane tab = new JTabbedPane(); tab.addTab("New tab1", new JLabel("1")); tab.addTab("New Tab2", new JLabel("2")); JPanel p = new JPanel(new BorderLayout()); p.add(new JLayer<JComponent>(tab, new TopRightCornerLabelLayerUI())); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(p);/*from ww w . ja va 2 s.c o m*/ f.setSize(320, 240); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { BoundedRangeModel model = new DefaultBoundedRangeModel(); BlockedColorLayerUI layerUI = new BlockedColorLayerUI(); JPanel p = new JPanel(new GridLayout(2, 1, 12, 12)); p.add(new JLayer<JProgressBar>(new JProgressBar(model), layerUI)); JPanel box = new JPanel(); box.add(new JButton(new AbstractAction("+10") { private int i = 0; @Override/*from w ww .j a v a 2 s .c o m*/ public void actionPerformed(ActionEvent e) { model.setValue(i = (i >= 100) ? 0 : i + 10); } })); p.repaint(); JPanel panel = new JPanel(new BorderLayout()); panel.add(p, BorderLayout.NORTH); panel.add(box, BorderLayout.SOUTH); JFrame f = new JFrame(); f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); f.getContentPane().add(panel); f.setSize(320, 240); f.setVisible(true); }
From source file:Main.java
/** * Adds a glass layer to the dialog to intercept all key events. If the * espace key is pressed, the dialog is disposed (either with a fadeout * animation, or directly).//from w w w . j a va 2 s . co m */ public static void addEscapeToCloseSupport(final JDialog dialog) { LayerUI<Container> layerUI = new LayerUI<Container>() { private boolean closing = false; @Override public void installUI(JComponent c) { super.installUI(c); ((JLayer) c).setLayerEventMask(AWTEvent.KEY_EVENT_MASK); } @Override public void uninstallUI(JComponent c) { super.uninstallUI(c); ((JLayer) c).setLayerEventMask(0); } @Override public void eventDispatched(AWTEvent e, JLayer<? extends Container> l) { if (e instanceof KeyEvent && ((KeyEvent) e).getKeyCode() == KeyEvent.VK_ESCAPE) { if (closing) { return; } closing = true; fadeOut(dialog); } } }; JLayer<Container> layer = new JLayer<Container>(dialog.getContentPane(), layerUI); dialog.setContentPane(layer); }
From source file:Main.java
/** * Adds a glass layer to the dialog to intercept all key events. If the * espace key is pressed, the dialog is disposed (either with a fadeout * animation, or directly).//from w w w.j a v a 2s. c om */ public static void addEscapeToCloseSupport(final JDialog dialog, final boolean fadeOnClose) { LayerUI<Container> layerUI = new LayerUI<Container>() { private boolean closing = false; @Override public void installUI(JComponent c) { super.installUI(c); ((JLayer) c).setLayerEventMask(AWTEvent.KEY_EVENT_MASK); } @Override public void uninstallUI(JComponent c) { super.uninstallUI(c); ((JLayer) c).setLayerEventMask(0); } @Override public void eventDispatched(AWTEvent e, JLayer<? extends Container> l) { if (e instanceof KeyEvent && ((KeyEvent) e).getKeyCode() == KeyEvent.VK_ESCAPE) { if (closing) return; closing = true; if (fadeOnClose) fadeOut(dialog); else dialog.dispose(); } } }; JLayer<Container> layer = new JLayer<>(dialog.getContentPane(), layerUI); dialog.setContentPane(layer); }
From source file:Main.java
public JComponent makeUI() { UIManager.put("TabbedPane.tabInsets", new Insets(2, 2, 2, 50)); final JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("A", new JPanel()); JPanel p = new JPanel(new BorderLayout()); p.add(new JLayer<JTabbedPane>(tabbedPane, new CloseableTabbedPaneLayerUI())); p.add(new JButton(new AbstractAction("add tab") { @Override//from w ww . jav a2 s . c o m public void actionPerformed(ActionEvent e) { tabbedPane.addTab("test", new JPanel()); } }), BorderLayout.SOUTH); return p; }
From source file:Wallpaper.java
public static void createUI() { JFrame f = new JFrame("Wallpaper"); JPanel panel = createPanel(); LayerUI<JComponent> layerUI = new WallpaperLayerUI(); JLayer<JComponent> jlayer = new JLayer<JComponent>(panel, layerUI); f.add(jlayer);//from www . j a v a 2s . c o m f.setSize(300, 200); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:Myopia.java
public static void createUI() { JFrame f = new JFrame("Myopia"); LayerUI<JComponent> layerUI = new BlurLayerUI(); JPanel panel = createPanel(); JLayer<JComponent> jlayer = new JLayer<JComponent>(panel, layerUI); f.add(jlayer);/*from w w w. ja v a2 s . c om*/ f.setSize(300, 200); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:Diva.java
public static void createUI() { JFrame f = new JFrame("Diva"); LayerUI<JPanel> layerUI = new SpotlightLayerUI(); JPanel panel = createPanel(); JLayer<JPanel> jlayer = new JLayer<JPanel>(panel, layerUI); f.add(jlayer);//from w ww .jav a2 s . com f.setSize(300, 200); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:FieldValidator.java
private static JComponent createContent() { Dimension labelSize = new Dimension(80, 20); Box box = Box.createVerticalBox(); // A single LayerUI for all the fields. LayerUI<JFormattedTextField> layerUI = new ValidationLayerUI(); // Number field. JLabel numberLabel = new JLabel("Number:"); numberLabel.setHorizontalAlignment(SwingConstants.RIGHT); numberLabel.setPreferredSize(labelSize); NumberFormat numberFormat = NumberFormat.getInstance(); JFormattedTextField numberField = new JFormattedTextField(numberFormat); numberField.setColumns(16);//from ww w. j a v a2 s.co m numberField.setFocusLostBehavior(JFormattedTextField.PERSIST); numberField.setValue(42); JPanel numberPanel = new JPanel(); numberPanel.add(numberLabel); numberPanel.add(new JLayer<JFormattedTextField>(numberField, layerUI)); // Date field. JLabel dateLabel = new JLabel("Date:"); dateLabel.setHorizontalAlignment(SwingConstants.RIGHT); dateLabel.setPreferredSize(labelSize); DateFormat dateFormat = DateFormat.getDateInstance(); JFormattedTextField dateField = new JFormattedTextField(dateFormat); dateField.setColumns(16); dateField.setFocusLostBehavior(JFormattedTextField.PERSIST); dateField.setValue(new java.util.Date()); JPanel datePanel = new JPanel(); datePanel.add(dateLabel); datePanel.add(new JLayer<JFormattedTextField>(dateField, layerUI)); // Time field. JLabel timeLabel = new JLabel("Time:"); timeLabel.setHorizontalAlignment(SwingConstants.RIGHT); timeLabel.setPreferredSize(labelSize); DateFormat timeFormat = DateFormat.getTimeInstance(); JFormattedTextField timeField = new JFormattedTextField(timeFormat); timeField.setColumns(16); timeField.setFocusLostBehavior(JFormattedTextField.PERSIST); timeField.setValue(new java.util.Date()); JPanel timePanel = new JPanel(); timePanel.add(timeLabel); timePanel.add(new JLayer<JFormattedTextField>(timeField, layerUI)); // Put them all in the box. box.add(Box.createGlue()); box.add(numberPanel); box.add(Box.createGlue()); box.add(datePanel); box.add(Box.createGlue()); box.add(timePanel); return box; }
From source file:TapTapTap.java
public void createUI() { JFrame f = new JFrame("TapTapTap"); final WaitLayerUI layerUI = new WaitLayerUI(); JPanel panel = createPanel(); JLayer<JPanel> jlayer = new JLayer<JPanel>(panel, layerUI); final Timer stopper = new Timer(4000, new ActionListener() { public void actionPerformed(ActionEvent ae) { layerUI.stop();/*from ww w . ja v a 2 s. c om*/ } }); stopper.setRepeats(false); mOrderButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { layerUI.start(); if (!stopper.isRunning()) { stopper.start(); } } }); f.add(jlayer); f.setSize(300, 200); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLocationRelativeTo(null); f.setVisible(true); }