use of javax.swing.JDialog in project JMRI by JMRI.
the class WarrantTableAction method showPathPortalErrors.
public static boolean showPathPortalErrors() {
if (!_hasErrors) {
return false;
}
if (_textArea == null) {
log.error("_textArea is null!.");
return true;
}
JScrollPane scrollPane = new JScrollPane(_textArea);
_errorDialog = new JDialog();
_errorDialog.setTitle(Bundle.getMessage("ErrorDialogTitle"));
JButton ok = new JButton(Bundle.getMessage("ButtonOK"));
class myListener extends java.awt.event.WindowAdapter implements ActionListener {
/* java.awt.Window _w;
myListener(java.awt.Window w) {
_w = w;
} */
@Override
public void actionPerformed(ActionEvent e) {
_hasErrors = false;
_textArea = null;
_errorDialog.dispose();
}
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
_hasErrors = false;
_textArea = null;
_errorDialog.dispose();
}
}
ok.addActionListener(new myListener());
ok.setMaximumSize(ok.getPreferredSize());
java.awt.Container contentPane = _errorDialog.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(Box.createVerticalStrut(5));
contentPane.add(Box.createVerticalGlue());
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(ok);
contentPane.add(panel, BorderLayout.SOUTH);
_errorDialog.addWindowListener(new myListener());
_errorDialog.pack();
_errorDialog.setVisible(true);
return true;
}
use of javax.swing.JDialog in project JMRI by JMRI.
the class EntryExitPairs method stackNXRoute.
/**
* If a route is requested but is currently blocked, ask user
* if it should be added to stackList.
*
* @param dp DestinationPoints object
* @param reverse true for a reversed running direction, mostly false
*/
public synchronized void stackNXRoute(DestinationPoints dp, boolean reverse) {
if (isRouteStacked(dp, reverse)) {
return;
}
stackList.add(new StackDetails(dp, reverse));
checkTimer.start();
if (stackPanel == null) {
stackPanel = new StackNXPanel();
}
if (stackDialog == null) {
stackDialog = new JDialog();
stackDialog.setTitle(Bundle.getMessage("WindowTitleStackRoutes"));
stackDialog.add(stackPanel);
}
stackPanel.updateGUI();
stackDialog.pack();
stackDialog.setModal(false);
stackDialog.setVisible(true);
}
use of javax.swing.JDialog in project jdk8u_jdk by JetBrains.
the class Listener method testHidenChildDispose.
/**
* Test if a dialog that has never been shown fire
* the WINDOW_CLOSED event on parent dispose().
* @throws Exception
*/
public static void testHidenChildDispose() throws Exception {
JFrame f = new JFrame();
JDialog dlg = new JDialog(f);
Listener l = new Listener();
dlg.addWindowListener(l);
f.dispose();
waitEvents();
assertEquals(0, l.getCount());
}
use of javax.swing.JDialog in project jdk8u_jdk by JetBrains.
the class Listener method testVisibleChildParentDispose.
/**
* Test if a dialog fire the WINDOW_CLOSED event
* on parent dispose().
* @throws Exception
*/
public static void testVisibleChildParentDispose() throws Exception {
JFrame f = new JFrame();
JDialog dlg = new JDialog(f);
Listener l = new Listener();
dlg.addWindowListener(l);
dlg.setVisible(true);
f.dispose();
waitEvents();
assertEquals(1, l.getCount());
}
use of javax.swing.JDialog in project n2a by frothga.
the class Lay method WLtg.
public static JPanel WLtg(Container target, Object... args) {
HintList hints = new HintList();
List<Component> cmpsChosen = new ArrayList<Component>();
WrapLayout fl = new WrapLayout(FlowLayout.CENTER, 5, 5);
for (Object arg : args) {
if (arg instanceof String) {
String str = (String) arg;
// String axis override
if (flAlign.get(str.toUpperCase()) != null) {
fl.setAlignment(flAlign.get(str.toUpperCase()));
// Add any hints
} else {
hints.addHints(parseHints(str));
}
// Integer axis override
} else if (arg instanceof Integer) {
fl.setAlignment((Integer) arg);
// Save components
} else if (arg instanceof Component) {
cmpsChosen.add((Component) arg);
} else if (arg instanceof ImageIcon) {
if (target instanceof JFrame) {
JFrame frame = (JFrame) target;
frame.setIconImage(((ImageIcon) arg).getImage());
} else if (target instanceof JDialog) {
JDialog dlg = (JDialog) target;
dlg.setIconImage(((ImageIcon) arg).getImage());
}
}
// Else ignore
}
// Set layout on container, add components, and set hints on container.
Container cont = chooseContainer(target, hints);
cont.setLayout(fl);
for (Component c : cmpsChosen) {
cont.add(c);
}
setHints(cont, hints);
return (target == null) ? (JPanel) cont : null;
}
Aggregations