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);
}
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();
}
});
}
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());
}
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;
}
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);
}
Aggregations