类javax.swing.plaf.LayerUI源码实例Demo

下面列出了怎么用javax.swing.plaf.LayerUI的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk8u-dev-jdk   文件: JLayer.java
@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();
        }
    }
}
 
源代码2 项目: jdk1.8-source-analysis   文件: JLayer.java
@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();
        }
    }
}
 
源代码3 项目: dragonwell8_jdk   文件: JLayer.java
@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();
        }
    }
}
 
源代码4 项目: jdk8u_jdk   文件: JLayer.java
@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();
        }
    }
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: JLayer.java
@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();
        }
    }
}
 
源代码6 项目: openjdk-8   文件: JLayer.java
@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();
        }
    }
}
 
源代码7 项目: Bytecoder   文件: JLayer.java
@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);
    }
}
 
源代码8 项目: openjdk-jdk9   文件: JLayer.java
@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);
    }
}
 
源代码9 项目: openjdk-jdk9   文件: JLayer.java
@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();
        }
    }
}
 
源代码10 项目: Pixelitor   文件: TweenOutputSettingsPanel.java
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);
}
 
源代码11 项目: Pixelitor   文件: TweenOutputSettingsPanel.java
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);
}
 
源代码12 项目: openjdk-8-source   文件: JLayer.java
@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();
        }
    }
}
 
源代码13 项目: Java8CN   文件: JLayer.java
@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();
        }
    }
}
 
源代码14 项目: jdk8u-jdk   文件: JLayer.java
@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();
        }
    }
}
 
源代码15 项目: dragonwell8_jdk   文件: bug7068740.java
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);
}
 
源代码16 项目: openjdk-8   文件: bug7068740.java
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);
}
 
源代码17 项目: java-swing-tips   文件: MainPanel.java
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);
}
 
源代码18 项目: TencentKona-8   文件: bug6824395.java
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!");
            }
        }
    });
}
 
源代码19 项目: TencentKona-8   文件: bug7068740.java
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);
}
 
源代码20 项目: jdk8u60   文件: bug6824395.java
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!");
            }
        }
    });
}
 
源代码21 项目: jdk8u-jdk   文件: bug6824395.java
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!");
            }
        }
    });
}
 
源代码22 项目: openjdk-jdk8u   文件: bug6824395.java
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!");
            }
        }
    });
}
 
源代码23 项目: openjdk-jdk8u   文件: bug7068740.java
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);
}
 
源代码24 项目: jdk8u_jdk   文件: bug7068740.java
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);
}
 
源代码25 项目: openjdk-jdk8u-backup   文件: bug7068740.java
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);
}
 
源代码26 项目: openjdk-8-source   文件: bug7068740.java
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);
}
 
源代码27 项目: jdk8u-dev-jdk   文件: bug6824395.java
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!");
            }
        }
    });
}
 
源代码28 项目: jdk8u-jdk   文件: bug6824395.java
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!");
            }
        }
    });
}
 
源代码29 项目: jdk8u-jdk   文件: bug7068740.java
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);
}
 
源代码30 项目: jdk8u_jdk   文件: bug6824395.java
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!");
            }
        }
    });
}
 
 类所在包
 类方法
 同包方法