/** Show the filter dialog */ public void showDialog() { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); include_panel = new ServiceFilterPanel("Include messages based on target service:", filter_include_list); exclude_panel = new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list); status_box = new JCheckBox("Filter messages based on status:"); status_box.addActionListener(this); status_active = new JRadioButton("Active messages only"); status_active.setSelected(true); status_active.setEnabled(false); status_complete = new JRadioButton("Complete messages only"); status_complete.setEnabled(false); status_group = new ButtonGroup(); status_group.add(status_active); status_group.add(status_complete); if (filter_active || filter_complete) { status_box.setSelected(true); status_active.setEnabled(true); status_complete.setEnabled(true); if (filter_complete) { status_complete.setSelected(true); } } status_options = new JPanel(); status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS)); status_options.add(status_active); status_options.add(status_complete); status_options.setBorder(indent_border); status_panel = new JPanel(); status_panel.setLayout(new BorderLayout()); status_panel.add(status_box, BorderLayout.NORTH); status_panel.add(status_options, BorderLayout.CENTER); status_panel.setBorder(empty_border); ok_button = new JButton("Ok"); ok_button.addActionListener(this); cancel_button = new JButton("Cancel"); cancel_button.addActionListener(this); buttons = new JPanel(); buttons.setLayout(new FlowLayout()); buttons.add(ok_button); buttons.add(cancel_button); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(include_panel); panel.add(exclude_panel); panel.add(status_panel); panel.add(buttons); dialog = new JDialog(); dialog.setTitle("SOAP Monitor Filter"); dialog.setContentPane(panel); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setModal(true); dialog.pack(); Dimension d = dialog.getToolkit().getScreenSize(); dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2); ok_pressed = false; dialog.show(); }
private void warning(String msg) { final JDialog warn; JButton ok; JLabel message; warn = new JDialog(); warn.setTitle(msg); message = new JLabel("CryoBay: " + msg); ok = new JButton("Ok"); ok.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { warn.dispose(); } }); warn.getContentPane().setLayout(new BorderLayout()); warn.getContentPane().add(message, "North"); warn.getContentPane().add(ok, "South"); warn.setSize(200, 80); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); warn.setLocation(screenSize.width / 2 - 100, screenSize.height / 2 - 40); warn.setResizable(false); warn.show(); }
public void runCalculatorDialog(MouseEvent e) { if (calculatorDialog == null) { JFrame frame = null; Container container = getTopLevelAncestor(); if (container instanceof JFrame) { frame = (JFrame) container; } calculatorDialog = new JDialog(frame, "Rechner", true); calculator = new Calculator(); calculator.getOKButton().addActionListener(this); calculatorDialog.getContentPane().add(calculator); calculatorDialog.pack(); } // Set calculator's init value Money money = getValue(); if (money != null) { calculator.setValue(money.getValue()); } else { calculator.setValue(0.0); } // calculate POP (point of presentation) Point point = ((JComponent) e.getSource()).getLocationOnScreen(); int x = point.x + e.getX(); int y = point.y + e.getY(); // ensure that it does not exceed the screen limits Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); Dimension dim = calculatorDialog.getPreferredSize(); if (x + dim.width >= screenDim.width) { x = screenDim.width - dim.width - 1; } if (y + dim.height >= screenDim.height) { y = screenDim.height - dim.height - 1; } // make it visible at wanted location calculatorDialog.setLocation(x, y); calculatorDialog.show(); }
/** * Show the dialog box. The dialog is automatically centered on the parent window, or on the * screen if there is no parent. * * <p>This method always returns immediately after showing the dialog box. However, if the dialog * has a parent, the dialog defaults to modal. When modal, interaction with the application will * be blocked until this dialog box is closed by calling the hide() method. If the dialog has no * parent, it is not modal and application interaction is not blocked. * * <p>While the dialog box is up, an internal thread monitors changes to the dialog box's * parameters and keeps the dialog drawn and uptodate. */ public void show() { // Center final Rectangle windowDim = this.getBounds(); int x, y; if (this.parent == null) { // Center on the screen. final Toolkit toolkit = Toolkit.getDefaultToolkit(); final Dimension screenDim = toolkit.getScreenSize(); x = screenDim.width / 2 - windowDim.width / 2; y = screenDim.height / 2 - windowDim.height / 2; } else { // Center on the parent. final Rectangle parentDim = this.parent.getBounds(); x = parentDim.x + parentDim.width / 2 - windowDim.width / 2; y = parentDim.y + parentDim.height / 2 - windowDim.height / 2; } if (x < 0) { x = 0; } if (y < 0) { y = 0; } this.setLocation(x, y); // If the dialog box is not modal, just call the // superclass's show method. That method returns // quickly, and then we return. if (this.isModal() == false) { super.show(); return; } // Otherwise the dialog is modal. Start a thread // to show the dialog box. That thread will block // waiting for the dialog box to be hidden. final ProgressDialog thisDialog = this; final Thread showThread = new Thread( new Runnable() { public void run() { // Doesn't return until dialog is hidden. thisDialog.showIt(); } }); showThread.start(); // Return, leaving the dialog box up. }
protected void show0() { JRootPane rp = null; if (getOwner() instanceof JFrame) { rp = ((JFrame) getOwner()).getRootPane(); } else if (getOwner() instanceof JDialog) { rp = ((JDialog) getOwner()).getRootPane(); } if (rp != null && !isDocumentModalitySupported() && !isExperimentalSheet()) { ownersGlassPane = rp.getGlassPane(); JPanel blockingPanel = new JPanel(); blockingPanel.setOpaque(false); rp.setGlassPane(blockingPanel); blockingPanel.setVisible(true); } super.show(); }
public void setPanel(Parameters pp, String s) { JPanel buttonsPanel = new JPanel(); okButton = new JButton("确定"); okButton.addActionListener(this); dialog = new JDialog(this, s + " 参数选择", true); Container contentPane = getContentPane(); Container dialogContentPane = dialog.getContentPane(); dialogContentPane.add(pp, BorderLayout.CENTER); dialogContentPane.add(buttonsPanel, BorderLayout.SOUTH); dialog.pack(); buttonsPanel.add(okButton); dialog.setLocation(50, 330); dialog.show(); }
/** * Show tracker * * @param parent GUI parent widget */ public final void show(final Component parent) { Frame frame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent); dialog.getContentPane().setLayout(new BorderLayout()); label = new JLabel(START_HTML + labelText + END_HTML); JPanel labelPanel = new JPanel(); labelPanel.setLayout(new BorderLayout()); labelPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); labelPanel.add(label, BorderLayout.CENTER); dialog.getContentPane().add(labelPanel, BorderLayout.CENTER); dialog.pack(); Windows.centerOnScreen(dialog); dialog.show(); }
@SuppressWarnings("deprecation") @Override public void actionPerformed(ActionEvent ae) { if (ae.getActionCommand().equals("Выбрать")) { JFileChooser fileopen = new JFileChooser(); int ret = fileopen.showDialog(null, "Открыть файл"); file = fileopen.getSelectedFile(); label.setText(file.getName()); } if (ae.getActionCommand().equals("Послать")) { ou.setWayOfFile(file.getAbsolutePath()); ou.setNameOfFile(file.getName()); ou.setSizeOfFile(file.length()); progressBar.setMaximum((int) file.length()); b1.setVisible(false); b4.setEnabled(false); b2.setEnabled(false); ou.start(1); } if (ae.getActionCommand().equals("Соединить")) { ou.start(0); ou.stop(); } if (ae.getActionCommand().equals("Разорвать")) { ou.start(2); ou.stop(); } if (ae.getActionCommand().equals("Настройки")) { final JDialog jd = new JDialog(fr, "Настройки", true); JLabel label1 = new JLabel("COM порт"); JLabel label2 = new JLabel("Скорость"); JLabel label3 = new JLabel("Биты данных"); JLabel label4 = new JLabel("Стоп биты"); JLabel label5 = new JLabel("Четность"); ArrayList<String> list = new ArrayList<String>(); jd.setLayout(gbl); Enumeration portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement(); list.add(portId.getName()); } System.out.println(stopbits); final String[] speed1 = {"9600", "14400", "19200", "38400", "57600", "115200"}; final String[] databits1 = {"5", "6", "7", "8"}; final String[] stopbits1 = {"1", "1.5", "2"}; String[] parity1 = {"нет", "нечет", "чет", "'1'", "'0'"}; final JComboBox comboBox1 = new JComboBox(list.toArray()); Iterator<String> it = list.iterator(); int elem = 0; port = con.getPortNumber(); speed = con.getSpeed(); databits = con.getDatabits(); stopbits = con.getStopBits(); parity = con.getParity(); while (it.hasNext()) { if (it.next().equals(port)) { comboBox1.setSelectedIndex(elem); } elem++; } final JComboBox comboBox2 = new JComboBox(speed1); for (int i = 0; i < speed1.length; i++) { if (speed1[i].equals(Integer.toString(speed))) { comboBox2.setSelectedIndex(i); } } final JComboBox comboBox3 = new JComboBox(databits1); for (int i = 0; i < databits1.length; i++) { if (databits1[i].equals(Integer.toString(databits))) { comboBox3.setSelectedIndex(i); } } final JComboBox comboBox4 = new JComboBox(stopbits1); for (int i = 0; i < stopbits1.length; i++) { if (stopbits == 1) { comboBox4.setSelectedIndex(0); } if (stopbits == 3) { comboBox4.setSelectedIndex(1); } if (stopbits == 2) { comboBox4.setSelectedIndex(2); } } final JComboBox comboBox5 = new JComboBox(parity1); for (int i = 0; i < 5; i++) { if (parity == i) { comboBox5.setSelectedIndex(i); } } JButton but = new JButton("OK"); JButton but1 = new JButton("Подключиться к порту"); locationX = (screenSize.width - 270) / 2; locationY = (screenSize.height - 300) / 2; jd.setBounds(locationX, locationY, 300, 270); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("comboBoxChanged")) { if ((JComboBox) e.getSource() == comboBox1) { JComboBox box = (JComboBox) e.getSource(); port = (String) box.getSelectedItem(); } if ((JComboBox) e.getSource() == comboBox2) { JComboBox box = (JComboBox) e.getSource(); speed = Integer.parseInt((String) box.getSelectedItem()); } if ((JComboBox) e.getSource() == comboBox3) { JComboBox box = (JComboBox) e.getSource(); databits = Integer.parseInt((String) box.getSelectedItem()); } if ((JComboBox) e.getSource() == comboBox4) { JComboBox box = (JComboBox) e.getSource(); if ((String) box.getSelectedItem() == "1") { stopbits = 1; } if ((String) box.getSelectedItem() == "2") { stopbits = 2; } if ((String) box.getSelectedItem() == "1.5") { stopbits = 3; } } if ((JComboBox) e.getSource() == comboBox5) { String setter; JComboBox box = (JComboBox) e.getSource(); if ((String) box.getSelectedItem() == "нет") { parity = 0; } if ((String) box.getSelectedItem() == "нечет") { parity = 1; } if ((String) box.getSelectedItem() == "чет") { parity = 2; } if ((String) box.getSelectedItem() == "'1'") { parity = 3; } if ((String) box.getSelectedItem() == "'0'") { parity = 4; } } } if (e.getActionCommand().equals("OK")) { con.setPortParam(speed, databits, stopbits, parity, port); jd.setVisible(false); } if (e.getActionCommand().equals("Подключиться к порту")) { con.setPortParam(speed, databits, stopbits, parity, port); con.portConnect(port); ou = new Output(con, form); in = new Input(con, ou, form); // final JDialog jd1 = new JDialog(jd,"Сообщение",true); // GridBagLayout gbl=new GridBagLayout(); // jd1.setLayout(gbl); // JLabel label6 = new JLabel("Подключение выполнено"); // jd1.add(label6); // locationX = (screenSize.width - 100) / 2; // locationY = (screenSize.height - 100) / 2; // jd1.setBounds(locationX, locationY, 180, 120); // jd1.show(); JOptionPane optionPane = new JOptionPane(); optionPane.setMessage("Подключение выполнено"); optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); JDialog dialog = optionPane.createDialog("Cообщение"); dialog.show(); b3.setEnabled(true); jd.setVisible(false); } } }; comboBox1.addActionListener(actionListener); comboBox2.addActionListener(actionListener); comboBox3.addActionListener(actionListener); comboBox4.addActionListener(actionListener); comboBox5.addActionListener(actionListener); but.addActionListener(actionListener); but1.addActionListener(actionListener); gbc.insets = new Insets(10, 10, 0, 0); gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; gbl.setConstraints(label1, gbc); gbc.gridy = 2; gbl.setConstraints(label2, gbc); gbc.gridy = 3; gbl.setConstraints(label3, gbc); gbc.gridy = 4; gbl.setConstraints(label4, gbc); gbc.gridy = 5; gbl.setConstraints(label5, gbc); gbc.insets = new Insets(10, 20, 0, 0); gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridx = 2; gbc.fill = GridBagConstraints.HORIZONTAL; gbl.setConstraints(comboBox1, gbc); gbc.gridy = 2; gbl.setConstraints(comboBox2, gbc); gbc.gridy = 3; gbl.setConstraints(comboBox3, gbc); gbc.gridy = 4; gbl.setConstraints(comboBox4, gbc); gbc.gridy = 5; gbl.setConstraints(comboBox5, gbc); gbc.insets = new Insets(10, 10, 10, 0); gbc.gridy = 6; gbc.gridwidth = 1; gbc.gridx = 2; gbl.setConstraints(but, gbc); gbc.insets = new Insets(10, 10, 10, 0); gbc.gridx = 1; gbl.setConstraints(but1, gbc); jd.add(label1); jd.add(label2); jd.add(label3); jd.add(label4); jd.add(label5); jd.add(comboBox1); jd.add(comboBox2); jd.add(comboBox3); jd.add(comboBox4); jd.add(comboBox5); jd.add(but); jd.add(but1); jd.show(); } if (ae.getActionCommand().equals("О программе")) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int locationX = (screenSize.width - 100) / 2; int locationY = (screenSize.height - 100) / 2; final JDialog jd2 = new JDialog(); GridBagLayout gbl = new GridBagLayout(); jd2.setLayout(gbl); JLabel label6 = new JLabel("Курсовая работа по курсу 'Сетевые технологии'"); gbc.fill = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 0, 0, 0); gbc.gridy = 1; gbc.gridx = 1; gbl.setConstraints(label6, gbc); jd2.add(label6); JLabel label7 = new JLabel("Шевченко П.А.(ИУ5-74) и Федоров Д.Б.(ИУ5-79)"); gbc.gridy = 2; gbc.gridx = 1; gbl.setConstraints(label7, gbc); jd2.add(label7); JLabel label8 = new JLabel("2011 г."); gbc.gridy = 3; gbc.gridx = 1; gbl.setConstraints(label8, gbc); jd2.add(label8); jd2.setBounds(locationX, locationY, 500, 120); jd2.show(); } if (ae.getActionCommand().equals("Выход")) { System.exit(0); } }
public void show() { super.show(); toFront(); myLabel.paintImmediately(0, 0, myImage.getIconWidth(), myImage.getIconHeight()); }
public void show() { addDatalogData(); super.show(); }
public static boolean showLicensing() { if (Config.getLicenseResource() == null) return true; ClassLoader cl = Main.class.getClassLoader(); URL url = cl.getResource(Config.getLicenseResource()); if (url == null) return true; String license = null; try { URLConnection con = url.openConnection(); int size = con.getContentLength(); byte[] content = new byte[size]; InputStream in = new BufferedInputStream(con.getInputStream()); in.read(content); license = new String(content); } catch (IOException ioe) { Config.trace("Got exception when reading " + Config.getLicenseResource() + ": " + ioe); return false; } // Build dialog JTextArea ta = new JTextArea(license); ta.setEditable(false); final JDialog jd = new JDialog(_installerFrame, true); Container comp = jd.getContentPane(); jd.setTitle(Config.getLicenseDialogTitle()); comp.setLayout(new BorderLayout(10, 10)); comp.add(new JScrollPane(ta), "Center"); Box box = new Box(BoxLayout.X_AXIS); box.add(box.createHorizontalStrut(10)); box.add(new JLabel(Config.getLicenseDialogQuestionString())); box.add(box.createHorizontalGlue()); JButton acceptButton = new JButton(Config.getLicenseDialogAcceptString()); JButton exitButton = new JButton(Config.getLicenseDialogExitString()); box.add(acceptButton); box.add(box.createHorizontalStrut(10)); box.add(exitButton); box.add(box.createHorizontalStrut(10)); jd.getRootPane().setDefaultButton(acceptButton); Box box2 = new Box(BoxLayout.Y_AXIS); box2.add(box); box2.add(box2.createVerticalStrut(5)); comp.add(box2, "South"); jd.pack(); final boolean accept[] = new boolean[1]; acceptButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { accept[0] = true; jd.hide(); jd.dispose(); } }); exitButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { accept[0] = false; jd.hide(); jd.dispose(); } }); // Apply any defaults the user may have, constraining to the size // of the screen, and default (packed) size. Rectangle size = new Rectangle(0, 0, 500, 300); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); size.width = Math.min(screenSize.width, size.width); size.height = Math.min(screenSize.height, size.height); // Center the window jd.setBounds( (screenSize.width - size.width) / 2, (screenSize.height - size.height) / 2, size.width, size.height); // Show dialog jd.show(); return accept[0]; }
/** Show the dialog box via the superclass. This method is only called by the show thread. */ private void showIt() { super.show(); }
@Override @SuppressWarnings("deprecation") public void show() { myFocusTrackback = new FocusTrackback(getDialogWrapper(), getParent(), true); final DialogWrapper dialogWrapper = getDialogWrapper(); boolean isAutoAdjustable = dialogWrapper.isAutoAdjustable(); Point location = null; if (isAutoAdjustable) { pack(); Dimension packedSize = getSize(); Dimension minSize = getMinimumSize(); setSize( Math.max(packedSize.width, minSize.width), Math.max(packedSize.height, minSize.height)); setSize( (int) (getWidth() * dialogWrapper.getHorizontalStretch()), (int) (getHeight() * dialogWrapper.getVerticalStretch())); // Restore dialog's size and location myDimensionServiceKey = dialogWrapper.getDimensionKey(); if (myDimensionServiceKey != null) { final Project projectGuess = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(this)); location = DimensionService.getInstance().getLocation(myDimensionServiceKey, projectGuess); Dimension size = DimensionService.getInstance().getSize(myDimensionServiceKey, projectGuess); if (size != null) { myInitialSize = new Dimension(size); _setSizeForLocation(myInitialSize.width, myInitialSize.height, location); } } if (myInitialSize == null) { myInitialSize = getSize(); } } if (location == null) { location = dialogWrapper.getInitialLocation(); } if (location != null) { setLocation(location); } else { setLocationRelativeTo(getOwner()); } if (isAutoAdjustable) { final Rectangle bounds = getBounds(); ScreenUtil.fitToScreen(bounds); setBounds(bounds); } addWindowListener( new WindowAdapter() { @Override public void windowActivated(WindowEvent e) { final DialogWrapper wrapper = getDialogWrapper(); if (wrapper != null && myFocusTrackback != null) { myFocusTrackback.cleanParentWindow(); myFocusTrackback.registerFocusComponent( new FocusTrackback.ComponentQuery() { @Override public Component getComponent() { return wrapper.getPreferredFocusedComponent(); } }); } } @Override public void windowDeactivated(WindowEvent e) { if (!isModal()) { final Ref<IdeFocusManager> focusManager = new Ref<IdeFocusManager>(null); Project project = getProject(); if (project != null && !project.isDisposed()) { focusManager.set(getFocusManager()); focusManager .get() .doWhenFocusSettlesDown( new Runnable() { @Override public void run() { disposeFocusTrackbackIfNoChildWindowFocused(focusManager.get()); } }); } else { disposeFocusTrackbackIfNoChildWindowFocused(focusManager.get()); } } } @Override public void windowOpened(WindowEvent e) { if (!SystemInfo.isMacOSLion) return; Window window = e.getWindow(); if (window instanceof Dialog) { ID _native = MacUtil.findWindowForTitle(((Dialog) window).getTitle()); if (_native != null && _native.intValue() > 0) { // see MacMainFrameDecorator // NSCollectionBehaviorFullScreenAuxiliary = 1 << 8 Foundation.invoke(_native, "setCollectionBehavior:", 1 << 8); } } } }); if (Registry.is("actionSystem.fixLostTyping")) { final IdeEventQueue queue = IdeEventQueue.getInstance(); if (queue != null) { queue.getKeyEventDispatcher().resetState(); } // if (myProject != null) { // Project project = myProject.get(); // if (project != null && !project.isDisposed() && project.isInitialized()) { // // IdeFocusManager.findInstanceByComponent(this).requestFocus(new // MyFocusCommand(dialogWrapper), true); // } // } } if (SystemInfo.isMac && myProject != null && Registry.is("ide.mac.fix.dialog.showing") && !dialogWrapper.isModalProgress()) { final IdeFrame frame = WindowManager.getInstance().getIdeFrame(myProject.get()); AppIcon.getInstance().requestFocus(frame); } setBackground(UIUtil.getPanelBackground()); final ApplicationEx app = ApplicationManagerEx.getApplicationEx(); if (app != null && !app.isLoaded() && Splash.BOUNDS != null) { final Point loc = getLocation(); loc.y = Splash.BOUNDS.y + Splash.BOUNDS.height; setLocation(loc); } super.show(); }