List of usage examples for javax.swing JDialog pack
@SuppressWarnings("deprecation") public void pack()
From source file:Main.java
Main() { Object[][] data = { { "A", "B", "Snowboarding", new Integer(5) }, { "C", "D", "Pool", new Integer(10) } }; Object[] columnNames = { "firstname", "lastname", "age" }; final JTable table = new JTable(data, columnNames) { @Override// w w w. j a v a 2 s .c om public Dimension getPreferredScrollableViewportSize() { Dimension d = getPreferredSize(); int n = getRowHeight(); return new Dimension(d.width, (n * ROWS)); } }; JPanel jPanel = new JPanel(); jPanel.setLayout(new GridLayout()); JScrollPane sp = new JScrollPane(table); jPanel.add(sp); JDialog jdialog = new JDialog(); jdialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); jdialog.setContentPane(jPanel); jdialog.pack(); jdialog.setVisible(true); }
From source file:Main.java
public Main() { super(BoxLayout.Y_AXIS); Box info = Box.createVerticalBox(); info.add(new Label("Please wait 3 seconds")); final JButton continueButton = new JButton("Continue"); info.add(continueButton);/*from ww w .j a va 2 s . c o m*/ JDialog d = new JDialog(); d.setModalityType(ModalityType.APPLICATION_MODAL); d.setContentPane(info); d.pack(); continueButton.addActionListener(e -> d.dispose()); continueButton.setVisible(false); SwingWorker sw = new SwingWorker<Integer, Integer>() { protected Integer doInBackground() throws Exception { int i = 0; while (i++ < 30) { System.out.println(i); Thread.sleep(100); } return null; } @Override protected void done() { continueButton.setVisible(true); } }; JButton button = new JButton("Click Me"); button.addActionListener(e -> { sw.execute(); d.setVisible(true); }); add(button); }
From source file:ca.nengo.ui.util.DialogPlotter.java
@Override protected void showChart(JFreeChart chart, String title) { JPanel panel = new ChartPanel(chart); JDialog dialog = new JDialog(parent, title); dialog.getContentPane().add(panel, BorderLayout.CENTER); dialog.pack(); dialog.setVisible(true);/*from www . j av a 2 s. c o m*/ }
From source file:Modelos.Grafica.java
public ChartPanel mostrarGrafica(Window owner) { ChartPanel panel = new ChartPanel(chart); JDialog ventana; ventana = new JDialog(owner, "Grafica"); ventana.getContentPane().add(panel); ventana.pack(); ventana.setVisible(true);/* ww w . jav a2s.co m*/ //ventana.dispose(); ventana.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); return panel; }
From source file:org.simbrain.plot.piechart.PieChartGui.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equalsIgnoreCase("Add")) { this.getWorkspaceComponent().getModel().addDataSource(); } else if (e.getActionCommand().equalsIgnoreCase("dialog")) { ReflectivePropertyEditor editor = (new ReflectivePropertyEditor(getWorkspaceComponent().getModel())); JDialog dialog = editor.getDialog(); dialog.setModal(true);//from w w w. j a v a 2 s . com dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); } else if (e.getActionCommand().equalsIgnoreCase("Delete")) { this.getWorkspaceComponent().getModel().removeDataSource(); } }
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/* ww w. ja v a2 s . co 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);//www. j a v a2 s .c o m 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.simbrain.plot.barchart.BarChartGui.java
/** @see ActionListener */ public void actionPerformed(final ActionEvent arg0) { if (arg0.getActionCommand().equalsIgnoreCase("dialog")) { ReflectivePropertyEditor editor = (new ReflectivePropertyEditor(getWorkspaceComponent().getModel())); JDialog dialog = editor.getDialog(); dialog.setModal(true);/*from w w w.ja v a 2 s. c om*/ dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); } else if (arg0.getActionCommand().equalsIgnoreCase("Delete")) { this.getWorkspaceComponent().getModel().removeColumn(); } else if (arg0.getActionCommand().equalsIgnoreCase("Add")) { this.getWorkspaceComponent().getModel().addColumn(); } }
From source file:org.simbrain.plot.rasterchart.RasterPlotPanel.java
/** * Show properties dialog.//from w w w . j a va2 s . c om */ public void showPropertiesDialog() { ReflectivePropertyEditor editor = (new ReflectivePropertyEditor(model)); JDialog dialog = editor.getDialog(); dialog.setModal(true); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); }
From source file:Main.java
public void launchDialog() { JButton findButton = new JButton("Find"); findButton.addActionListener(e -> { int start = text.getText().indexOf("is"); int end = start + "is".length(); if (start != -1) { text.requestFocus();/*from w w w. ja va 2s .c o m*/ text.select(start, end); } }); JButton cancelButton = new JButton("Cancel"); JOptionPane optionPane = new JOptionPane("Do you understand?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, new Object[] { findButton, cancelButton }); JDialog dialog = new JDialog(frame, "Click a button", false); cancelButton.addActionListener(e -> dialog.setVisible(false)); dialog.setContentPane(optionPane); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.setLocation(100, 100); dialog.pack(); dialog.setVisible(true); }