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