Search in sources :

Example 6 with JLayeredPane

use of javax.swing.JLayeredPane in project opennars by opennars.

the class PropertyUtils method createWindow.

public static PropertySheetDialog createWindow(Window parent, boolean editable, final PropertySheetPanel psp, String title) {
    final PropertySheetDialog propertySheetDialog;
    if (parent instanceof Dialog) {
        Dialog pDialog = (Dialog) parent;
        propertySheetDialog = new PropertySheetDialog(pDialog);
    } else if (parent instanceof Frame) {
        Frame pFrame = (Frame) parent;
        propertySheetDialog = new PropertySheetDialog(pFrame);
    } else {
        propertySheetDialog = new PropertySheetDialog() {

            private static final long serialVersionUID = 1L;

            @Override
            public void ok() {
                if (psp.getTable().getEditorComponent() != null)
                    psp.getTable().commitEditing();
                super.ok();
            }
        };
    }
    if (editable) {
        propertySheetDialog.setDialogMode(PropertySheetDialog.OK_CANCEL_DIALOG);
    } else {
        propertySheetDialog.setDialogMode(PropertySheetDialog.CLOSE_DIALOG);
    }
    int sb = 1;
    for (Component compL0 : propertySheetDialog.getRootPane().getComponents()) {
        if (compL0 instanceof JLayeredPane) {
            for (Component compL01 : ((JLayeredPane) compL0).getComponents()) {
                if (!(compL01 instanceof JPanel))
                    continue;
                for (Component compL1 : ((JPanel) compL01).getComponents()) {
                    if (compL1 instanceof BannerPanel)
                        continue;
                    if (compL1 instanceof JPanel) {
                        for (Component compL2 : ((JPanel) compL1).getComponents()) {
                            for (Component compL3 : ((JPanel) compL2).getComponents()) {
                                if (compL3 instanceof JButton) {
                                    if (propertySheetDialog.getDialogMode() == PropertySheetDialog.OK_CANCEL_DIALOG && sb == 1) {
                                        ((JButton) compL3).setText("OK");
                                        sb--;
                                    } else if (propertySheetDialog.getDialogMode() == PropertySheetDialog.CLOSE_DIALOG || sb == 0) {
                                        ((JButton) compL3).setText(propertySheetDialog.getDialogMode() == PropertySheetDialog.CLOSE_DIALOG ? "Close" : "Cancel");
                                        sb--;
                                        break;
                                    }
                                    if (sb < 0)
                                        break;
                                }
                            }
                            if (sb < 0)
                                break;
                        }
                    }
                }
            }
        }
    }
    if (title != null) {
        propertySheetDialog.getBanner().setTitle(title);
        propertySheetDialog.setTitle(title);
    }
    // propertySheetDialog.setIconImage(ImageUtils.getImage("images/menus/settings.png"));
    // propertySheetDialog.getBanner().setIcon(ImageUtils.getIcon("images/settings.png"));
    propertySheetDialog.getContentPane().add(psp);
    propertySheetDialog.pack();
    propertySheetDialog.setLocationRelativeTo(null);
    propertySheetDialog.setModalityType(ModalityType.DOCUMENT_MODAL);
    return propertySheetDialog;
}
Also used : JPanel(javax.swing.JPanel) Frame(java.awt.Frame) PropertySheetDialog(automenta.vivisect.swing.property.propertysheet.PropertySheetDialog) Dialog(java.awt.Dialog) JLayeredPane(javax.swing.JLayeredPane) JButton(javax.swing.JButton) Component(java.awt.Component) BannerPanel(automenta.vivisect.swing.property.swing.BannerPanel) PropertySheetDialog(automenta.vivisect.swing.property.propertysheet.PropertySheetDialog)

Example 7 with JLayeredPane

use of javax.swing.JLayeredPane in project com.revolsys.open by revolsys.

the class MouseOverlay method getOverlays.

private List<Component> getOverlays() {
    final List<Component> overlays = new ArrayList<>();
    final Container parent = getParent();
    if (parent instanceof JLayeredPane) {
        final JLayeredPane layeredPane = (JLayeredPane) parent;
        for (final Component component : layeredPane.getComponents()) {
            if (component.isEnabled() && !(component instanceof MouseOverlay)) {
                overlays.add(component);
            }
        }
    }
    return overlays;
}
Also used : Container(java.awt.Container) JLayeredPane(javax.swing.JLayeredPane) ArrayList(java.util.ArrayList) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Example 8 with JLayeredPane

use of javax.swing.JLayeredPane in project Lejos by arqetype.

the class Brick method createBrick.

