/* * The following method creates the color chooser dialog box */ public void createColorDialog() { colorDialog = new JDialog(this, new String("Choose a color"), true); colorDialog.getContentPane().add(createColorPicker(), BorderLayout.CENTER); JButton okButton = new JButton("OK"); // This class is used to create a special ActionListener for // the ok button class ButtonListener implements ActionListener { /* * This method is called whenever the ok button is clicked */ public void actionPerformed(ActionEvent event) { currentChoice.changeColor(color_panel.getColor()); currentChoice.repaint(); fontColor = color_panel.getColor(); colorDialog.hide(); } // end actionPerformed method } ActionListener listener = new ButtonListener(); okButton.addActionListener(listener); // Add the four font control panels to one big panel using // a grid layout JPanel buttonPanel = new JPanel(); buttonPanel.add(okButton); // Add the button panel to the content pane of the ColorDialogue colorDialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH); colorDialog.pack(); }
/** 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(); }
public char[] askPassword() { char[] password = null; final JDialog dlg = new JDialog(frm, "Password", true); final JPasswordField jpf = new JPasswordField(15); final JButton[] btns = {new JButton("Enter"), new JButton("Cancel")}; for (int i = 0; i < btns.length; i++) { btns[i].addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dlg.setVisible(false); } }); } Object[] prts = new Object[] {"Please input a password:"******"Invalid password, passwords must be " + PASSWORD_MIN + " characters long"); System.exit(1); } return password; }
static void tell(String question, String btnText) { final JDialog d = new JDialog(); d.setLocationRelativeTo(null); JPanel bpane = new JPanel(new FlowLayout()); JLabel l = new JLabel(question); JPanel cp = (JPanel) d.getContentPane(); cp.setLayout(new FlowLayout()); cp.add(l, BorderLayout.CENTER); cp.add(bpane, BorderLayout.SOUTH); JButton b1 = new JButton("OK"); bpane.add(b1); d.pack(); d.setVisible(true); b1.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ans = ((JButton) e.getSource()).getText(); d.dispose(); } }); }
private JDialog createDialog(String title) { JDialog dlg = null; Presenter currentPst = AWWindowsManager.instance().getCurrentPst(); // boolean thrower = (currentPst!=null && // currentPst.getClass().getSimpleName().equals("AbrirDocumentoPst")); // if (thrower){ // dlg = new JDialog(null, title, Dialog.ModalityType.MODELESS); // }else if (AWWindowsManager.instance().isInMainWindow() || (currentPst == null)) { dlg = new JDialog( AWWindowsManager.instance().getFrame(), title, Dialog.ModalityType.DOCUMENT_MODAL); } else { JDialog parent = (JDialog) ((View) currentPst.getView()).getParentContainer(); dlg = new JDialog(parent, title, Dialog.ModalityType.DOCUMENT_MODAL); } setupIcons(dlg); dlg.setUndecorated(true); dlg.getContentPane().setLayout(new BorderLayout()); installFestFixture(dlg); // installMouseAdapter(dlg); return dlg; }
private JDialog assembleDialog() { String title = getTitle(); JDialog dlg = createDialog(title); boolean showAudit = showAuditFields(); int headerHeight = 0; // int headerHeight = (int) viewLayout.headerPanel.getPreferredSize().getHeight(); int auditInfoHeight = 0; // (int) viewLayout.auditInfo.getPreferredSize().getHeight(); int toolbarHeight = 0; int errorHeight = 0; int contentHeight = (int) viewLayout.contentPanel.getPreferredSize().getHeight(); int contentWidth = (int) viewLayout.contentPanel.getPreferredSize().getWidth(); int footerHeight = 0; int delta = 40; /* if(contentHeight<=450){ delta=-160; }else if (contentHeight<=700){ delta=40; }*/ dlg.setSize( contentWidth, (showAudit ? -14 : -14) + headerHeight + toolbarHeight + auditInfoHeight + errorHeight + contentHeight + footerHeight + delta); return dlg; }
/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user pressed the ok button if (e.getSource() == ok_button) { filter_include_list = include_panel.getServiceList(); filter_exclude_list = exclude_panel.getServiceList(); if (status_box.isSelected()) { filter_active = status_active.isSelected(); filter_complete = status_complete.isSelected(); } else { filter_active = false; filter_complete = false; } ok_pressed = true; dialog.dispose(); } // Check if the user pressed the cancel button if (e.getSource() == cancel_button) { dialog.dispose(); } // Check if the user changed the status filter option if (e.getSource() == status_box) { status_active.setEnabled(status_box.isSelected()); status_complete.setEnabled(status_box.isSelected()); } }
public JDialog createFileChooserDialog(JFileChooser jfilechooser, String s, Container container) { JDialog jdialog = new JDialog(frame, s, true); jdialog.setDefaultCloseOperation(2); jdialog.add(jfilechooser); jdialog.pack(); jdialog.setLocationRelativeTo(container); return jdialog; }
private void proceedDialogDisposalQueue(Project project) { Set<JDialog> dialogs = myDialogsToDispose.get(project); if (dialogs == null) return; for (JDialog dialog : dialogs) { dialog.dispose(); } myDialogsToDispose.put(project, null); }
public void edit(Evaluator evaluator, JFrame parent) { if (!(evaluator instanceof Evaluator)) { return; // error? } // create an editor dialog box JDialog editor = new Editor(parent, (Evaluator) evaluator); editor.setVisible(true); }
/** * shows a color chooser dialog * * @param initialColor the initial Color set when the color-chooser is shown * @return the selected color or <code>null</code> if the user opted out */ public Color showColorChooserDialog(Color initialColor) { setColor(initialColor); SVGColorTracker ok = new SVGColorTracker(this); JDialog dialog = createDialog(Editor.getParent(), "", true, this, ok, null); dialog.setVisible(true); return ok.getColor(); }
public void actionPerformed(ActionEvent e) { JColorChooser colorChooser = BasicComponentFactory.createColorChooser(bufferedColorModel); ActionListener okHandler = new OKHandler(trigger); JDialog dialog = JColorChooser.createDialog(parent, "Choose Color", true, colorChooser, okHandler, null); dialog.addWindowListener(new Closer()); dialog.addComponentListener(new DisposeOnClose()); dialog.setVisible(true); // blocks until user brings dialog down... }
private void initializeDlg() { if (pst.isEmbeddedView()) { return; } JDialog dlg = (JDialog) parentContainer; dlg.add(viewLayout.mainPanel, BorderLayout.CENTER); // SwingUtils.locateOnScreenCenter(dlg); SwingUtils.locateRelativeToMenu(dlg); dlg.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); dlg.addWindowListener( new java.awt.event.WindowAdapter() { // todo ver cómo se va a hacer esto en la versión Filthy public void windowOpened(WindowEvent e) { if (pst != null) { pst.onWindowsOpened(e); pst.onWindowsOpenedInternalOnlyForAWFW(e); if (!pst.isReadOnly()) { // pst.setFocusToCmpOnWindowOpen(); // // ActionManager.instance().getVisualMgrForActions().repaintMainDisabledActions(pst.getActionRsr()); } else { pst.configureAsReanOnly(); JButton btnCancel = (JButton) pst.getIpView().getComponent("btnCancel"); if (btnCancel != null) { btnCancel.requestFocusInWindow(); } } } } public void windowClosing(WindowEvent e) { MsgDisplayer.showMessage("sw.common.closeWindowDisabled"); } public void windowActivated(WindowEvent e) { Object oppositeWindow = e.getOppositeWindow(); if (oppositeWindow instanceof DlgMensaje) { logger.debug("Ignoring Windows activated for DlgMensaje"); return; } if (oppositeWindow instanceof JDialog) { JDialog dlg = (JDialog) oppositeWindow; if (MessageDisplayer.GENERIC_MESSAGE_TITLE.equals(dlg.getTitle())) { logger.debug("Ignoring Windows activated for System Msg"); return; } } logger.debug("Windows Activated:" + pst); AWWindowsManager.instance().setPresenterActivated(pst); } }); }
private void initComponents() { final SimpleDateFormat dateFrmt = new SimpleDateFormat(DEFAULT_DATE_FORMAT); panel = new JPanel(); panel.setLayout(new BorderLayout()); JPanel north = new JPanel(); north.setLayout(new BoxLayout(north, BoxLayout.X_AXIS)); JLabel dateLbl = new JLabel("検査日:"); north.add(dateLbl); dateFld = new JTextField(10); dateFld.setMaximumSize(dateFld.getPreferredSize()); dateFld.setEditable(false); dateFld.setText(dateFrmt.format(new Date())); north.add(dateFld); north.add(Box.createHorizontalGlue()); editCheck = new JCheckBox("項目編集"); north.add(editCheck); panel.add(north, BorderLayout.NORTH); JPanel south = new JPanel(); south.setLayout(new FlowLayout()); deleteBtn = new JButton("削除", deleteIcon); deleteBtn.setEnabled(false); south.add(deleteBtn); closeBtn = new JButton("閉じる", closeIcon); south.add(closeBtn); saveBtn = new JButton("保存", saveIcon); south.add(saveBtn); panel.add(south, BorderLayout.SOUTH); setTable = new JTable(); JScrollPane scroll = new JScrollPane(setTable); centerPanel = new JPanel(); centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.X_AXIS)); centerPanel.add(scroll); panel.add(centerPanel, BorderLayout.CENTER); templateTable = new JTable(); templateTable.setToolTipText("DnDで左の施設内検査項目テーブルに追加してください。"); rtScroll = new JScrollPane(templateTable); Dimension d = new Dimension(200, 200); rtScroll.setPreferredSize(d); d = new Dimension(200, Integer.MAX_VALUE); rtScroll.setMaximumSize(d); dialog = new JDialog(); String title = ClientContext.getFrameTitle("院内検査項目追加"); dialog.setTitle(title); dialog.setModal(true); dialog.setContentPane(panel); ClientContext.setDolphinIcon(dialog); dialog.pack(); dialog.setLocationRelativeTo(chart.getFrame()); }
/** * Method used by the SystemIO class to get interactive user input requested by a running MIPS * program (e.g. syscall #5 to read an integer). SystemIO knows whether simulator is being run at * command line by the user, or by the GUI. If run at command line, it gets input from System.in * rather than here. * * <p>This is an overloaded method. This version, with the String parameter, is used to get input * from a popup dialog. * * @param prompt Prompt to display to the user. * @return User input. */ public String getInputString(String prompt) { String input; JOptionPane pane = new JOptionPane(prompt, JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION); pane.setWantsInput(true); JDialog dialog = pane.createDialog(Globals.getGui(), "MIPS Keyboard Input"); dialog.setVisible(true); input = (String) pane.getInputValue(); this.postRunMessage(Globals.userInputAlert + input + "\n"); return input; }
public boolean start() throws Exception { initComponents(); connect(); setupTables(); dialog.setVisible(true); dialog.dispose(); return toUpdate; }
/** Close me */ public void close() { if (dialog != null) { dialog.setVisible(false); if (dialog.isModal()) { dialog.setModal(false); } } if (frame != null) { frame.setVisible(false); } }
public void hideDialog(JDialog dialog, Project project) { if (project == null) { dialog.dispose(); } else { IdeFrameImpl frame = getFrame(project); if (frame.isActive()) { dialog.dispose(); } else { queueForDisposal(dialog, project); dialog.setVisible(false); } } }
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 actionPerformed(ActionEvent evt) { JDialog parent = GUIUtilities.getParentDialog(ColorWellButton.this); JDialog dialog; if (parent != null) { dialog = new ColorPickerDialog(parent, jEdit.getProperty("colorChooser.title"), true); } else { dialog = new ColorPickerDialog( JOptionPane.getFrameForComponent(ColorWellButton.this), jEdit.getProperty("colorChooser.title"), true); } dialog.pack(); dialog.setVisible(true); }
private void createJDlg() { JDialog dlg; if (vsr instanceof JDialog) { dlg = (JDialog) vsr; } else { // jcv2.0.1 if (pst.isEmbeddedView()) { parentContainer = vsr; } else { dlg = assembleDialog(); dlg.setName(getDlgName(vsr.getClass().getName())); parentContainer = dlg; } } }
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(); }
public static JDialog createDialog(JComponent parent, OWLEditorKit editorKit) { JFrame parentFrame = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, parent); final JDialog dialog = new JDialog(parentFrame, "Search", Dialog.ModalityType.MODELESS); final SearchDialogPanel searchDialogPanel = new SearchDialogPanel(editorKit); searchDialogPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); searchDialogPanel .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "CLOSE_DIALOG"); searchDialogPanel .getActionMap() .put( "CLOSE_DIALOG", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } }); searchDialogPanel .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "CLOSE_DIALOG_WITH_ENTER"); searchDialogPanel .getActionMap() .put( "CLOSE_DIALOG_WITH_ENTER", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); searchDialogPanel.selectEntity(); } }); dialog.setContentPane(searchDialogPanel); dialog.setResizable(true); dialog.pack(); dialog.addWindowListener( new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { searchDialogPanel.searchField.requestFocusInWindow(); } }); return dialog; }
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("New Game")) { newGame(); } if (e.getActionCommand().equals("Exit Game")) { exit(); } if (e.getActionCommand().equals("About")) { JDialog f = new JDialog(); f.add(new JLabel(new ImageIcon("splash_applet.jpg"))); f.setSize(660, 520); f.setLocationRelativeTo(this); f.setVisible(true); } }
public void show() { if (pst.isEmbeddedView()) { return; } TimeObserver time = new TimeObserver("Show Dialog"); time.empezar(); JDialog dlg = (JDialog) parentContainer; time.terminar(); if (dialogFixture == null) { dlg.setModal(true); dlg.setVisible(true); } }
private void showJPopupMenu(MouseEvent e) { try { if (e.isPopupTrigger() && menu != null) { if (window == null) { if (isWindows) { window = new JDialog((Frame) null); ((JDialog) window).setUndecorated(true); } else { window = new JWindow((Frame) null); } window.setAlwaysOnTop(true); Dimension size = menu.getPreferredSize(); Point centerPoint = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint(); if (e.getY() > centerPoint.getY()) window.setLocation(e.getX(), e.getY() - size.height); else window.setLocation(e.getX(), e.getY()); window.setVisible(true); menu.show(((RootPaneContainer) window).getContentPane(), 0, 0); // popup works only for focused windows window.toFront(); } } } catch (Exception ignored) { } }
/** 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); } }
@Override public void addNotify() { super.addNotify(); if (UIManager.getBoolean("Sheet.showAsSheet") && !isExperimentalSheet()) { QuaquaUtilities.setWindowAlpha(this, 240); } }
/** * Open me * * @param modal _more_ */ public void show(boolean modal) { if (!windowOk()) { return; } if (dialog != null) { dialog.setModal(modal); dialog.setVisible(true); } if (frame != null) { frame.setVisible(true); } if (window != null) { GuiUtils.showWidget(window); } }
/** * Opens a dialog that asks the user if they want to make a virtual entry a non virtual entry. If * the user clicks 'Yes' the 'change class' dialog opens. */ public void doVirtualEntryDisplay() { virtualEntryDialog = new JDialog(owner, CBIntText.get("Virtual Entry"), true); CBButton btnYes = new CBButton(CBIntText.get("Yes"), CBIntText.get("Click yes to make a Virtual Entry.")); CBButton btnNo = new CBButton( CBIntText.get("No"), CBIntText.get("Click no to cancel without making a Virtual Entry.")); // TE: layout stuff... Container pane = virtualEntryDialog.getContentPane(); pane.setLayout(new BorderLayout()); CBPanel panel1 = new CBPanel(); CBPanel panel2 = new CBPanel(); CBPanel panel3 = new CBPanel(); panel1.add( new JLabel( CBIntText.get( "This entry is a Virtual Entry. Are you sure you want to give this entry an object class?"))); panel2.add(btnYes); panel2.add(btnNo); panel3.makeWide(); panel3.addln(panel1); panel3.addln(panel2); pane.add(panel3); btnYes.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { processVirtualEntry(); } }); btnNo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { shutVirtualEntryDialog(); } }); virtualEntryDialog.setSize(475, 125); CBUtility.center(virtualEntryDialog, owner); virtualEntryDialog.setVisible(true); }