Java Code Examples for javax.swing.plaf.LayerUI

The following examples show how to use javax.swing.plaf.LayerUI. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk8u-dev-jdk   Source File: JLayer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void eventDispatched(AWTEvent event) {
    Object source = event.getSource();
    if (source instanceof Component) {
        Component component = (Component) source;
        while (component != null) {
            if (component instanceof JLayer) {
                JLayer l = (JLayer) component;
                LayerUI ui = l.getUI();
                if (ui != null &&
                        isEventEnabled(l.getLayerEventMask(), event.getID()) &&
                        (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) {
                    ui.eventDispatched(event, l);
                }
            }
            component = component.getParent();
        }
    }
}
 
Example 2
Source Project: jdk1.8-source-analysis   Source File: JLayer.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void eventDispatched(AWTEvent event) {
    Object source = event.getSource();
    if (source instanceof Component) {
        Component component = (Component) source;
        while (component != null) {
            if (component instanceof JLayer) {
                JLayer l = (JLayer) component;
                LayerUI ui = l.getUI();
                if (ui != null &&
                        isEventEnabled(l.getLayerEventMask(), event.getID()) &&
                        (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) {
                    ui.eventDispatched(event, l);
                }
            }
            component = component.getParent();
        }
    }
}
 
Example 3
Source Project: dragonwell8_jdk   Source File: JLayer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void eventDispatched(AWTEvent event) {
    Object source = event.getSource();
    if (source instanceof Component) {
        Component component = (Component) source;
        while (component != null) {
            if (component instanceof JLayer) {
                JLayer l = (JLayer) component;
                LayerUI ui = l.getUI();
                if (ui != null &&
                        isEventEnabled(l.getLayerEventMask(), event.getID()) &&
                        (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) {
                    ui.eventDispatched(event, l);
                }
            }
            component = component.getParent();
        }
    }
}
 
Example 4
Source Project: jdk8u_jdk   Source File: JLayer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void eventDispatched(AWTEvent event) {
    Object source = event.getSource();
    if (source instanceof Component) {
        Component component = (Component) source;
        while (component != null) {
            if (component instanceof JLayer) {
                JLayer l = (JLayer) component;
                LayerUI ui = l.getUI();
                if (ui != null &&
                        isEventEnabled(l.getLayerEventMask(), event.getID()) &&
                        (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) {
                    ui.eventDispatched(event, l);
                }
            }
            component = component.getParent();
        }
    }
}
 
Example 5
Source Project: openjdk-jdk8u-backup   Source File: JLayer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void eventDispatched(AWTEvent event) {
    Object source = event.getSource();
    if (source instanceof Component) {
        Component component = (Component) source;
        while (component != null) {
            if (component instanceof JLayer) {
                JLayer l = (JLayer) component;
                LayerUI ui = l.getUI();
                if (ui != null &&
                        isEventEnabled(l.getLayerEventMask(), event.getID()) &&
                        (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) {
                    ui.eventDispatched(event, l);
                }
            }
            component = component.getParent();
        }
    }
}
 
Example 6
Source Project: openjdk-8   Source File: JLayer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void eventDispatched(AWTEvent event) {
    Object source = event.getSource();
    if (source instanceof Component) {
        Component component = (Component) source;
        while (component != null) {
            if (component instanceof JLayer) {
                JLayer l = (JLayer) component;
                LayerUI ui = l.getUI();
                if (ui != null &&
                        isEventEnabled(l.getLayerEventMask(), event.getID()) &&
                        (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) {
                    ui.eventDispatched(event, l);
                }
            }
            component = component.getParent();
        }
    }
}
 
Example 7
Source Project: Bytecoder   Source File: JLayer.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream s)
        throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField f = s.readFields();

    view = (V) f.get("view", null);
    glassPane = (JPanel) f.get("glassPane", null);
    eventMask = f.get("eventMask", 0l);
    if (eventMask != 0) {
        eventController.updateAWTEventListener(0, eventMask);
    }
    LayerUI<V> newLayerUI = (LayerUI<V>) f.get("layerUI", null);
    if (newLayerUI != null) {
        setUI(newLayerUI);
    }
}
 
Example 8
Source Project: openjdk-jdk9   Source File: JLayer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream s)
        throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField f = s.readFields();

    view = (V) f.get("view", null);
    glassPane = (JPanel) f.get("glassPane", null);
    eventMask = f.get("eventMask", 0l);
    if (eventMask != 0) {
        eventController.updateAWTEventListener(0, eventMask);
    }
    LayerUI<V> newLayerUI = (LayerUI<V>) f.get("layerUI", null);
    if (newLayerUI != null) {
        setUI(newLayerUI);
    }
}
 
Example 9
Source Project: openjdk-jdk9   Source File: JLayer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked", "rawtypes"})
public void eventDispatched(AWTEvent event) {
    Object source = event.getSource();
    if (source instanceof Component) {
        Component component = (Component) source;
        while (component != null) {
            if (component instanceof JLayer) {
                JLayer l = (JLayer) component;
                LayerUI<?> ui = l.getUI();
                if (ui != null &&
                        isEventEnabled(l.getLayerEventMask(), event.getID()) &&
                        (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) {
                    ui.eventDispatched(event, l);
                }
            }
            component = component.getParent();
        }
    }
}
 
Example 10
public TweenOutputSettingsPanel() {
    super(new GridBagLayout());

    numSecondsTF.setName("numSecondsTF");
    fpsTF.setName("fpsTF");
    numFramesLabel.setName("numFramesLabel");

    // A single TFValidationLayerUI for all the textfields.
    LayerUI<JTextField> tfLayerUI = new TFValidationLayerUI(this);

    var gbh = new GridBagHelper(this);

    addOutputTypeSelector(gbh);
    addAnimationLengthSelector(tfLayerUI, gbh);
    addInterpolationSelector(gbh);
    addPingPongSelector(gbh);
    addFileSelector(tfLayerUI, gbh);
}
 
Example 11
private void addAnimationLengthSelector(LayerUI<JTextField> tfLayerUI,
                                        GridBagHelper gbh) {
    gbh.addLabelAndControl("Number of Seconds:",
            new JLayer<>(numSecondsTF, tfLayerUI));

    KeyListener keyListener = new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent keyEvent) {
            updateCalculations();
        }
    };
    numSecondsTF.addKeyListener(keyListener);

    gbh.addLabelAndControl("Frames per Second:",
            new JLayer<>(fpsTF, tfLayerUI));
    fpsTF.addKeyListener(keyListener);

    updateCalculations();
    gbh.addLabelAndControl("Number of Frames:", numFramesLabel);
}
 
Example 12
Source Project: openjdk-8-source   Source File: JLayer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void eventDispatched(AWTEvent event) {
    Object source = event.getSource();
    if (source instanceof Component) {
        Component component = (Component) source;
        while (component != null) {
            if (component instanceof JLayer) {
                JLayer l = (JLayer) component;
                LayerUI ui = l.getUI();
                if (ui != null &&
                        isEventEnabled(l.getLayerEventMask(), event.getID()) &&
                        (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) {
                    ui.eventDispatched(event, l);
                }
            }
            component = component.getParent();
        }
    }
}
 
Example 13
Source Project: Java8CN   Source File: JLayer.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void eventDispatched(AWTEvent event) {
    Object source = event.getSource();
    if (source instanceof Component) {
        Component component = (Component) source;
        while (component != null) {
            if (component instanceof JLayer) {
                JLayer l = (JLayer) component;
                LayerUI ui = l.getUI();
                if (ui != null &&
                        isEventEnabled(l.getLayerEventMask(), event.getID()) &&
                        (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) {
                    ui.eventDispatched(event, l);
                }
            }
            component = component.getParent();
        }
    }
}
 
Example 14
Source Project: jdk8u-jdk   Source File: JLayer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void eventDispatched(AWTEvent event) {
    Object source = event.getSource();
    if (source instanceof Component) {
        Component component = (Component) source;
        while (component != null) {
            if (component instanceof JLayer) {
                JLayer l = (JLayer) component;
                LayerUI ui = l.getUI();
                if (ui != null &&
                        isEventEnabled(l.getLayerEventMask(), event.getID()) &&
                        (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) {
                    ui.eventDispatched(event, l);
                }
            }
            component = component.getParent();
        }
    }
}
 
Example 15
Source Project: dragonwell8_jdk   Source File: bug7068740.java    License: GNU General Public License v2.0 5 votes vote down vote up
bug7068740() {
    super();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    DefaultTableModel model = new DefaultTableModel() {
        @Override
        public int getRowCount() {
            return 20;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            return "(" + row + "," + column + ")";
        }
    };

    table = new JTable(model);
    table.setRowSelectionInterval(0, 0);
    LayerUI<JComponent> layerUI = new LayerUI<>();
    JLayer<JComponent> layer = new JLayer<>(table, layerUI);
    JScrollPane scrollPane = new JScrollPane(layer);
    add(scrollPane);
    pack();
    setLocationRelativeTo(null);
}
 
Example 16
Source Project: openjdk-8   Source File: bug7068740.java    License: GNU General Public License v2.0 5 votes vote down vote up
bug7068740() {
    super();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    DefaultTableModel model = new DefaultTableModel() {
        @Override
        public int getRowCount() {
            return 20;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            return "(" + row + "," + column + ")";
        }
    };

    table = new JTable(model);
    table.setRowSelectionInterval(0, 0);
    LayerUI<JComponent> layerUI = new LayerUI<>();
    JLayer<JComponent> layer = new JLayer<>(table, layerUI);
    JScrollPane scrollPane = new JScrollPane(layer);
    add(scrollPane);
    pack();
    setLocationRelativeTo(null);
}
 
Example 17
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 5 votes vote down vote up
private static void createAndShowGui() {
  try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
    ex.printStackTrace();
    Toolkit.getDefaultToolkit().beep();
  }
  TabTransferHandler handler = new TabTransferHandler();
  JCheckBoxMenuItem check = new JCheckBoxMenuItem("Ghost image: Heavyweight");
  check.addActionListener(e -> {
    JCheckBoxMenuItem c = (JCheckBoxMenuItem) e.getSource();
    handler.setDragImageMode(c.isSelected() ? DragImageMode.HEAVYWEIGHT : DragImageMode.LIGHTWEIGHT);
  });
  JMenu menu = new JMenu("Debug");
  menu.add(check);
  JMenuBar menuBar = new JMenuBar();
  menuBar.add(menu);

  LayerUI<DnDTabbedPane> layerUI = new DropLocationLayerUI();
  JFrame frame = new JFrame("@[email protected]");
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.getContentPane().add(new MainPanel(handler, layerUI));
  frame.setJMenuBar(menuBar);
  frame.pack();
  frame.setLocationRelativeTo(null);

  Point pt = frame.getLocation();
  pt.translate(360, 60);

  JFrame sub = new JFrame("sub");
  sub.getContentPane().add(new MainPanel(handler, layerUI));
  sub.pack();
  sub.setLocation(pt);

  frame.setVisible(true);
  sub.setVisible(true);
}
 
Example 18
Source Project: TencentKona-8   Source File: bug6824395.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            JFrame frame = new JFrame("testing");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            JEditorPane editorPane = new JEditorPane();
            String str = "hello\n";
            for(int i = 0; i<5; i++) {
                str += str;
            }

            editorPane.setText(str);

            JLayer<JEditorPane> editorPaneLayer = new JLayer<JEditorPane>(editorPane);
            LayerUI<JComponent> layerUI = new LayerUI<JComponent>();
            editorPaneLayer.setUI(layerUI);

            scrollPane = new JScrollPane(editorPaneLayer);

            scrollPane.setPreferredSize(new Dimension(200, 250));
            frame.add(scrollPane);

            frame.setSize(200, 200);
            frame.pack();
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
                throw new RuntimeException("Wrong component's width!");
            }
        }
    });
}
 
