Search in sources :

Example 6 with JRootPane

use of javax.swing.JRootPane in project adempiere by adempiere.

the class PreviewPanel method setupPreview.

/**
	 * Create the preview UI components 
	 */
private void setupPreview() {
    JRootPane rootPane = new JRootPane();
    previewPanel.setLayout(new BorderLayout());
    previewPanel.add(rootPane, BorderLayout.CENTER);
    previewPanel.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary1(), 1));
    GridLayout gridLayout = new GridLayout(1, 3);
    gridLayout.setHgap(4);
    rootPane.getContentPane().setLayout(gridLayout);
    rootPane.setGlassPane(new GlassPane());
    rootPane.getGlassPane().setVisible(true);
    CPanel column1 = new CPanel();
    rootPane.getContentPane().add(column1);
    CPanel column2 = new CPanel();
    rootPane.getContentPane().add(column2);
    CPanel column3 = new CPanel();
    rootPane.getContentPane().add(column3);
    column1.setLayout(new GridBagLayout());
    JTree jtree = new JTree();
    jtree.setFocusable(false);
    jtree.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary1(), 1));
    column1.add(jtree, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 2, 2), 0, 0));
    CTextField normal = new CTextField("Text Field");
    normal.setFocusable(false);
    column1.add(normal, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 5, 2), 0, 0));
    error.setBackground(true);
    error.setFocusable(false);
    column1.add(error, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 5, 2), 0, 0));
    column2.setLayout(new GridBagLayout());
    JTable jtable = new JTable(s_data, s_columns);
    JScrollPane scrollPane = new JScrollPane(jtable);
    jtable.setFocusable(false);
    scrollPane.setPreferredSize(jtable.getPreferredSize());
    column2.add(scrollPane, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 2, 2, 2), 0, 0));
    mandatory.setMandatory(true);
    mandatory.setFocusable(false);
    column2.add(mandatory, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 5, 2), 0, 0));
    CTextField inactive = new CTextField(s_res.getString("Inactive"));
    inactive.setEnabled(false);
    column2.add(inactive, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 5, 2), 0, 0));
    column3.setLayout(new GridBagLayout());
    CTabbedPane tab = new CTabbedPane();
    column3.add(tab, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 2, 2, 5), 0, 0));
    CComboBox editable = new CComboBox(new Object[] { "Editable" });
    editable.setEditable(true);
    editable.setFocusable(false);
    column3.add(editable, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 5, 2), 0, 0));
    CComboBox choice = new CComboBox(new Object[] { "Choice" });
    choice.setEditable(false);
    choice.setFocusable(false);
    column3.add(choice, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 5, 5), 0, 0));
    tabPage1.setLayout(new BoxLayout(tabPage1, BoxLayout.Y_AXIS));
    JRadioButton radio = new JRadioButton("Radio");
    radio.setSelected(true);
    radio.setMargin(new Insets(5, 5, 5, 5));
    radio.setFocusable(false);
    radio.setOpaque(false);
    tabPage1.add(radio);
    CCheckBox checkBox = new CCheckBox("Checkbox");
    checkBox.setSelected(true);
    checkBox.setMargin(new Insets(5, 5, 5, 5));
    checkBox.setFocusable(false);
    tabPage1.add(checkBox);
    CLabel label = new CLabel("Label");
    label.setHorizontalAlignment(JLabel.LEFT);
    label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    tabPage1.add(label);
    button.setMargin(new Insets(5, 5, 5, 5));
    button.setFocusable(false);
    tabPage1.add(button);
    tab.add(tabPage1, "tab1");
    tab.add(new CPanel(), "tab2");
}
Also used : JScrollPane(javax.swing.JScrollPane) CLabel(org.compiere.swing.CLabel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) CComboBox(org.compiere.swing.CComboBox) CTextField(org.compiere.swing.CTextField) BoxLayout(javax.swing.BoxLayout) CPanel(org.compiere.swing.CPanel) CTabbedPane(org.compiere.swing.CTabbedPane) GridLayout(java.awt.GridLayout) JTree(javax.swing.JTree) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) CCheckBox(org.compiere.swing.CCheckBox) JRootPane(javax.swing.JRootPane)

Example 7 with JRootPane

use of javax.swing.JRootPane in project adempiere by adempiere.

the class ConfirmPanel method addActionListener.

//	getRefreshButton
/**************************************************************************
	 *	Add Action Listener
	 *  <code>
	 *  if (e.getActionCommand().equals(ConfirmPanel.A_OK))
	 *  </code>
	 *  @param al listener
	 */
