List of usage examples for javax.swing JDialog add
public Component add(Component comp)
From source file:Main.java
public static void main(String[] args) { JFrame frame1 = new JFrame(); frame1.setExtendedState(JFrame.MAXIMIZED_BOTH); frame1.setUndecorated(true);//from w w w .j a v a 2 s.c o m frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.setVisible(true); JDialog nonModalDialog = new JDialog(frame1, "Non-Modal Dialog", ModalityType.MODELESS); nonModalDialog.add(Box.createRigidArea(new Dimension(200, 200))); nonModalDialog.pack(); nonModalDialog.setVisible(true); JDialog modalDialog = new JDialog(frame1, "Modal Dialog", ModalityType.APPLICATION_MODAL); modalDialog.add(Box.createRigidArea(new Dimension(200, 200))); modalDialog.pack(); modalDialog.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(Main.class.getSimpleName()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton("Click me to open dialog"); button.addActionListener(e -> {//from w w w . ja v a 2 s.co m Window parentWindow = SwingUtilities.windowForComponent(button); JDialog dialog = new JDialog(parentWindow); dialog.setLocationRelativeTo(button); dialog.setModal(true); dialog.add(new JLabel("A dialog")); dialog.pack(); dialog.setVisible(true); }); frame.add(button); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Frame"); frame.add(Box.createRigidArea(new Dimension(400, 300))); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack();//from w w w.j a va 2s .co m frame.setVisible(true); JDialog dialog = new JDialog(frame, "Dialog", true); int condition = JPanel.WHEN_IN_FOCUSED_WINDOW; InputMap inputMap = ((JPanel) dialog.getContentPane()).getInputMap(condition); ActionMap actionMap = ((JPanel) dialog.getContentPane()).getActionMap(); String enter = "enter"; inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), enter); actionMap.put(enter, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); dialog.add(Box.createRigidArea(new Dimension(200, 200))); dialog.pack(); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); }
From source file:Main.java
public static void main(final String[] args) { JFrame frame = new JFrame("Frame"); JDialog dialog = new JDialog(frame, "Dialog"); frame.add(new JLabel("Content")); frame.addMouseListener(new MouseAdapter() { @Override//from w w w. ja va2 s. c om public void mousePressed(MouseEvent arg0) { System.out.println("frame pressed"); System.out.println("dialog focused " + dialog.isFocused()); System.out.println("frame focused " + frame.isFocused()); super.mousePressed(arg0); } }); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); dialog.add(new JLabel("Content")); dialog.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { super.focusLost(arg0); dialog.requestFocus(); } }); dialog.pack(); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); }
From source file:Main.java
private static JButton newButton(String label) { final JButton button = new JButton(label); button.addActionListener(e -> {//from w w w .ja v a2 s . c o m Window parentWindow = SwingUtilities.windowForComponent(button); JDialog dialog = new JDialog(parentWindow); dialog.setLocationRelativeTo(button); dialog.setModal(true); dialog.add(newPane("Label")); dialog.pack(); dialog.setVisible(true); }); return button; }
From source file:org.duracloud.syncui.SyncUIDriver.java
/** * Note: The embedded Jetty server setup below is based on the example configuration in the Eclipse documentation: * https://www.eclipse.org/jetty/documentation/9.4.x/embedded-examples.html#embedded-webapp-jsp *//*from w w w . j a v a 2 s . c o m*/ private static void launchServer(final String url, final CloseableHttpClient client) { try { final JDialog dialog = new JDialog(); dialog.setSize(new java.awt.Dimension(400, 75)); dialog.setModalityType(ModalityType.MODELESS); dialog.setTitle("DuraCloud Sync"); dialog.setLocationRelativeTo(null); JPanel panel = new JPanel(); final JLabel label = new JLabel("Loading..."); final JProgressBar progress = new JProgressBar(); progress.setStringPainted(true); panel.add(label); panel.add(progress); dialog.add(panel); dialog.setVisible(true); port = SyncUIConfig.getPort(); contextPath = SyncUIConfig.getContextPath(); Server srv = new Server(port); // Setup JMX MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer()); srv.addBean(mbContainer); ProtectionDomain protectionDomain = org.duracloud.syncui.SyncUIDriver.class.getProtectionDomain(); String warFile = protectionDomain.getCodeSource().getLocation().toExternalForm(); log.debug("warfile: {}", warFile); WebAppContext context = new WebAppContext(); context.setContextPath(contextPath); context.setWar(warFile); context.setExtractWAR(Boolean.TRUE); Configuration.ClassList classlist = Configuration.ClassList.setServerDefault(srv); classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration"); context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$"); srv.setHandler(context); new Thread(new Runnable() { @Override public void run() { createSysTray(url, srv); while (true) { if (progress.getValue() < 100) { progress.setValue(progress.getValue() + 3); } sleep(2000); if (isAppRunning(url, client)) { break; } } progress.setValue(100); label.setText("Launching browser..."); launchBrowser(url); dialog.setVisible(false); } }).start(); srv.start(); srv.join(); } catch (Exception e) { log.error("Error launching server: " + e.getMessage(), e); } }
From source file:Main.java
public Main() { setDefaultCloseOperation(EXIT_ON_CLOSE); JButton openDialog = new JButton("Click here"); JPanel myPanel = new JPanel(); myPanel.add(new JButton(new AbstractAction("Click here") { @Override/*w w w . j ava2 s .c o m*/ public void actionPerformed(ActionEvent e) { JDialog dialog = new JDialog(myFrame, true); JTextField myField = new JTextField(10); JPanel innerPanel = new JPanel(); innerPanel.add(myField); dialog.add(innerPanel); dialog.pack(); dialog.setSize(new Dimension(160, 120)); dialog.setLocationRelativeTo(myFrame); dialog.setVisible(true); } })); add(myPanel); pack(); setSize(new Dimension(320, 240)); setLocationRelativeTo(null); setVisible(true); }
From source file:Main.java
public Main() { int MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); KeyStroke exitKey = KeyStroke.getKeyStroke(KeyEvent.VK_W, MASK); this.setDefaultCloseOperation(EXIT_ON_CLOSE); JMenu fileMenu = new JMenu("File"); JMenuItem fileExit = new JMenuItem(exitAction); fileMenu.add(fileExit);//from w w w . jav a 2 s. c om JMenuBar menu = new JMenuBar(); menu.add(fileMenu); JDialog d = new JDialog(this, "Dialog"); JPanel p = new JPanel(); p.getInputMap().put(exitKey, exitName); p.getActionMap().put(exitName, exitAction); p.add(new JButton(exitAction)); d.add(p); d.pack(); d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setJMenuBar(menu); this.pack(); this.setSize(new Dimension(320, 240)); this.setVisible(true); d.setLocation(this.getRootPane().getContentPane().getLocationOnScreen()); d.setVisible(true); }
From source file:org.nekorp.workflow.desktop.view.resource.imp.EvidenciaViewDialogFactory.java
@Override public JDialog createDialog(Frame frame, boolean modal) { JDialog dialog = new JDialog(mainFrame, true); dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); dialog.setTitle("Evidencia"); evidenciaView.iniciaVista();//from w w w . jav a2s.c o m dialog.add(evidenciaView); dialog.setSize(980, 640);//hardcode para que no cresca en medida de imagenes en el preview dialog.validate(); //dialog.pack(); dialog.setLocationRelativeTo(mainFrame); return dialog; }
From source file:org.nekorp.workflow.desktop.view.resource.imp.ParametrosReporteGlobalDialogFactory.java
@Override public JDialog createDialog(Frame frame, boolean modal) { JDialog dialog = new JDialog(mainFrame, true); dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); dialog.setTitle("Reporte Global"); datePickView.setParent(dialog);//from w w w . j a v a 2 s .com datePickView.iniciaVista(); dialog.add(datePickView); dialog.validate(); dialog.pack(); dialog.setLocationRelativeTo(mainFrame); return dialog; }