Refine search
final JDialog dialog = new JDialog(frame, "Jar File Chooser", true); dialog.setLocation(location); final JList fileList = new JList(new Vector<>(files)); okay.setText("Okay"); okay.setToolTipText("Okay"); okay.addActionListener(evt -> dialog.setVisible(false)); JButton cancel = new javax.swing.JButton(); cancel.setText("Cancel"); cancel.addActionListener(evt -> { fileList.clearSelection(); dialog.setVisible(false); }); constraints.weighty = 1.0; gridbag.setConstraints(scroll, constraints); dialog.add(scroll); constraints.weighty = 0.0; gridbag.setConstraints(okay, constraints); dialog.add(okay); dialog.add(cancel); dialog.pack(); dialog.setSize(dialog.getPreferredSize()); dialog.setVisible(true);
JDialog d = new JDialog((Frame) null, "Download symbols", false); d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); d.addWindowListener(new WindowAdapter() { d.add(g); d.pack(); d.setVisible(true);
portsettings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JDialog dialog = new JDialog(frame); dialog.add(PortSettings); dialog.pack(); dialog.setVisible(true); } });
JButton cancel = new javax.swing.JButton(); JDialog dialog = new JDialog(new Frame(), "Parser Progress", true); dialog.add(BorderLayout.NORTH, new JLabel("Parsing " + sentences.size() + " sentences")); dialog.add(BorderLayout.CENTER, progress); dialog.add(BorderLayout.SOUTH, cancel); dialog.setVisible(true);
JDialog someDialog = new JDialog(myJFrame, "My Dialog", ModalityType.APPLICATION_MODAL); someDialog.add(myContentPaneWithMyGui); someDialog.pack(); someDialog.setVisible(true); // here code flow stops until the dialog is no longer visible. // now call my getter to extract data SomeType someData = myContentPaneWithMyGui.getSomeData();
if (gameArea.hitChest()) { JDialog d = new JDialog((JFrame) gameArea.getTopLevelAncestor(), "Dialogue", true); ChestLoot ch = new ChestLoot(player); d.add(ch); d.setSize(200, 100); d.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); d.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { System.out.println("Don't Close!"); } }); d.setVisible(true); //code pauses here and waits for the dialog to be handled System.out.println("Should dispose here"); TileIcon ches = gameArea.getCurrChest(); gameArea.removeChest(ches); }
private void handleError(String name, Throwable t) { StringWriter writer = new StringWriter(); writer.append("Apache Tika was unable to parse the document\n"); writer.append("at " + name + ".\n\n"); writer.append("The full exception stack trace is included below:\n\n"); t.printStackTrace(new PrintWriter(writer)); JEditorPane editor = new JEditorPane("text/plain", writer.toString()); editor.setEditable(false); editor.setBackground(Color.WHITE); editor.setCaretPosition(0); editor.setPreferredSize(new Dimension(600, 400)); JDialog dialog = new JDialog(this, "Apache Tika error"); dialog.add(new JScrollPane(editor)); dialog.pack(); dialog.setVisible(true); }
public void makeGui() { aPanel = new JPanel(new BorderLayout()); this.getContentPane().add(aPanel, BorderLayout.CENTER); Window win = SwingUtilities.getWindowAncestor(Example.this); JDialog dialog = new JDialog(win, "My Dialog", ModalityType.MODELESS); JPanel dialogPanel = new JPanel(); dialogPanel.setPreferredSize(new Dimension(200, 200)); dialog.add(dialogPanel); dialog.pack(); dialog.setVisible(true); JOptionPane.showMessageDialog(dialog, "arfarf"); }
private void textDialog(String title, URL resource) { try { JDialog dialog = new JDialog(this, title); JEditorPane editor = new JEditorPane(resource); editor.setContentType("text/html"); editor.setEditable(false); editor.setBackground(Color.WHITE); editor.setPreferredSize(new Dimension(400, 250)); editor.addHyperlinkListener(this); dialog.add(editor); dialog.pack(); dialog.setVisible(true); } catch (IOException e) { e.printStackTrace(); } }
@Override public void actionPerformed(ActionEvent e) { JDialog dlg = new JDialog(jf, "modal"); dlg.add(new JLabel("hello")); dlg.setModal(true); dlg.pack(); dlg.setLocationRelativeTo(canvas); dlg.setVisible(true); button.getModel().setRollover(false); }
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == EventType.ACTIVATED) { try { URL url = e.getURL(); try (InputStream stream = url.openStream()) { JEditorPane editor = new JEditorPane("text/plain", IOUtils.toString(stream, UTF_8)); editor.setEditable(false); editor.setBackground(Color.WHITE); editor.setCaretPosition(0); editor.setPreferredSize(new Dimension(600, 400)); String name = url.toString(); name = name.substring(name.lastIndexOf('/') + 1); JDialog dialog = new JDialog(this, "Apache Tika: " + name); dialog.add(new JScrollPane(editor)); dialog.pack(); dialog.setVisible(true); } } catch (IOException exception) { exception.printStackTrace(); } } }
MyPanel myPanel = new MyPanel(); // assuming that the parent window JFrame is referenced by "myFrame" JDialog myDialog = new JDialog(myJFrame, "My Dialog", ModalityType.APPLICATION_MODAL); myDialog.add(myPanel); myDialog.pack(); myDialog.setVisible(true);
final JDialog waitForTrans = new JDialog((JFrame) null, true); SwingWorker worker = new SwingWorker() { public String doInBackground() throws Exception { Thread.sleep(5000); return null; } public void done() { SwingUtilities.invokeLater(new Runnable() { public void run() { waitForTrans.setVisible(false); waitForTrans.dispose(); } }); } }; worker.execute(); SwingUtilities.invokeLater(new Runnable() { public void run() { waitForTrans.add(new JLabel("Please Wait...")); waitForTrans.setMinimumSize(new Dimension(300, 100)); waitForTrans.setVisible(true); } });
JFrame f = this.getFrame(); JDialog loginDialog = new JDialog(f,"Login",true); loginDialog.add(loginPanel); loginDialog.pack(); f.setExtendedState(Frame.MAXIMIZED_BOTH) f.setVisible(true); loginDialog.setLocationRelativeTo(f); loginDialog.setVisible(true);