GridBagConstraints constraints = new GridBagConstraints(); dialog.setLayout(gridbag);
this.setLayout(new GridLayout(0, 1)); this.add(new JLabel("Dialog close test.", JLabel.CENTER)); this.add(new JButton(new AbstractAction("Close") {
emailDialog.setLayout(new BorderLayout());
dialog.setAlwaysOnTop(true); dialog.setModal(true); dialog.setLayout(new GridLayout(2, 0, 10, 10)); JPanel pane = (JPanel) dialog.getContentPane(); pane.setBorder(new EmptyBorder(10, 10, 10, 10));
d.setLayout(new BorderLayout()); d.add(g); d.pack();
JDialog dialog = new JDialog(); dialog.setLayout( new GrigBagLayout() ); JPanel panel = new JPanel(...); panel.add(...); dialog.add(panel, new GridBagConstraints());
JDialog dlg = new JDialog(null, "My Dialog", false); // Create non-modal dialog. dlg.setLayout(new BorderLayout()); dlg.add(myPanel, BorderLayout.CENTER); dlg.pack(); dlg.setLocationRelativeTo(null); dlg.setVisible(true);
private void initComponents(final JDialog dialog) { dialog.setLayout(new BorderLayout()); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.getContentPane().add(editorPanel, BorderLayout.CENTER); dialog.setPreferredSize(DEF_SIZE); dialog.setMinimumSize(MIN_SIZE); dialog.pack(); } });
Window containerWindow = SwingUtilities.getWindowAncestor(panel); JDialog dialog = new JDialog(containerWindow); dialog.setLayout(new BorderLayout()); dialog.setLocationRelativeTo(containerWindow); dialog.setResizeable(false); dialog.add(effectPanel, BorderLayout.CENTER);
import javax.swing.*; import java.awt.*; public class t { public static void main(String[] args) { JDialog downloadingDialog = new JDialog((JFrame)null ,"Start donwloading..."); JProgressBar progressBar = new JProgressBar(JProgressBar.HORIZONTAL); progressBar.setIndeterminate(true); downloadingDialog.setLayout(new FlowLayout(FlowLayout.LEFT)); downloadingDialog.add(progressBar); downloadingDialog.setSize(300, 100); downloadingDialog.setVisible(true); } }
JDialog zMessageDialog = new JDialog((java.awt.Frame) null, true); zMessageDialog.setTitle("Order summary"); zMessageDialog.setLayout(new BorderLayout()); JTextArea zTextArea = new JTextArea("Blah blah\nblah blah\nblah blah"); zTextArea.setEditable(false); zTextArea.setColumns(40); zTextArea.setRows(10); zTextArea.setBackground(null); JScrollPane zScrollPane = new JScrollPane(zTextArea); zMessageDialog.add(zScrollPane, BorderLayout.CENTER); zMessageDialog.revalidate(); zMessageDialog.pack(); zMessageDialog.setVisible(true);
private void addContent(JDialog d) { d.setLayout(new BorderLayout()); if (addScrollBars) { JScrollPane scrollPane = new JScrollPane(content, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER); d.add(scrollPane, BorderLayout.CENTER); } else { d.add(content, BorderLayout.CENTER); } }
JDialog dialog = new JDialog(); dialog.setSize(300, 200); dialog.setLayout(null); JButton button = new JButton("Testbutton!"); button.setVisible(true); button.setBounds(10,10,40,40); dialog.add(button); //Make dialog visible dialog.setVisible(true);
JOptionPane jop = new JOptionPane(); JDialog dialog = jop.createDialog("File not found"); dialog.setLayout(new BorderLayout()); JLabel im = new JLabel("Java Technology Dive Log", new ImageIcon("images/gwhite.gif"), JLabel.CENTER); dialog.add(im, BorderLayout.NORTH); dialog.setVisible(true);
JDialog jd=new JDialog(loginpage.this,"User Registration"); jd.setModal(true); jd.setLayout(null); // THIS IS A BAD IDEA // jd.setLocationRelativeTo(null); // This is somewhat pointless, you've set relative location, but know overridden it... // You should also be relying on the layout manager and pack to determine the size... jd.setBounds(400,300, 479, 329); jd.setResizable(false); setLocationRelativeTo(loginpage.this); // Add you other components jd.setVisible(true);
for (File file : files) { try { ... HistogramPanel panel = new HistogramPanel(width, counts, height, horizon); JDialog dialog = new JDialog(); dialog.setModal(false); <---- very important dialog.setLayout(new BorderLayout()); dialog.add(panel); dialog.pack(); dialog.setLocationByPlatform(true); dialog.setVisible(true); } catch (...) }
JDialog jDialog = new JDialog(); jDialog.setLayout(new GridBagLayout()); jDialog.add(new JLabel("Please wait...")); jDialog.setMinimumSize(new Dimension(150, 50)); jDialog.setResizable(false); jDialog.setModal(false); jDialog.setUndecorated(true); jDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); jDialog.setLocationRelativeTo(null); jDialog.setVisible(true);
/** * @param f 设置OCR界面 */ public BaiduNlpSettingDialog(JFrame f) { dialog = new JDialog(f, "输入", true); dialog.setBounds(20, 200, 400, 220); dialog.setLayout(null); dialogPane = dialog.getContentPane(); addAppId(); addApiKey(); addSecretKey(); addSetFinishButton(); dialog.setVisible(true); }
/** * * @param f 设置OCR界面 */ public BaiDuOcrSettingDialog(JFrame f){ dialog = new JDialog(f, "输入",true); dialog.setBounds(20,200,400,220); dialog.setLayout(null); dialogPane = dialog.getContentPane(); addAppId(); addApiKey(); addSecretKey(); addSetFinishButton(); dialog.setVisible(true); }
@Override public void actionPerformed(ActionEvent e) { JDialog f = new JDialog(MedSavantFrame.getInstance(), "Pedigree Viewer", true); PedigreeCanvas pc = new PedigreeCanvas(); pc.setFamilyName(patient.getFamilyID()); pc.showPedigreeFor(patient.getID()); f.setPreferredSize(new Dimension(650, 500)); f.setLayout(new BorderLayout()); f.add(pc, BorderLayout.CENTER); f.pack(); f.setLocationRelativeTo(MedSavantFrame.getInstance()); f.setVisible(true); }