Example 19
Source Project: TencentKona-8   Source File: bug7068740.java    License: GNU General Public License v2.0 5 votes vote down vote up
bug7068740() {
    super();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    DefaultTableModel model = new DefaultTableModel() {
        @Override
        public int getRowCount() {
            return 20;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            return "(" + row + "," + column + ")";
        }
    };

    table = new JTable(model);
    table.setRowSelectionInterval(0, 0);
    LayerUI<JComponent> layerUI = new LayerUI<>();
    JLayer<JComponent> layer = new JLayer<>(table, layerUI);
    JScrollPane scrollPane = new JScrollPane(layer);
    add(scrollPane);
    pack();
    setLocationRelativeTo(null);
}
 
Example 20
Source Project: jdk8u60   Source File: bug6824395.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            JFrame frame = new JFrame("testing");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            JEditorPane editorPane = new JEditorPane();
            String str = "hello\n";
            for(int i = 0; i<5; i++) {
                str += str;
            }

            editorPane.setText(str);

            JLayer<JEditorPane> editorPaneLayer = new JLayer<JEditorPane>(editorPane);
            LayerUI<JComponent> layerUI = new LayerUI<JComponent>();
            editorPaneLayer.setUI(layerUI);

            scrollPane = new JScrollPane(editorPaneLayer);

            scrollPane.setPreferredSize(new Dimension(200, 250));
            frame.add(scrollPane);

            frame.setSize(200, 200);
            frame.pack();
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
                throw new RuntimeException("Wrong component's width!");
            }
        }
    });
}
 
