use of automenta.vivisect.swing.property.swing.BannerPanel 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;
}
Aggregations