javax.swing.plaf.LayerUI Java Examples
The following examples show how to use
javax.swing.plaf.LayerUI.
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 File: JLayer.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@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 File: JLayer.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@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 File: JLayer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@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 File: TweenOutputSettingsPanel.java From Pixelitor with GNU General Public License v3.0 | 6 votes |
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 #5
Source File: TweenOutputSettingsPanel.java From Pixelitor with GNU General Public License v3.0 | 6 votes |
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 #6
Source File: JLayer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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 #7
Source File: JLayer.java From Java8CN with Apache License 2.0 | 6 votes |
@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 #8
Source File: JLayer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@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 #9
Source File: JLayer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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 #10
Source File: JLayer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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 #11
Source File: JLayer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@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 #12
Source File: JLayer.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
@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 File: JLayer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@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 File: JLayer.java From Bytecoder with Apache License 2.0 | 6 votes |
@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 #15
Source File: bug7068740.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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 File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
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("@title@"); 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 #17
Source File: bug6824395.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 #18
Source File: bug6824395.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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 File: bug7068740.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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 File: bug6824395.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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 File: bug6824395.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 File: bug6824395.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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 File: bug7068740.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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 File: bug6824395.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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 #25
Source File: bug6824395.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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 #26
Source File: bug7068740.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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 File: bug7068740.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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 #28
Source File: bug7068740.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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 #29
Source File: bug6824395.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 #30
Source File: bug7068740.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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); }