/** 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(); }
@Override public void actionPerformed(ActionEvent actionEvent) { Dimension all = parent.getSize(); Dimension d = dialog.getSize(); dialog.setLocation((all.width - d.width) / 2, (all.height - d.height) / 2); dialog.setVisible(true); }
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(); }
/** * @param editor * @param idDialog * @param dialog * @param title */ public static void setDialogVisible( @Nullable Editor editor, String idDialog, JDialog dialog, String title) { Point location = null; if (editor != null) { Point caretLocation = editor.visualPositionToXY(editor.getCaretModel().getVisualPosition()); SwingUtilities.convertPointToScreen(caretLocation, editor.getComponent()); String[] position = UtilsPreferences.getDialogPosition(idDialog).split("x"); if (!(position[0].equals("0") && position[1].equals("0"))) { location = new Point(Integer.parseInt(position[0]), Integer.parseInt(position[1])); } } if (location == null) { // Center to screen dialog.setLocationRelativeTo(null); } else { dialog.setLocation(location.x, location.y); } dialog.setTitle(title); dialog.pack(); dialog.setVisible(true); }
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(); }
/** Create and show the gui */ public void showDialog() { if (dialog == null) { JFrame parentFrame = persistenceManager.getIdv().getIdvUIManager().getFrame(); dialog = new JDialog(parentFrame, "Loading Bundle"); if (dialogTitle != null) { dialog.setTitle("Loading Bundle: " + dialogTitle); } dialog.getContentPane().add(contents); } dialog.pack(); Point center = GuiUtils.getLocation(null); if (persistenceManager.getIdv().okToShowWindows()) { dialog.setLocation(20, 20); dialog.setVisible(true); } }
/** Sets the location on the given dialog for the given index. */ private void setLocation(JDialog dialog, int index) { Rectangle bounds = dialog.getBounds(); JFrame frame = findOwner(); Dimension dim; if (frame == null) { dim = Toolkit.getDefaultToolkit().getScreenSize(); } else { dim = frame.getSize(); } int x = (int) (150 * Math.cos(index * 15 * (Math.PI / 180))); int y = (int) (150 * Math.sin(index * 15 * (Math.PI / 180))); x += (dim.width - bounds.width) / 2; y += (dim.height - bounds.height) / 2; dialog.setLocation(x, y); }
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 DialogPopupWrapper(Component owner, Component content, int x, int y) { if (!owner.isShowing()) { throw new IllegalArgumentException("Popup owner must be showing"); } final Window wnd = owner instanceof Window ? (Window) owner : SwingUtilities.getWindowAncestor(owner); if (wnd instanceof Frame) { myDialog = new JDialog((Frame) wnd, false); } else { myDialog = new JDialog((Dialog) wnd, false); } myDialog.getContentPane().setLayout(new BorderLayout()); myDialog.getContentPane().add(content, BorderLayout.CENTER); myDialog.setUndecorated(true); myDialog.pack(); myDialog.setLocation(x, y); }
public void showDialog(ScreenType diag) { assert (diag == ScreenType.HIGHSCORE || diag == ScreenType.PAUSE || diag == ScreenType.SETUP); JDialog show = null; switch (diag) { case HIGHSCORE: show = mHighScoreDialog; break; case PAUSE: show = mPauseMenuDialog; break; case SETUP: show = mGameSetupDialog; break; } if (show != null) { show.setLocation( (int) 0.5 * (this.getWidth() - show.getWidth()), (int) 0.5 * (this.getHeight() - show.getHeight())); show.setVisible(true); } }
private void mouseClicked_searchSource() { SourceSearchPanel ssp = new SourceSearchPanel(); Point p = getLocation(); orgSearchDialog.setLocation(p.x + 50, p.y + 50); ssp.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Source source = (Source) e.getSource(); setToAddress(source.getName() + " <" + source.getEmail() + ">"); orgSearchDialog.dispose(); } }); orgSearchDialog.getContentPane().add(ssp); orgSearchDialog.pack(); orgSearchDialog.setVisible(true); }
/** * _more_ * * @return _more_ */ private boolean windowOk() { getContents(); if (contents == null) { return false; } if (shouldMakeDialog()) { if (dialog == null) { dialog = new JDialog((Frame) null, getWindowTitle(), false); LogUtil.registerWindow(dialog); GuiUtils.packDialog(dialog, contents); dialog.setLocation(100, 100); window = dialog; } } else { if (frame == null) { frame = new JFrame(getWindowTitle()); if (menuBar != null) { GuiUtils.decorateFrame(frame, menuBar); } LogUtil.registerWindow(frame); frame.getContentPane().add(contents); frame.pack(); Msg.translateTree(frame); frame.setLocation(100, 100); window = frame; } } if (window != null) { window.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { windowIsClosing(); } }); } return window != null; }
public void actionPerformed(ActionEvent e) { if (e.getSource() == addbt) { if (bankAccountBLService != null) { JDialog dialog = new JDialog(parent, "新建银行账户", true); dialog .getContentPane() .add(new BankAccountAddPanel(parent, dialog, this, bankAccountBLService)); dialog.setLocationRelativeTo(parent); dialog.setLocation(dialog.getX() / 2, dialog.getY() / 2); dialog.pack(); dialog.setVisible(true); } else { initBL(); } } else if (e.getSource() == deletebt) { int row = table.getSelectedRow(); if (row >= 0) { if (bankAccountBLService != null) { String account = (String) table.getValueAt(row, 0); try { bankAccountBLService.deleteBankAccount(account); refresh(); new TranslucentFrame(this, MessageType.DELETE_SUCCESS, Color.GREEN); } catch (RemoteException e1) { new TranslucentFrame(this, MessageType.RMI_LAG, Color.ORANGE); } catch (SQLException e1) { System.out.println(e1.getMessage()); } } else { initBL(); } } } else if (e.getSource() == refreshbt) { refresh(); new TranslucentFrame(this, "刷新成功", Color.GREEN); } }
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); }
public void show(List<Rule> rules) { if (original != null) config.restoreState(original); dialog = new JDialog(owner, true); dialog.setTitle(messages.getString("guiConfigWindowTitle")); Collections.sort(rules, new CategoryComparator()); // close dialog when user presses Escape key: final KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); final ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent actionEvent) { dialog.setVisible(false); } }; final JRootPane rootPane = dialog.getRootPane(); rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); // JPanel final JPanel checkBoxPanel = new JPanel(); checkBoxPanel.setLayout(new GridBagLayout()); GridBagConstraints cons = new GridBagConstraints(); cons.anchor = GridBagConstraints.NORTHWEST; cons.gridx = 0; cons.weightx = 1.0; cons.weighty = 1.0; cons.fill = GridBagConstraints.BOTH; DefaultMutableTreeNode rootNode = createTree(rules); DefaultTreeModel treeModel = new DefaultTreeModel(rootNode); treeModel.addTreeModelListener( new TreeModelListener() { @Override public void treeNodesChanged(TreeModelEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getTreePath().getLastPathComponent(); int index = e.getChildIndices()[0]; node = (DefaultMutableTreeNode) (node.getChildAt(index)); if (node instanceof RuleNode) { RuleNode o = (RuleNode) node; if (o.getRule().isDefaultOff()) { if (o.isEnabled()) { config.getEnabledRuleIds().add(o.getRule().getId()); } else { config.getEnabledRuleIds().remove(o.getRule().getId()); } } else { if (o.isEnabled()) { config.getDisabledRuleIds().remove(o.getRule().getId()); } else { config.getDisabledRuleIds().add(o.getRule().getId()); } } } if (node instanceof CategoryNode) { CategoryNode o = (CategoryNode) node; if (o.isEnabled()) { config.getDisabledCategoryNames().remove(o.getCategory().getName()); } else { config.getDisabledCategoryNames().add(o.getCategory().getName()); } } } @Override public void treeNodesInserted(TreeModelEvent e) {} @Override public void treeNodesRemoved(TreeModelEvent e) {} @Override public void treeStructureChanged(TreeModelEvent e) {} }); configTree = new JTree(treeModel); configTree.setRootVisible(false); configTree.setEditable(false); configTree.setCellRenderer(new CheckBoxTreeCellRenderer()); TreeListener.install(configTree); checkBoxPanel.add(configTree, cons); MouseAdapter ma = new MouseAdapter() { private void handlePopupEvent(MouseEvent e) { final JTree tree = (JTree) e.getSource(); TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); TreePath[] paths = tree.getSelectionPaths(); boolean isSelected = false; if (paths != null) { for (TreePath selectionPath : paths) { if (selectionPath.equals(path)) { isSelected = true; } } } if (!isSelected) { tree.setSelectionPath(path); } if (node.isLeaf()) { JPopupMenu popup = new JPopupMenu(); final JMenuItem aboutRuleMenuItem = new JMenuItem(messages.getString("guiAboutRuleMenu")); aboutRuleMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { RuleNode node = (RuleNode) tree.getSelectionPath().getLastPathComponent(); Rule rule = node.getRule(); Language lang = config.getLanguage(); if (lang == null) { lang = Language.getLanguageForLocale(Locale.getDefault()); } Tools.showRuleInfoDialog( tree, messages.getString("guiAboutRuleTitle"), rule.getDescription(), rule, messages, lang.getShortNameWithCountryAndVariant()); } }); popup.add(aboutRuleMenuItem); popup.show(tree, e.getX(), e.getY()); } } @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } }; configTree.addMouseListener(ma); final JPanel treeButtonPanel = new JPanel(); cons = new GridBagConstraints(); cons.gridx = 0; cons.gridy = 0; final JButton expandAllButton = new JButton(messages.getString("guiExpandAll")); treeButtonPanel.add(expandAllButton, cons); expandAllButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TreeNode root = (TreeNode) configTree.getModel().getRoot(); TreePath parent = new TreePath(root); for (Enumeration categ = root.children(); categ.hasMoreElements(); ) { TreeNode n = (TreeNode) categ.nextElement(); TreePath child = parent.pathByAddingChild(n); configTree.expandPath(child); } } }); cons.gridx = 1; cons.gridy = 0; final JButton collapseAllbutton = new JButton(messages.getString("guiCollapseAll")); treeButtonPanel.add(collapseAllbutton, cons); collapseAllbutton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TreeNode root = (TreeNode) configTree.getModel().getRoot(); TreePath parent = new TreePath(root); for (Enumeration categ = root.children(); categ.hasMoreElements(); ) { TreeNode n = (TreeNode) categ.nextElement(); TreePath child = parent.pathByAddingChild(n); configTree.collapsePath(child); } } }); final JPanel motherTonguePanel = new JPanel(); motherTonguePanel.add(new JLabel(messages.getString("guiMotherTongue")), cons); motherTongueBox = new JComboBox(getPossibleMotherTongues()); if (config.getMotherTongue() != null) { motherTongueBox.setSelectedItem(config.getMotherTongue().getTranslatedName(messages)); } motherTongueBox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { Language motherTongue; if (motherTongueBox.getSelectedItem() instanceof String) { motherTongue = getLanguageForLocalizedName(motherTongueBox.getSelectedItem().toString()); } else { motherTongue = (Language) motherTongueBox.getSelectedItem(); } config.setMotherTongue(motherTongue); } } }); motherTonguePanel.add(motherTongueBox, cons); final JPanel portPanel = new JPanel(); portPanel.setLayout(new GridBagLayout()); // TODO: why is this now left-aligned?!?! cons = new GridBagConstraints(); cons.insets = new Insets(0, 4, 0, 0); cons.gridx = 0; cons.gridy = 0; cons.anchor = GridBagConstraints.WEST; cons.fill = GridBagConstraints.NONE; cons.weightx = 0.0f; if (!insideOOo) { serverCheckbox = new JCheckBox(Tools.getLabel(messages.getString("guiRunOnPort"))); serverCheckbox.setMnemonic(Tools.getMnemonic(messages.getString("guiRunOnPort"))); serverCheckbox.setSelected(config.getRunServer()); portPanel.add(serverCheckbox, cons); serverCheckbox.addActionListener( new ActionListener() { @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { serverPortField.setEnabled(serverCheckbox.isSelected()); serverSettingsCheckbox.setEnabled(serverCheckbox.isSelected()); } }); serverCheckbox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setRunServer(serverCheckbox.isSelected()); } }); serverPortField = new JTextField(Integer.toString(config.getServerPort())); serverPortField.setEnabled(serverCheckbox.isSelected()); serverSettingsCheckbox = new JCheckBox(Tools.getLabel(messages.getString("useGUIConfig"))); // TODO: without this the box is just a few pixels small, but why??: serverPortField.setMinimumSize(new Dimension(100, 25)); cons.gridx = 1; portPanel.add(serverPortField, cons); serverPortField .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void removeUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void changedUpdate(DocumentEvent e) { try { int serverPort = Integer.parseInt(serverPortField.getText()); if (serverPort > -1 && serverPort < 65536) { serverPortField.setForeground(null); config.setServerPort(serverPort); } else { serverPortField.setForeground(Color.RED); } } catch (NumberFormatException ex) { serverPortField.setForeground(Color.RED); } } }); cons.gridx = 0; cons.gridy = 10; serverSettingsCheckbox.setMnemonic(Tools.getMnemonic(messages.getString("useGUIConfig"))); serverSettingsCheckbox.setSelected(config.getUseGUIConfig()); serverSettingsCheckbox.setEnabled(config.getRunServer()); serverSettingsCheckbox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setUseGUIConfig(serverSettingsCheckbox.isSelected()); } }); portPanel.add(serverSettingsCheckbox, cons); } final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton"))); okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton"))); okButton.addActionListener(this); cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton"))); cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton"))); cancelButton.addActionListener(this); cons = new GridBagConstraints(); cons.insets = new Insets(0, 4, 0, 0); buttonPanel.add(okButton, cons); buttonPanel.add(cancelButton, cons); final Container contentPane = dialog.getContentPane(); contentPane.setLayout(new GridBagLayout()); cons = new GridBagConstraints(); cons.insets = new Insets(4, 4, 4, 4); cons.gridx = 0; cons.gridy = 0; cons.weightx = 10.0f; cons.weighty = 10.0f; cons.fill = GridBagConstraints.BOTH; contentPane.add(new JScrollPane(checkBoxPanel), cons); cons.gridx = 0; cons.gridy = 1; cons.weightx = 0.0f; cons.weighty = 0.0f; cons.fill = GridBagConstraints.NONE; cons.anchor = GridBagConstraints.LINE_END; contentPane.add(treeButtonPanel, cons); cons.gridx = 0; cons.gridy = 2; cons.weightx = 0.0f; cons.weighty = 0.0f; cons.fill = GridBagConstraints.NONE; cons.anchor = GridBagConstraints.WEST; contentPane.add(motherTonguePanel, cons); cons.gridx = 0; cons.gridy = 3; cons.weightx = 0.0f; cons.weighty = 0.0f; cons.fill = GridBagConstraints.NONE; cons.anchor = GridBagConstraints.WEST; contentPane.add(portPanel, cons); cons.gridx = 0; cons.gridy = 4; cons.weightx = 0.0f; cons.weighty = 0.0f; cons.fill = GridBagConstraints.NONE; cons.anchor = GridBagConstraints.EAST; contentPane.add(buttonPanel, cons); dialog.pack(); dialog.setSize(500, 500); // center on screen: final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); final Dimension frameSize = dialog.getSize(); dialog.setLocation( screenSize.width / 2 - frameSize.width / 2, screenSize.height / 2 - frameSize.height / 2); dialog.setLocationByPlatform(true); dialog.setVisible(true); }
protected void handleExecute() { ImageView view = getSelectedView(); if (view != null) { ColorBarAnnotation cbar = (ColorBarAnnotation) view.getAnnotation(view.getSelectedPlot(), ColorBarAnnotation.ID); if (cbar == null) { cbar = new ColorBarAnnotation(view.getModel()); view.setAnnotation(view.getSelectedPlot(), cbar.getIdentifier(), cbar); } log.finest("retrieved color bar annotation for editing"); ColorBarAnnotationPresenter presenter = new ColorBarAnnotationPresenter(cbar); Container c = JOptionPane.getFrameForComponent(view); final JButton okButton = new JButton("OK"); okButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); dialog.dispose(); } }); final JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // view.setAnnotation(safeCopy); // icross.setLinePaint(safeCopy.getLinePaint()); // icross.setLineWidth(safeCopy.getLineWidth()); // icross.setGap(safeCopy.getGap()); // icross.setVisible(safeCopy.isVisible()); dialog.setVisible(false); dialog.dispose(); } }); final JButton applyButton = new JButton("Apply"); dialog = new JDialog(JOptionPane.getFrameForComponent(view)); dialog.setLayout(new BorderLayout()); Point p = c.getLocation(); JPanel mainPanel = new JPanel(); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 8, 15, 8)); mainPanel.setLayout(new BorderLayout()); JPanel buttonPanel = ButtonBarFactory.buildRightAlignedBar(okButton, cancelButton, applyButton); mainPanel.add(presenter.getComponent(), BorderLayout.CENTER); mainPanel.add(buttonPanel, BorderLayout.SOUTH); dialog.add(mainPanel, BorderLayout.CENTER); dialog.pack(); dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); dialog.setLocation( (int) (p.getX() + c.getWidth() / 2f), (int) (p.getY() + c.getHeight() / 2f)); dialog.setVisible(true); } }
public void createDialogBox(String Roll, String ExamYear) { RPS = new JDialog(); this.NumberOfCourses = DataTransfer.Courses.size(); this.Roll = Roll; this.ExamYear = ExamYear; this.Session = setSession(); final int Final = NumberOfCourses; final int Height = (Final * 40 + 270 > 600) ? Final * 40 + 270 : 600; Panel = new JPanel() { protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage( new ImageIcon(getClass().getResource("/Icons/8.jpg")).getImage(), 0, 0, 950, Height, null); ButtonBorder.paintBorder(this, g, 284, 84 + Final * 40 + 60 + 60, 252, 32); } }; Panel.setPreferredSize( new Dimension( 600, NumberOfCourses * 40 + 150 + 60 + 60)); // 50+(100*5+3*5)+50, 120+NumberOfCourses*30+(NumberOfCourses-1)*10+50+60 Panel.setLayout(null); RollLabel = new JLabel("Roll : " + this.Roll, SwingConstants.CENTER); RollLabel.setForeground(Color.WHITE); RollLabel.setFont(new Font("SERRIF", Font.BOLD, 15)); RollLabel.setBounds(112, 20, 615, 20); Panel.add(RollLabel); SessionLabel = new JLabel("Session : " + this.Session, SwingConstants.CENTER); SessionLabel.setForeground(Color.WHITE); SessionLabel.setFont(new Font("SERRIF", Font.BOLD, 15)); SessionLabel.setBounds(112, 40, 615, 20); Panel.add(SessionLabel); ColumnName = new JLabel("", SwingConstants.LEFT); ColumnName.setText( " COURSE NO. TOTAL MARKS GRADE POINT LETTER GRADE COURSE CREDIT EXAM-TYPE"); ColumnName.setForeground(Color.WHITE); ColumnName.setFont(new Font("SERRIF", Font.BOLD, 10)); ColumnName.setBounds(112, 80, 635, 30); Panel.add(ColumnName); TakenLabel1 = new JLabel("Credit Hour Taken : ", SwingConstants.RIGHT); TakenLabel1.setForeground(Color.WHITE); TakenLabel1.setFont(new Font("SERRIF", Font.ITALIC, 12)); TakenLabel1.setBounds(112, 85 + NumberOfCourses * 40 + 60, 130, 20); Panel.add(TakenLabel1); TakenLabel2 = new JLabel("", SwingConstants.LEFT); TakenLabel2.setForeground(Color.WHITE); TakenLabel2.setFont(new Font("SERRIF", Font.ITALIC, 12)); TakenLabel2.setBounds(242, 85 + NumberOfCourses * 40 + 60, 50, 20); Panel.add(TakenLabel2); CompletedLabel1 = new JLabel("Credit Hour Completed : ", SwingConstants.RIGHT); CompletedLabel1.setForeground(Color.WHITE); CompletedLabel1.setFont( new Font("SERRIF", Font.ITALIC, 12)); // 50,85+NumberOfCourses*40+60+20,150,20 CompletedLabel1.setBounds(342, 85 + NumberOfCourses * 40 + 60, 150, 20); Panel.add(CompletedLabel1); CompletedLabel2 = new JLabel("opps", SwingConstants.LEFT); CompletedLabel2.setForeground(Color.WHITE); CompletedLabel2.setFont(new Font("SERRIF", Font.ITALIC, 12)); CompletedLabel2.setBounds(492, 85 + NumberOfCourses * 40 + 60, 50, 20); Panel.add(CompletedLabel2); GPALabel1 = new JLabel("GPA : ", SwingConstants.RIGHT); GPALabel1.setForeground(Color.WHITE); GPALabel1.setFont(new Font("SERRIF", Font.ITALIC, 12)); GPALabel1.setBounds(552, 85 + NumberOfCourses * 40 + 60, 80, 20); Panel.add(GPALabel1); GPALabel2 = new JLabel("36.25", SwingConstants.LEFT); GPALabel2.setForeground(Color.WHITE); GPALabel2.setFont(new Font("SERRIF", Font.ITALIC, 12)); GPALabel2.setBounds(632, 85 + NumberOfCourses * 40 + 60, 50, 20); Panel.add(GPALabel2); DocButton = new JButton("Create Document"); DocButton.setFont(new Font("SERRIF", Font.BOLD, 15)); DocButton.setBounds( 285, 85 + NumberOfCourses * 40 + 60 + 60, 250, 30); // 50+NumberOfCourses*30+(NumberOfCourses-1)*10+35 DocButton.addActionListener(this); Panel.add(DocButton); CheckAll = new JCheckBox("Uncheck all"); CheckAll.setForeground(Color.WHITE); CheckAll.setFont(new Font("SERRIF", Font.BOLD + Font.ITALIC, 12)); CheckAll.setOpaque(false); CheckAll.setSelected(true); CheckAll.addActionListener(this); setComponentsOnTheGrid(); Scroll = new JScrollPane( Panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); RPS.add(Scroll); RPS.setModal(true); RPS.setTitle(" Result : Particular Student "); RPS.setResizable(false); RPS.setSize(840, 565); RPS.setLocation( 250, 100 + (565 - RPS.getHeight()) / 2); // setiing RPS dialogbox in the middle of MenuFrame RPS.setVisible(true); }
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; }
public void mouseDragged(MouseEvent e) { Point p = dlg.getLocationOnScreen(); dlg.setLocation(p.x + e.getX() - origin.x, p.y + e.getY() - origin.y); }
/** * 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); } }
private void plotDataOnGraphics( Graphics g, final MainWindow mainWindow, final int w, final int h, final HiC hic, final JPanel hiCPanel) { // Print the panel on created graphics. if (w == mainWindow.getWidth() && h == mainWindow.getHeight()) { hiCPanel.printAll(g); } else { JDialog waitDialog = new JDialog(); JPanel panel1 = new JPanel(); panel1.add(new JLabel(" Creating and saving " + w + " by " + h + " image ")); // panel1.setPreferredSize(new Dimension(250,50)); waitDialog.add(panel1); waitDialog.setTitle("Please wait..."); waitDialog.pack(); waitDialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); waitDialog.setLocation(100, 100); waitDialog.setVisible(true); mainWindow.setVisible(false); Dimension minSize = mainWindow.getMinimumSize(); Dimension prefSize = mainWindow.getPreferredSize(); hic.centerBP(0, 0); mainWindow.setMinimumSize(new Dimension(w, h)); mainWindow.setPreferredSize(new Dimension(w, h)); mainWindow.pack(); mainWindow.setState(Frame.ICONIFIED); mainWindow.setState(Frame.NORMAL); mainWindow.setVisible(true); mainWindow.setVisible(false); final Runnable painter = new Runnable() { public void run() { hiCPanel.paintImmediately(0, 0, w, h); } }; Thread thread = new Thread(painter) { public void run() { try { SwingUtilities.invokeAndWait(painter); } catch (Exception e) { e.printStackTrace(); } } }; thread.start(); hiCPanel.printAll(g); mainWindow.setPreferredSize(prefSize); mainWindow.setMinimumSize(minSize); mainWindow.setSize(new Dimension(w, h)); waitDialog.setVisible(false); waitDialog.dispose(); mainWindow.setVisible(true); } }