public void addActionListener(ActionListener al) {
    ((AppsAction) bOK.getAction()).setDelegate(al);
    ((AppsAction) bCancel.getAction()).setDelegate(al);
    //
    if (bRefresh != null)
        ((AppsAction) bRefresh.getAction()).setDelegate(al);
    if (bReset != null)
        ((AppsAction) bReset.getAction()).setDelegate(al);
    if (bCustomize != null)
        ((AppsAction) bCustomize.getAction()).setDelegate(al);
    if (bHistory != null)
        ((AppsAction) bHistory.getAction()).setDelegate(al);
    if (bZoom != null)
        ((AppsAction) bZoom.getAction()).setDelegate(al);
    //	Set OK as default Button
    JRootPane rootpane = null;
    if (al instanceof JDialog)
        rootpane = ((JDialog) al).getRootPane();
    else if (al instanceof JFrame)
        rootpane = ((JFrame) al).getRootPane();
    if (rootpane != null)
        rootpane.setDefaultButton(bOK);
}
Also used : JFrame(javax.swing.JFrame) JRootPane(javax.swing.JRootPane) JDialog(javax.swing.JDialog)

Example 8 with JRootPane

use of javax.swing.JRootPane in project jodd by oblac.

the class SwingSpy method initSpyDialog.

/**
	 * Initializes Spy dialog.
	 */
protected void initSpyDialog(Component rootComponent, Component component) {
    if (rootComponent instanceof Dialog) {
        spyDialog = new CaddyDialog((Dialog) rootComponent) {

            @Override
            protected JRootPane createRootPane() {
                return createSpyRootPane();
            }
        };
    } else if (rootComponent instanceof Frame) {
        spyDialog = new CaddyDialog((Frame) rootComponent) {

            @Override
            protected JRootPane createRootPane() {
                return createSpyRootPane();
            }
        };
    } else {
        spyDialog = new JDialog() {

            @Override
            protected JRootPane createRootPane() {
                return createSpyRootPane();
            }
        };
    }
    spyDialog.setName("SwingSpy");
    spyDialog.setTitle("SwingSpy");
    spyDialog.setModal(false);
    spyDialog.setAlwaysOnTop(true);
    Container contentPane = spyDialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    spyPanel = new SwingSpyPanel();
    spyPanel.reload(rootComponent, component);
    contentPane.add(spyPanel);
    spyDialog.pack();
    spyDialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosed(e);
            spyGlass.setVisible(false);
            spyDialog = null;
        }
    });
    spyDialog.setLocationRelativeTo(null);
    spyDialog.setVisible(true);
}
Also used : Frame(java.awt.Frame) RootPaneContainer(javax.swing.RootPaneContainer) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JDialog(javax.swing.JDialog) Dialog(java.awt.Dialog) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) JRootPane(javax.swing.JRootPane) JDialog(javax.swing.JDialog)

Example 9 with JRootPane

use of javax.swing.JRootPane in project jodd by oblac.

the class SwingSpy method createSpyRootPane.

/**
	 * Creates spy root pane for spy dialog.
	 */
protected JRootPane createSpyRootPane() {
    JRootPane rootPane = new JRootPane();
    KeyStroke escapeKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    rootPane.registerKeyboardAction(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            spyGlass.setVisible(false);
            spyDialog.setVisible(false);
        }
    }, escapeKeyStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) JRootPane(javax.swing.JRootPane)

Example 10 with JRootPane

use of javax.swing.JRootPane 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)

Aggregations

JRootPane (javax.swing.JRootPane)90 ActionEvent (java.awt.event.ActionEvent)48 KeyStroke (javax.swing.KeyStroke)35 AbstractAction (javax.swing.AbstractAction)32 Action (javax.swing.Action)29 InputMap (javax.swing.InputMap)26 JPanel (javax.swing.JPanel)16 BorderLayout (java.awt.BorderLayout)14 JButton (javax.swing.JButton)13 ActionListener (java.awt.event.ActionListener)12 JLabel (javax.swing.JLabel)12 Container (java.awt.Container)10 FlowLayout (java.awt.FlowLayout)10 Dimension (java.awt.Dimension)9 Insets (java.awt.Insets)9 BoxLayout (javax.swing.BoxLayout)9 Component (java.awt.Component)8 Frame (java.awt.Frame)7 JScrollPane (javax.swing.JScrollPane)7 GridBagConstraints (java.awt.GridBagConstraints)6