Example 21
Source Project: jdk8u-jdk   Source File: bug6824395.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            JFrame frame = new JFrame("testing");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            JEditorPane editorPane = new JEditorPane();
            String str = "hello\n";
            for(int i = 0; i<5; i++) {
                str += str;
            }

            editorPane.setText(str);

            JLayer<JEditorPane> editorPaneLayer = new JLayer<JEditorPane>(editorPane);
            LayerUI<JComponent> layerUI = new LayerUI<JComponent>();
            editorPaneLayer.setUI(layerUI);

            scrollPane = new JScrollPane(editorPaneLayer);

            scrollPane.setPreferredSize(new Dimension(200, 250));
            frame.add(scrollPane);

            frame.setSize(200, 200);
            frame.pack();
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
                throw new RuntimeException("Wrong component's width!");
            }
        }
    });
}
 
Example 22
Source Project: openjdk-jdk8u   Source File: bug6824395.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            JFrame frame = new JFrame("testing");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            JEditorPane editorPane = new JEditorPane();
            String str = "hello\n";
            for(int i = 0; i<5; i++) {
                str += str;
            }

            editorPane.setText(str);

            JLayer<JEditorPane> editorPaneLayer = new JLayer<JEditorPane>(editorPane);
            LayerUI<JComponent> layerUI = new LayerUI<JComponent>();
            editorPaneLayer.setUI(layerUI);

            scrollPane = new JScrollPane(editorPaneLayer);

            scrollPane.setPreferredSize(new Dimension(200, 250));
            frame.add(scrollPane);

            frame.setSize(200, 200);
            frame.pack();
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
                throw new RuntimeException("Wrong component's width!");
            }
        }
    });
}
 