private void createBrick() {
    JLayeredPane layer = new JLayeredPane();
    layer.setPreferredSize(new Dimension(340, 512));
    layer.add(new Ev3Backdrop(), JLayeredPane.DEFAULT_LAYER);
    layer.add(scherm, new Integer(9));
    layer.add(leds, new Integer(10));
    layer.add(buttons, new Integer(11));
    setContentPane(layer);
}
Also used : Ev3Backdrop(utility.Ev3Backdrop) JLayeredPane(javax.swing.JLayeredPane) Dimension(java.awt.Dimension)

Example 9 with JLayeredPane

use of javax.swing.JLayeredPane in project omegat by omegat-org.

the class DragTargetOverlay method apply.

public static void apply(final JComponent comp, final IDropInfo info) {
    DropTargetListener listener = new DropTargetAdapter() {

        private JPanel panel = null;

        @Override
        public void dragEnter(DropTargetDragEvent dtde) {
            if (!dtde.isDataFlavorSupported(info.getDataFlavor()) || !info.canAcceptDrop()) {
                return;
            }
            final JLayeredPane layeredPane = SwingUtilities.getRootPane(comp).getLayeredPane();
            if (panel == null) {
                panel = createOverlayPanel(comp, layeredPane, info);
            }
            layeredPane.add(panel, JLayeredPane.MODAL_LAYER);
            Rectangle rect = calculateBounds(info.getComponentToOverlay());
            panel.setBounds(rect);
            panel.doLayout();
            layeredPane.repaint();
            // Repaint again later because the panel might paint itself again if it wraps.
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    layeredPane.repaint();
                }
            });
        }

        private Rectangle calculateBounds(Component overlayComponent) {
            JRootPane rootPane = SwingUtilities.getRootPane(overlayComponent);
            Rectangle rect = SwingUtilities.convertRectangle(overlayComponent.getParent(), overlayComponent.getBounds(), rootPane.getContentPane());
            JMenuBar menuBar = rootPane.getJMenuBar();
            rect.x += MARGIN;
            rect.y += MARGIN + (menuBar == null ? 0 : menuBar.getHeight());
            rect.width -= MARGIN * 2;
            rect.height -= MARGIN * 2;
            return rect;
        }

        @Override
        public void drop(DropTargetDropEvent dtde) {
        }
    };
    addListener(comp, listener);
}
Also used : DropTargetAdapter(java.awt.dnd.DropTargetAdapter) JPanel(javax.swing.JPanel) DropTargetDragEvent(java.awt.dnd.DropTargetDragEvent) DropTargetListener(java.awt.dnd.DropTargetListener) JLayeredPane(javax.swing.JLayeredPane) Rectangle(java.awt.Rectangle) JRootPane(javax.swing.JRootPane) JComponent(javax.swing.JComponent) Component(java.awt.Component) DropTargetDropEvent(java.awt.dnd.DropTargetDropEvent) JMenuBar(javax.swing.JMenuBar)

Example 10 with JLayeredPane

use of javax.swing.JLayeredPane in project jdk8u_jdk by JetBrains.

the class InsetsEncapsulation method run.

@Override
public void run() {
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    runTest(new JScrollBar());
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTableHeader(javax.swing.table.JTableHeader) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JScrollBar(javax.swing.JScrollBar) JTextPane(javax.swing.JTextPane) JToggleButton(javax.swing.JToggleButton) JSlider(javax.swing.JSlider) JMenuItem(javax.swing.JMenuItem) JComponent(javax.swing.JComponent) Component(java.awt.Component) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JToolBar(javax.swing.JToolBar) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JPopupMenu(javax.swing.JPopupMenu) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) JTable(javax.swing.JTable) JEditorPane(javax.swing.JEditorPane) JSpinner(javax.swing.JSpinner) JRootPane(javax.swing.JRootPane) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Aggregations

JLayeredPane (javax.swing.JLayeredPane)16 Component (java.awt.Component)6 JButton (javax.swing.JButton)6 JComponent (javax.swing.JComponent)5 Dimension (java.awt.Dimension)4 JPanel (javax.swing.JPanel)4 JEditorPane (javax.swing.JEditorPane)3 JMenuBar (javax.swing.JMenuBar)3 JRootPane (javax.swing.JRootPane)3 Dialog (java.awt.Dialog)2 Frame (java.awt.Frame)2 Insets (java.awt.Insets)2 ArrayList (java.util.ArrayList)2 JCheckBox (javax.swing.JCheckBox)2 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)2 JColorChooser (javax.swing.JColorChooser)2 JDesktopPane (javax.swing.JDesktopPane)2 JDialog (javax.swing.JDialog)2 JFrame (javax.swing.JFrame)2 JLabel (javax.swing.JLabel)2