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