public static void main(String[] args) { Dialog dlg = new Dialog("TextField Test"); dlg.setBounds(10, 10, 600, 400); dlg.setLayout(new TableLayout(new double[][] {{1, 0, 1}, {0, 20, 0}}, 0, 5)); TextField tf = new TextField(); tf.setLimit("1, 1"); tf.setAlignX(TextField.AlignX.RIGHT); // tf.getStyle().getBorder().setSize(1); dlg.getStyle().getBackground().setColor(Color.BLACK); dlg.getChildren().add(tf); dlg.setVisible(true); }
protected synchronized Dialog createGotoDialog() { if (gotoDialog == null) { gotoDialog = DialogSupport.createDialog( NbBundle.getBundle(org.netbeans.editor.BaseKit.class) .getString("goto-title"), // NOI18N gotoPanel, false, // non-modal gotoButtons, false, // sidebuttons, 0, // defaultIndex = 0 => gotoButton 1, // cancelIndex = 1 => cancelButton this // listener ); gotoDialog.pack(); // Position the dialog according to the history Rectangle lastBounds = (Rectangle) EditorState.get(BOUNDS_KEY); if (lastBounds != null) { gotoDialog.setBounds(lastBounds); } else { // no history, center it on the screen Dimension dim = gotoDialog.getPreferredSize(); int x; int y; JTextComponent c = EditorRegistry.lastFocusedComponent(); Window w = c != null ? SwingUtilities.getWindowAncestor(c) : null; if (w != null) { x = Math.max(0, w.getX() + (w.getWidth() - dim.width) / 2); y = Math.max(0, w.getY() + (w.getHeight() - dim.height) / 2); } else { Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); x = Math.max(0, (screen.width - dim.width) / 2); y = Math.max(0, (screen.height - dim.height) / 2); } gotoDialog.setLocation(x, y); } return gotoDialog; } else { gotoDialog.setVisible(true); gotoDialog.toFront(); return null; } }
/* WARNING: THIS METHOD WILL BE REGENERATED. */ private java.awt.Dialog getDialog1() { if (ivjDialog1 == null) { try { ivjDialog1 = new java.awt.Dialog(new java.awt.Frame()); ivjDialog1.setName("Dialog1"); ivjDialog1.setLayout(new java.awt.BorderLayout()); ivjDialog1.setBounds(65, 335, 204, 95); getDialog1().add(getContentsPane(), "Center"); // user code begin {1} // user code end } catch (java.lang.Throwable ivjExc) { // user code begin {2} // user code end handleException(ivjExc); } } return ivjDialog1; }
public void start() { Toolkit.getDefaultToolkit() .addAWTEventListener( new AWTEventListener() { public void eventDispatched(AWTEvent e) { System.out.println(e.toString()); } }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK | WindowEvent.WINDOW_EVENT_MASK); frame = new Frame("Frame"); frame.setName("Frame-owner"); frame.setBounds(100, 0, 100, 100); dialog = new Dialog(frame, "Dialog"); dialog.setName("Dialog-owner"); dialog.setBounds(100, 0, 100, 100); window1 = new Window(frame); window1.setName("1st child"); window1.setBounds(100, 300, 100, 100); window2 = new Window(window1); window2.setName("2nd child"); window2.setBounds(100, 500, 100, 100); test1(frame, window1); test2(frame, window1, window2); test3(frame, window1, window2); window1 = new Window(dialog); window1.setBounds(100, 300, 100, 100); window1.setName("1st child"); window2 = new Window(window1); window2.setName("2nd child"); window2.setBounds(100, 500, 100, 100); test1(dialog, window1); test2(dialog, window1, window2); test3(dialog, window1, window2); System.out.println("Test passed."); }