@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(); } } }
@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); } }
@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(); } } }
private void addAnimationLengthSelector(LayerUI<JTextField> tfLayerUI, GridBagHelper gbHelper) { gbHelper.addLabelWithControl("Number of Seconds:", new JLayer<>(nrSecondsTF, tfLayerUI)); KeyListener keyListener = new KeyAdapter() { @Override public void keyReleased(KeyEvent keyEvent) { updateCalculations(); } }; nrSecondsTF.addKeyListener(keyListener); gbHelper.addLabelWithControl("Frames per Second:", new JLayer<>(fpsTF, tfLayerUI)); fpsTF.addKeyListener(keyListener); nrFramesLabel = new JLabel(); updateCalculations(); gbHelper.addLabelWithControl("Number of Frames:", nrFramesLabel); }
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!"); } } }); }
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); }
public OutputSettingsPanel() { super(new GridBagLayout()); // A single TFValidationLayerUI for all the textfields. LayerUI<JTextField> tfLayerUI = new TFValidationLayerUI(this); GridBagHelper gbHelper = new GridBagHelper(this); addOutputTypeSelector(gbHelper); addAnimationLengthSelector(tfLayerUI, gbHelper); addInterpolationSelector(gbHelper); addPingPongSelector(gbHelper); addFileSelector(tfLayerUI, gbHelper); }
private void addFileSelector(LayerUI<JTextField> tfLayerUI, GridBagHelper gbHelper) { JPanel filePanel = new JPanel(new FlowLayout()); filePanel.setBorder(BorderFactory.createTitledBorder("Output File/Folder")); fileNameTF = browseFilesSupport.getNameTF(); filePanel.add(new JLayer<>(fileNameTF, tfLayerUI)); filePanel.add(browseFilesSupport.getBrowseButton()); gbHelper.addOnlyControlToRow(filePanel, 6); }
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); f.setSize(300, 200); f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); f.setLocationRelativeTo (null); f.setVisible (true); }