Example 23
Source Project: openjdk-jdk8u   Source File: bug7068740.java    License: GNU General Public License v2.0 5 votes vote down vote up
bug7068740() {
    super();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    DefaultTableModel model = new DefaultTableModel() {
        @Override
        public int getRowCount() {
            return 20;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            return "(" + row + "," + column + ")";
        }
    };

    table = new JTable(model);
    table.setRowSelectionInterval(0, 0);
    LayerUI<JComponent> layerUI = new LayerUI<>();
    JLayer<JComponent> layer = new JLayer<>(table, layerUI);
    JScrollPane scrollPane = new JScrollPane(layer);
    add(scrollPane);
    pack();
    setLocationRelativeTo(null);
}
 
Example 24
Source Project: jdk8u_jdk   Source File: bug7068740.java    License: GNU General Public License v2.0 5 votes vote down vote up
bug7068740() {
    super();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    DefaultTableModel model = new DefaultTableModel() {
        @Override
        public int getRowCount() {
            return 20;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            return "(" + row + "," + column + ")";
        }
    };

    table = new JTable(model);
    table.setRowSelectionInterval(0, 0);
    LayerUI<JComponent> layerUI = new LayerUI<>();
    JLayer<JComponent> layer = new JLayer<>(table, layerUI);
    JScrollPane scrollPane = new JScrollPane(layer);
    add(scrollPane);
    pack();
    setLocationRelativeTo(null);
}
 
