/** 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 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(); }
public EchoAWT() throws UnknownHostException { super("채팅 프로그램"); // 각종 정의 h = new JPanel(new GridLayout(2, 3)); m = new JPanel(new BorderLayout()); f = new JPanel(new BorderLayout()); s = new JPanel(new BorderLayout()); login = new JPanel(new BorderLayout()); // name = new JLabel(" 사용자 이름 "); name = new JLabel(" 메세지 입력 "); jta = new JTextArea(); // clientList = new JTextArea(0, 10); clientList = new JList(); jsp = new JScrollPane(jta); list = new JScrollPane(clientList); jtf = new JTextField("입력하세요."); hi = new JTextField("HOST IP 입력"); pi = new JTextField("PORT 입력"); localport = new JTextField("원하는 PORT 입력"); lid = new JTextField("ID를 입력하세요."); lpw = new JTextField("PW를 입력하세요."); serveropen = new JButton("서버 오픈"); textin = new JButton("입력"); clientin = new JButton("서버 접속"); conf = new JButton("로그인"); join = new JButton("회원가입"); addr = InetAddress.getLocalHost(); // 사용자 해상도 및 창 크기 설정 및 가져오기. Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize = tk.getScreenSize(); setSize(500, 500); Dimension d = getSize(); // 각종 버튼 및 텍스트 필드 리스너 jtf.addActionListener(this); hi.addActionListener(this); pi.addActionListener(this); localport.addActionListener(this); lid.addActionListener(this); lpw.addActionListener(this); conf.addActionListener(this); join.addActionListener(this); serveropen.addActionListener(this); clientin.addActionListener(this); textin.addActionListener(this); jtf.addFocusListener(this); hi.addFocusListener(this); pi.addFocusListener(this); localport.addFocusListener(this); lid.addFocusListener(this); lpw.addFocusListener(this); // 서버 접속 h.add(hi); h.add(pi); h.add(clientin); // 서버 생성 h.add(new JLabel("IP : " + addr.getHostAddress(), (int) CENTER_ALIGNMENT)); h.add(localport); h.add(serveropen); // 채팅글창 글 작성 막기 jta.setEditable(false); // 접속자 리스트 width 제한 clientList.setFixedCellWidth(d.width / 3); // 입력 창 f.add(name, "West"); f.add(jtf, "Center"); f.add(textin, "East"); // 접속자 확인창 s.add(new JLabel("접속자", (int) CENTER_ALIGNMENT), "North"); s.add(list, "Center"); // clientList.setEditable(false); // 메인 창 m.add(jsp, "Center"); m.add(s, "East"); // 프레임 설정 add(h, "North"); add(m, "Center"); add(f, "South"); // 로그인 다이얼로그 jd = new JDialog(); jd.setTitle("채팅 로그인"); jd.add(login); jd.setSize(200, 200); Dimension dd = jd.getSize(); jd.setLocation(screenSize.width / 2 - (dd.width / 2), screenSize.height / 2 - (dd.height / 2)); jd.setVisible(true); // 로그인창 JPanel lm = new JPanel(new GridLayout(4, 1)); lm.add(lid); lm.add(new Label()); lm.add(lpw); lm.add(new Label()); JPanel bt = new JPanel(); bt.add(conf); bt.add(join); login.add(new Label(), "North"); login.add(new Label(), "West"); login.add(new Label(), "East"); login.add(lm, "Center"); login.add(bt, "South"); // 창의 위치, 보임, EXIT 단추 활성화. setLocation(screenSize.width / 2 - (d.width / 2), screenSize.height / 2 - (d.height / 2)); setVisible(false); setDefaultCloseOperation(EXIT_ON_CLOSE); }
protected boolean exportApplicationPrompt() throws IOException, SketchException { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(Box.createVerticalStrut(6)); // Box panel = Box.createVerticalBox(); // Box labelBox = Box.createHorizontalBox(); // String msg = "<html>Click Export to Application to create a standalone, " + // "double-clickable application for the selected plaforms."; // String msg = "Export to Application creates a standalone, \n" + // "double-clickable application for the selected plaforms."; String line1 = "Export to Application creates double-clickable,"; String line2 = "standalone applications for the selected plaforms."; JLabel label1 = new JLabel(line1, SwingConstants.CENTER); JLabel label2 = new JLabel(line2, SwingConstants.CENTER); label1.setAlignmentX(Component.LEFT_ALIGNMENT); label2.setAlignmentX(Component.LEFT_ALIGNMENT); // label1.setAlignmentX(); // label2.setAlignmentX(0); panel.add(label1); panel.add(label2); int wide = label2.getPreferredSize().width; panel.add(Box.createVerticalStrut(12)); final JCheckBox windowsButton = new JCheckBox("Windows"); // windowsButton.setMnemonic(KeyEvent.VK_W); windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows")); windowsButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean( "export.application.platform.windows", windowsButton.isSelected()); } }); final JCheckBox macosxButton = new JCheckBox("Mac OS X"); // macosxButton.setMnemonic(KeyEvent.VK_M); macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx")); macosxButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected()); } }); final JCheckBox linuxButton = new JCheckBox("Linux"); // linuxButton.setMnemonic(KeyEvent.VK_L); linuxButton.setSelected(Preferences.getBoolean("export.application.platform.linux")); linuxButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.platform.linux", linuxButton.isSelected()); } }); JPanel platformPanel = new JPanel(); // platformPanel.setLayout(new BoxLayout(platformPanel, BoxLayout.X_AXIS)); platformPanel.add(windowsButton); platformPanel.add(Box.createHorizontalStrut(6)); platformPanel.add(macosxButton); platformPanel.add(Box.createHorizontalStrut(6)); platformPanel.add(linuxButton); platformPanel.setBorder(new TitledBorder("Platforms")); // Dimension goodIdea = new Dimension(wide, platformPanel.getPreferredSize().height); // platformPanel.setMaximumSize(goodIdea); wide = Math.max(wide, platformPanel.getPreferredSize().width); platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT); panel.add(platformPanel); // Box indentPanel = Box.createHorizontalBox(); // indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width)); final JCheckBox showStopButton = new JCheckBox("Show a Stop button"); // showStopButton.setMnemonic(KeyEvent.VK_S); showStopButton.setSelected(Preferences.getBoolean("export.application.stop")); showStopButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.stop", showStopButton.isSelected()); } }); showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen")); showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13)); // indentPanel.add(showStopButton); // indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT); final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)"); // fullscreenButton.setMnemonic(KeyEvent.VK_F); fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen")); fullScreenButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean sal = fullScreenButton.isSelected(); Preferences.setBoolean("export.application.fullscreen", sal); showStopButton.setEnabled(sal); } }); fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13)); JPanel optionPanel = new JPanel(); optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS)); optionPanel.add(fullScreenButton); optionPanel.add(showStopButton); // optionPanel.add(indentPanel); optionPanel.setBorder(new TitledBorder("Options")); wide = Math.max(wide, platformPanel.getPreferredSize().width); // goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height); optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT); // optionPanel.setMaximumSize(goodIdea); panel.add(optionPanel); Dimension good; // label1, label2, platformPanel, optionPanel good = new Dimension(wide, label1.getPreferredSize().height); label1.setMaximumSize(good); good = new Dimension(wide, label2.getPreferredSize().height); label2.setMaximumSize(good); good = new Dimension(wide, platformPanel.getPreferredSize().height); platformPanel.setMaximumSize(good); good = new Dimension(wide, optionPanel.getPreferredSize().height); optionPanel.setMaximumSize(good); // JPanel actionPanel = new JPanel(); // optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS)); // optionPanel.add(Box.createHorizontalGlue()); // final JDialog frame = new JDialog(editor, "Export to Application"); // JButton cancelButton = new JButton("Cancel"); // cancelButton.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // frame.dispose(); // return false; // } // }); // Add the buttons in platform-specific order // if (PApplet.platform == PConstants.MACOSX) { // optionPanel.add(cancelButton); // optionPanel.add(exportButton); // } else { // optionPanel.add(exportButton); // optionPanel.add(cancelButton); // } String[] options = {"Export", "Cancel"}; final JOptionPane optionPane = new JOptionPane( panel, JOptionPane.PLAIN_MESSAGE, // JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]); final JDialog dialog = new JDialog(this, "Export Options", true); dialog.setContentPane(optionPane); optionPane.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { // If you were going to check something // before closing the window, you'd do // it here. dialog.setVisible(false); } } }); dialog.pack(); dialog.setResizable(false); Rectangle bounds = getBounds(); dialog.setLocation( bounds.x + (bounds.width - dialog.getSize().width) / 2, bounds.y + (bounds.height - dialog.getSize().height) / 2); dialog.setVisible(true); Object value = optionPane.getValue(); if (value.equals(options[0])) { return jmode.handleExportApplication(sketch); } else if (value.equals(options[1]) || value.equals(new Integer(-1))) { // closed window by hitting Cancel or ESC statusNotice("Export to Application canceled."); } return false; }
/** * Create a new ProjectionManager. * * @param parent JFrame (application) or JApplet (applet) * @param projections list of initial projections * @param makeDialog true to make this a dialog * @param helpId help id if dialog * @param maps List of MapData */ public ProjectionManager( RootPaneContainer parent, List projections, boolean makeDialog, String helpId, List maps) { this.helpId = helpId; this.maps = maps; this.parent = parent; // manage NewProjectionListeners lm = new ListenerManager( "java.beans.PropertyChangeListener", "java.beans.PropertyChangeEvent", "propertyChange"); // here's where the map will be drawn: but cant be changed/edited npViewControl = new NPController(); if (maps == null) { maps = getDefaultMaps(); // we use the system default } for (int mapIdx = 0; mapIdx < maps.size(); mapIdx++) { MapData mapData = (MapData) maps.get(mapIdx); if (mapData.getVisible()) { npViewControl.addMap(mapData.getSource(), mapData.getColor()); } } mapViewPanel = npViewControl.getNavigatedPanel(); mapViewPanel.setPreferredSize(new Dimension(250, 250)); mapViewPanel.setToolTipText("Shows the default zoom of the current projection"); mapViewPanel.setChangeable(false); if ((projections == null) || (projections.size() == 0)) { projections = makeDefaultProjections(); } // the actual list is a JTable subclass projTable = new JTableProjection(this, projections); JComponent listContents = new JScrollPane(projTable); JComponent buttons = GuiUtils.hbox( GuiUtils.makeButton("Edit", this, "doEdit"), GuiUtils.makeButton("New", this, "doNew"), GuiUtils.makeButton("Export", this, "doExport"), GuiUtils.makeButton("Delete", this, "doDelete")); mapLabel = new JLabel(" "); JComponent leftPanel = GuiUtils.inset(GuiUtils.topCenter(mapLabel, mapViewPanel), 5); JComponent rightPanel = GuiUtils.topCenter(buttons, listContents); rightPanel = GuiUtils.inset(rightPanel, 5); contents = GuiUtils.inset(GuiUtils.hbox(leftPanel, rightPanel), 5); // default current and working projection if (null != (current = projTable.getSelected())) { setWorkingProjection(current); projTable.setCurrentProjection(current); mapLabel.setText(current.getName()); } /* listen for new working Projections from projTable */ projTable.addNewProjectionListener( new NewProjectionListener() { public void actionPerformed(NewProjectionEvent e) { if (e.getProjection() != null) { setWorkingProjection(e.getProjection()); } } }); eventsOK = true; // put it together in the viewDialog if (makeDialog) { Container buttPanel = GuiUtils.makeApplyOkHelpCancelButtons(this); contents = GuiUtils.centerBottom(contents, buttPanel); viewDialog = GuiUtils.createDialog(GuiUtils.getApplicationTitle() + "Projection Manager", false); viewDialog.getContentPane().add(contents); viewDialog.pack(); ucar.unidata.util.Msg.translateTree(viewDialog); viewDialog.setLocation(100, 100); } }