Search in sources :

Example 51 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)

Example 52 with JRootPane

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

the class ScriptingWindow method addRunShortcutToOmegaT.

private void addRunShortcutToOmegaT() {
    JRootPane appliRootPane = Core.getMainWindow().getApplicationFrame().getRootPane();
    appliRootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK, false), "RUN_CURRENT_SCRIPT");
    appliRootPane.getActionMap().put("RUN_CURRENT_SCRIPT", new AbstractAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            runScript();
        }
    });
}
Also used : ActionEvent(java.awt.event.ActionEvent) JRootPane(javax.swing.JRootPane) AbstractAction(javax.swing.AbstractAction)

Example 53 with JRootPane

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

the class CenterSelectedNodeAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    final Component mapView = Controller.getCurrentController().getMapViewManager().getMapViewComponent();
    final JRootPane rootPane = SwingUtilities.getRootPane(mapView);
    if (!rootPane.isValid()) {
        rootPane.revalidate();
    }
    selection.centerNode(selection.getSelected());
}
Also used : IMapSelection(org.freeplane.features.map.IMapSelection) JRootPane(javax.swing.JRootPane) Component(java.awt.Component)

Example 54 with JRootPane

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

the class EditNodeWYSIWYG method createHtmlEditor.

public HTMLDialog createHtmlEditor(final RootPaneContainer frame) throws Exception {
    final JRootPane rootPane = ((RootPaneContainer) frame).getRootPane();
    HTMLDialog htmlEditorWindow = (HTMLDialog) rootPane.getClientProperty(HTMLDialog.class);
    if (htmlEditorWindow == null) {
        htmlEditorWindow = new HTMLDialog(this, "", "", frame);
        rootPane.putClientProperty(HTMLDialog.class, htmlEditorWindow);
        // make sure that SHTML gets notified of relevant config changes!
        ResourceController.getResourceController().addPropertyChangeListener(new FreeplaneToSHTMLPropertyChangeAdapter(htmlEditorWindow.getHtmlEditorPanel()));
    }
    return htmlEditorWindow;
}
Also used : RootPaneContainer(javax.swing.RootPaneContainer) JRootPane(javax.swing.JRootPane)

Example 55 with JRootPane

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

the class BannerRootPanelLayout method minimumLayoutSize.

@Override
public Dimension minimumLayoutSize(Container parent) {
    int contentWidth = 0;
    int menuWidth = 0;
    int height = 0;
    Insets insets = parent.getInsets();
    height += insets.top + insets.bottom;
    JRootPane rootPane = (JRootPane) parent;
    Dimension contentSize;
    if (rootPane.getContentPane() != null) {
        contentSize = rootPane.getContentPane().getMinimumSize();
    } else {
        contentSize = rootPane.getSize();
    }
    contentWidth = contentSize.width;
    height += contentSize.height;
    if (rootPane.getJMenuBar() != null && rootPane.getJMenuBar().isVisible()) {
        Dimension menuSize = rootPane.getJMenuBar().getMinimumSize();
        height += menuSize.height;
        menuWidth = menuSize.width;
    }
    return new Dimension(Math.max(contentWidth, menuWidth) + insets.left + insets.right, height);
}
Also used : Insets(java.awt.Insets) JRootPane(javax.swing.JRootPane) Dimension(java.awt.Dimension)

Aggregations

JRootPane (javax.swing.JRootPane)89 ActionEvent (java.awt.event.ActionEvent)48 KeyStroke (javax.swing.KeyStroke)34 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 FlowLayout (java.awt.FlowLayout)10 Container (java.awt.Container)9 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