Example 25
bug7068740() {
    super();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    DefaultTableModel model = new DefaultTableModel() {
        @Override
        public int getRowCount() {
            return 20;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            return "(" + row + "," + column + ")";
        }
    };

    table = new JTable(model);
    table.setRowSelectionInterval(0, 0);
    LayerUI<JComponent> layerUI = new LayerUI<>();
    JLayer<JComponent> layer = new JLayer<>(table, layerUI);
    JScrollPane scrollPane = new JScrollPane(layer);
    add(scrollPane);
    pack();
    setLocationRelativeTo(null);
}
 
Example 26
Source Project: openjdk-8-source   Source File: bug7068740.java    License: GNU General Public License v2.0 5 votes vote down vote up
bug7068740() {
    super();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    DefaultTableModel model = new DefaultTableModel() {
        @Override
        public int getRowCount() {
            return 20;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            return "(" + row + "," + column + ")";
        }
    };

    table = new JTable(model);
    table.setRowSelectionInterval(0, 0);
    LayerUI<JComponent> layerUI = new LayerUI<>();
    JLayer<JComponent> layer = new JLayer<>(table, layerUI);
    JScrollPane scrollPane = new JScrollPane(layer);
    add(scrollPane);
    pack();
    setLocationRelativeTo(null);
}
 
Example 27
Source Project: jdk8u-dev-jdk   Source File: bug6824395.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            JFrame frame = new JFrame("testing");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            JEditorPane editorPane = new JEditorPane();
            String str = "hello\n";
            for(int i = 0; i<5; i++) {
                str += str;
            }

            editorPane.setText(str);

            JLayer<JEditorPane> editorPaneLayer = new JLayer<JEditorPane>(editorPane);
            LayerUI<JComponent> layerUI = new LayerUI<JComponent>();
            editorPaneLayer.setUI(layerUI);

            scrollPane = new JScrollPane(editorPaneLayer);

            scrollPane.setPreferredSize(new Dimension(200, 250));
            frame.add(scrollPane);

            frame.setSize(200, 200);
            frame.pack();
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
                throw new RuntimeException("Wrong component's width!");
            }
        }
    });
}
 
Example 28
Source Project: jdk8u-jdk   Source File: bug6824395.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            JFrame frame = new JFrame("testing");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            JEditorPane editorPane = new JEditorPane();
            String str = "hello\n";
            for(int i = 0; i<5; i++) {
                str += str;
            }

            editorPane.setText(str);

            JLayer<JEditorPane> editorPaneLayer = new JLayer<JEditorPane>(editorPane);
            LayerUI<JComponent> layerUI = new LayerUI<JComponent>();
            editorPaneLayer.setUI(layerUI);

            scrollPane = new JScrollPane(editorPaneLayer);

            scrollPane.setPreferredSize(new Dimension(200, 250));
            frame.add(scrollPane);

            frame.setSize(200, 200);
            frame.pack();
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
                throw new RuntimeException("Wrong component's width!");
            }
        }
    });
}
 
Example 29
Source Project: jdk8u-jdk   Source File: bug7068740.java    License: GNU General Public License v2.0 5 votes vote down vote up
bug7068740() {
    super();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    DefaultTableModel model = new DefaultTableModel() {
        @Override
        public int getRowCount() {
            return 20;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            return "(" + row + "," + column + ")";
        }
    };

    table = new JTable(model);
    table.setRowSelectionInterval(0, 0);
    LayerUI<JComponent> layerUI = new LayerUI<>();
    JLayer<JComponent> layer = new JLayer<>(table, layerUI);
    JScrollPane scrollPane = new JScrollPane(layer);
    add(scrollPane);
    pack();
    setLocationRelativeTo(null);
}
 
Example 30
Source Project: jdk8u_jdk   Source File: bug6824395.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            JFrame frame = new JFrame("testing");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            JEditorPane editorPane = new JEditorPane();
            String str = "hello\n";
            for(int i = 0; i<5; i++) {
                str += str;
            }

            editorPane.setText(str);

            JLayer<JEditorPane> editorPaneLayer = new JLayer<JEditorPane>(editorPane);
            LayerUI<JComponent> layerUI = new LayerUI<JComponent>();
            editorPaneLayer.setUI(layerUI);

            scrollPane = new JScrollPane(editorPaneLayer);

            scrollPane.setPreferredSize(new Dimension(200, 250));
            frame.add(scrollPane);

            frame.setSize(200, 200);
            frame.pack();
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
                throw new RuntimeException("Wrong component's width!");
            }
        }
    });
}