List of usage examples for javax.swing JOptionPane PLAIN_MESSAGE
int PLAIN_MESSAGE
To view the source code for javax.swing JOptionPane PLAIN_MESSAGE.
Click Source Link
From source file:me.mayo.telnetkek.MainPanel.java
public final ServerEntry saveServers() { final Object selectedItem = txtServer.getSelectedItem(); if (selectedItem == null) { return null; }/* ww w . j a v a2s . com*/ ServerEntry entry; if (selectedItem instanceof ServerEntry) { entry = (ServerEntry) selectedItem; } else { final String serverAddress = StringUtils.trimToNull(selectedItem.toString()); if (serverAddress == null) { return null; } String serverName = JOptionPane.showInputDialog(this, "Enter server name:", "Server Name", JOptionPane.PLAIN_MESSAGE); if (serverName == null) { return null; } serverName = StringUtils.trimToEmpty(serverName); if (serverName.isEmpty()) { serverName = "Unnamed"; } entry = new ServerEntry(serverName, serverAddress); TelnetKek.config.getServers().add(entry); } TelnetKek.config.save(); return entry; }
From source file:dbseer.gui.panel.DBSeerLiveMonitorPanel.java
@Override public synchronized void actionPerformed(ActionEvent event) { for (int i = 0; i < transactionRenameButtons.size(); ++i) { if (event.getSource() == transactionRenameButtons.get(i)) { String newName = (String) JOptionPane.showInputDialog(this, "Enter the new name for this transaction type", "New Dataset", JOptionPane.PLAIN_MESSAGE, null, null, transactionNames.get(i)); if (newName == null || newName.trim().isEmpty()) { return; } else { newName = newName.trim(); transactionNames.set(i, newName); transactionLabels.get(i).setText(newName); DefaultTableModel model = (DefaultTableModel) monitorTable.getModel(); model.setValueAt(String.format("Current TPS of '%s' transactions", transactionNames.get(i)), 2 + (i * ROW_PER_TX_TYPE), 0); model.setValueAt(/* w w w . j a va 2s. co m*/ String.format("Current average latency of '%s' transactions", transactionNames.get(i)), 2 + (i * ROW_PER_TX_TYPE) + 1, 0); // TimeSeriesCollection collection = (TimeSeriesCollection) throughputChartPanel.getChart().getXYPlot().getDataset(); throughputCollection.getSeries(i).setKey(newName); latencyCollection.getSeries(i).setKey(newName); // if (DBSeerGUI.currentDataset != null) // { // DBSeerGUI.currentDataset.setTransactionTypeName(i, newName); // } for (DBSeerDataSet dataset : DBSeerGUI.liveDatasets) { dataset.setTransactionTypeName(i, newName); } return; } } } for (int i = 0; i < transactionViewSampleButtons.size(); ++i) { if (event.getSource() == transactionViewSampleButtons.get(i)) { final int type = i; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { DBSeerShowTransactionExampleFrame sampleFrame = new DBSeerShowTransactionExampleFrame(type); sampleFrame.pack(); sampleFrame.setLocationRelativeTo(DBSeerGUI.mainFrame); sampleFrame.setVisible(true); } }); } } for (int i = 0; i < transactionEnableDisableButtons.size(); ++i) { if (event.getSource() == transactionEnableDisableButtons.get(i)) { final XYItemRenderer throughputRenderer = throughputChartPanel.getChart().getXYPlot().getRenderer(); final XYItemRenderer latencyRenderer = latencyChartPanel.getChart().getXYPlot().getRenderer(); final int type = i; final JButton button = transactionEnableDisableButtons.get(i); final DBSeerDataSet dataset = DBSeerGUI.liveDataset; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (button.getText() == "Disable") { dataset.disableTransaction(type); throughputRenderer.setSeriesVisible(type, false); latencyRenderer.setSeriesVisible(type, false); button.setText("Enable"); } else if (button.getText() == "Enable") { dataset.enableTransaction(type); throughputRenderer.setSeriesVisible(type, true); latencyRenderer.setSeriesVisible(type, true); button.setText("Disable"); } } }); } } for (int i = 0; i < transactionDeleteButtons.size(); ++i) { if (event.getSource() == transactionDeleteButtons.get(i)) { synchronized (LiveMonitorInfo.LOCK) { try { DBSeerGUI.middlewareSocket.removeTransactionType(i); } catch (IOException e) { DBSeerExceptionHandler.handleException(e); } throughputCollection.removeSeries(i); latencyCollection.removeSeries(i); DefaultTableModel model = (DefaultTableModel) monitorTable.getModel(); int newTxSize = transactionNames.size() - 1; for (int j = 0; j < transactionNames.size(); ++j) { model.setValueAt(String.format("Current TPS of '%s' transactions", transactionNames.get(j)), 2 + (j * ROW_PER_TX_TYPE), 0); model.setValueAt(String.format("Current average latency of '%s' transactions", transactionNames.get(j)), 2 + (j * ROW_PER_TX_TYPE) + 1, 0); model.setValueAt("", 2 + (j * ROW_PER_TX_TYPE), 1); model.setValueAt("", 2 + (j * ROW_PER_TX_TYPE) + 1, 1); } model.setValueAt("", 2 + (newTxSize * ROW_PER_TX_TYPE), 0); model.setValueAt("", 2 + (newTxSize * ROW_PER_TX_TYPE), 1); model.setValueAt("", 2 + (newTxSize * ROW_PER_TX_TYPE) + 1, 0); model.setValueAt("", 2 + (newTxSize * ROW_PER_TX_TYPE) + 1, 1); final JPanel panel = transactionTypesPanel; final JLabel label = transactionLabels.remove(i); final JButton renameButton = transactionRenameButtons.remove(i); final JButton exampleButton = transactionViewSampleButtons.remove(i); final JButton deleteButton = transactionDeleteButtons.remove(i); transactionNames.remove(i); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { panel.remove(label); panel.remove(renameButton); panel.remove(exampleButton); panel.remove(deleteButton); panel.revalidate(); panel.repaint(); } }); } break; } } }
From source file:com.sshtools.common.ui.SshToolsApplication.java
public void openChangelog(Component parent) { JPanel p = new JPanel(new GridBagLayout()); p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); GridBagConstraints gBC = new GridBagConstraints(); gBC.anchor = GridBagConstraints.CENTER; gBC.fill = GridBagConstraints.HORIZONTAL; gBC.insets = new Insets(1, 1, 1, 1); JLabel a = new JLabel(getApplicationName()); a.setFont(a.getFont().deriveFont(24f)); UIUtil.jGridBagAdd(p, a, gBC, GridBagConstraints.REMAINDER); String changelog = ""; try {//ww w . j a v a2 s . c o m BufferedReader br = new BufferedReader( new InputStreamReader(getClass().getResourceAsStream("/changelog"))); String line = br.readLine(); while (line != null) { changelog += line + "\n"; line = br.readLine(); } br.close(); } catch (Exception e) { changelog = "<Error opening changelog>\n"; } javax.swing.JTextArea message = new javax.swing.JTextArea(changelog); message.setEditable(false); message.setBorder(javax.swing.BorderFactory.createEmptyBorder(4, 4, 4, 4)); javax.swing.JLabel jl = new javax.swing.JLabel(); message.setFont(jl.getFont()); message.setBackground(jl.getBackground()); // MultilineLabel x = new MultilineLabel(changelog); // x.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 0)); // x.setFont(x.getFont().deriveFont(12f)); javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane(); scrollPane.getViewport().add(message); scrollPane.setSize(400, 200); scrollPane.setPreferredSize(new java.awt.Dimension(400, 200)); UIUtil.jGridBagAdd(p, scrollPane, gBC, GridBagConstraints.REMAINDER); JOptionPane.showMessageDialog(parent, p, "Change log", JOptionPane.PLAIN_MESSAGE, getApplicationLargeIcon()); }
From source file:lu.fisch.moenagade.model.Project.java
public BloxsClass addWorld() { String name = ""; boolean result; do {/*w w w .ja v a2s . c o m*/ name = (String) JOptionPane.showInputDialog(frame, "Please enter the world's name.", "Add world", JOptionPane.PLAIN_MESSAGE, null, null, name); if (name == null) return null; result = true; // check if name is OK Matcher matcher = Pattern.compile("^[a-zA-Z_$][a-zA-Z_$0-9]*$").matcher(name); boolean found = matcher.find(); if (!found) { result = false; JOptionPane.showMessageDialog(frame, "Please chose a valid name.", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); } // check if name is unique else if (worlds.containsKey(name) || entities.containsKey(name)) { result = false; JOptionPane.showMessageDialog(frame, "This name is not unique.", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); } // check internal name else if (name.trim().equals("World")) { result = false; JOptionPane.showMessageDialog(frame, "The name \"World\" is already internaly\nused and thus not allowed!", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); } else if (name.charAt(0) != name.toUpperCase().charAt(0)) { result = false; JOptionPane.showMessageDialog(frame, "The name should start with a capital letter.", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); } else { World world = new World(name); world.setProject(this); selected = world; worlds.put(name, world); return world; } } while (!result); return null; }
From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java
/** * Displays about window./* ww w . j a v a 2 s . c o m*/ */ private void about() { String msg = "<html>DrillBook " + State.VERSION + "<br>Created by Evan Belcher, 2016<br><a href=\"https://github.com/EbMinor3/DrillBook\">GitHub</a><br><a href=\"http://evanbelcher.com\">Website</a><br><br><a href=\"https://icons8.com\">Icon pack by Icons8</a></html>"; JEditorPane editorPane = new JEditorPane("text/html", msg); editorPane.setEditable(false); editorPane.setBackground(new JLabel().getBackground()); editorPane.addHyperlinkListener(e -> { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException e1) { e1.printStackTrace(); } } }); if (!(Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE))) { editorPane.setContentType("text"); editorPane.setText("DrillBook " + State.VERSION + "\nCreated by Evan Belcher, 2016\nGitHub: https://github.com/EbMinor3/DrillBook\nWebsite: http://evanbelcher.com\n\nIcon pack by Icons8: https://icons8.com"); } JOptionPane.showMessageDialog(this, editorPane, "About", JOptionPane.PLAIN_MESSAGE); }
From source file:StoreAdmin.ManageStoreJPanel.java
private void btnsearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnsearchActionPerformed // Store s= (Store)cmbstorelist.getSelectedItem(); String key = txtsearch.getText(); Product result = s.getInventoryDirectory().searchProduct(key); if (result != null) { DefaultTableModel dtm = (DefaultTableModel) tblsearchedproduct.getModel(); dtm.setRowCount(0);/*from w w w . j av a2s. c om*/ for (Product p : s.getInventoryDirectory().getInventoryList()) { Object row[] = new Object[4]; row[0] = p; row[1] = p.getProductName(); row[2] = p.getAvailability(); row[3] = p.getSellingPrice(); dtm.addRow(row); } } else { JOptionPane.showMessageDialog(null, "Product doesnot exist", "Success", JOptionPane.PLAIN_MESSAGE); return; } }
From source file:gda.gui.mca.McaGUI.java
private void makeTcaControlDialog() { if (tcaControlPanel == null) { tcaControlPanel = new TcaPanel(); tcaDialog = new JDialog(); Object[] options = { "OK" }; Object[] array = { tcaControlPanel }; // Create the JOptionPane. final JOptionPane optionPane = new JOptionPane(array, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_OPTION, null, options, options[0]); optionPane.addPropertyChangeListener(new PropertyChangeListener() { @Override/*from ww w . jav a 2s .com*/ public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { Object value = optionPane.getValue(); if (value == JOptionPane.UNINITIALIZED_VALUE) { // ignore reset return; } // Reset the JOptionPane's value. // If you don't do this, then if the user // presses the same button next time, no // property change event will be fired. optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); if ("OK".equals(value)) { tcaDialog.setVisible(false); } } } }); tcaDialog.setContentPane(optionPane); tcaDialog.pack(); tcaDialog.setTitle("TCA Controls"); tcaDialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); } }
From source file:components.DialogDemo.java
/** Creates the panel shown by the second tab. */ private JPanel createFeatureDialogBox() { final int numButtons = 5; JRadioButton[] radioButtons = new JRadioButton[numButtons]; final ButtonGroup group = new ButtonGroup(); JButton showItButton = null;//from w w w. j av a 2s . c om final String pickOneCommand = "pickone"; final String textEnteredCommand = "textfield"; final String nonAutoCommand = "nonautooption"; final String customOptionCommand = "customoption"; final String nonModalCommand = "nonmodal"; radioButtons[0] = new JRadioButton("Pick one of several choices"); radioButtons[0].setActionCommand(pickOneCommand); radioButtons[1] = new JRadioButton("Enter some text"); radioButtons[1].setActionCommand(textEnteredCommand); radioButtons[2] = new JRadioButton("Non-auto-closing dialog"); radioButtons[2].setActionCommand(nonAutoCommand); radioButtons[3] = new JRadioButton("Input-validating dialog " + "(with custom message area)"); radioButtons[3].setActionCommand(customOptionCommand); radioButtons[4] = new JRadioButton("Non-modal dialog"); radioButtons[4].setActionCommand(nonModalCommand); for (int i = 0; i < numButtons; i++) { group.add(radioButtons[i]); } radioButtons[0].setSelected(true); showItButton = new JButton("Show it!"); showItButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String command = group.getSelection().getActionCommand(); //pick one of many if (command == pickOneCommand) { Object[] possibilities = { "ham", "spam", "yam" }; String s = (String) JOptionPane.showInputDialog(frame, "Complete the sentence:\n" + "\"Green eggs and...\"", "Customized Dialog", JOptionPane.PLAIN_MESSAGE, icon, possibilities, "ham"); //If a string was returned, say so. if ((s != null) && (s.length() > 0)) { setLabel("Green eggs and... " + s + "!"); return; } //If you're here, the return value was null/empty. setLabel("Come on, finish the sentence!"); //text input } else if (command == textEnteredCommand) { String s = (String) JOptionPane.showInputDialog(frame, "Complete the sentence:\n" + "\"Green eggs and...\"", "Customized Dialog", JOptionPane.PLAIN_MESSAGE, icon, null, "ham"); //If a string was returned, say so. if ((s != null) && (s.length() > 0)) { setLabel("Green eggs and... " + s + "!"); return; } //If you're here, the return value was null/empty. setLabel("Come on, finish the sentence!"); //non-auto-closing dialog } else if (command == nonAutoCommand) { final JOptionPane optionPane = new JOptionPane( "The only way to close this dialog is by\n" + "pressing one of the following buttons.\n" + "Do you understand?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); //You can't use pane.createDialog() because that //method sets up the JDialog with a property change //listener that automatically closes the window //when a button is clicked. final JDialog dialog = new JDialog(frame, "Click a button", true); dialog.setContentPane(optionPane); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { setLabel("Thwarted user attempt to close window."); } }); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop))) { //If you were going to check something //before closing the window, you'd do //it here. dialog.setVisible(false); } } }); dialog.pack(); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); int value = ((Integer) optionPane.getValue()).intValue(); if (value == JOptionPane.YES_OPTION) { setLabel("Good."); } else if (value == JOptionPane.NO_OPTION) { setLabel("Try using the window decorations " + "to close the non-auto-closing dialog. " + "You can't!"); } else { setLabel("Window unavoidably closed (ESC?)."); } //non-auto-closing dialog with custom message area //NOTE: if you don't intend to check the input, //then just use showInputDialog instead. } else if (command == customOptionCommand) { customDialog.setLocationRelativeTo(frame); customDialog.setVisible(true); String s = customDialog.getValidatedText(); if (s != null) { //The text is valid. setLabel("Congratulations! " + "You entered \"" + s + "\"."); } //non-modal dialog } else if (command == nonModalCommand) { //Create the dialog. final JDialog dialog = new JDialog(frame, "A Non-Modal Dialog"); //Add contents to it. It must have a close button, //since some L&Fs (notably Java/Metal) don't provide one //in the window decorations for dialogs. JLabel label = new JLabel("<html><p align=center>" + "This is a non-modal dialog.<br>" + "You can have one or more of these up<br>" + "and still use the main window."); label.setHorizontalAlignment(JLabel.CENTER); Font font = label.getFont(); label.setFont(label.getFont().deriveFont(font.PLAIN, 14.0f)); JButton closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); dialog.dispose(); } }); JPanel closePanel = new JPanel(); closePanel.setLayout(new BoxLayout(closePanel, BoxLayout.LINE_AXIS)); closePanel.add(Box.createHorizontalGlue()); closePanel.add(closeButton); closePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel contentPane = new JPanel(new BorderLayout()); contentPane.add(label, BorderLayout.CENTER); contentPane.add(closePanel, BorderLayout.PAGE_END); contentPane.setOpaque(true); dialog.setContentPane(contentPane); //Show it. dialog.setSize(new Dimension(300, 150)); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); } } }); return createPane(moreDialogDesc + ":", radioButtons, showItButton); }
From source file:view.App.java
private void initGUI() { try {/*from ww w . j a v a 2s. co m*/ { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); getContentPane().add(jPanel1, BorderLayout.CENTER); jPanel1.setPreferredSize(new java.awt.Dimension(901, 398)); { jPanel2 = new JPanel(); BoxLayout jPanel2Layout = new BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS); jPanel2.setLayout(jPanel2Layout); jPanel1.add(jPanel2, BorderLayout.WEST); jPanel2.setPreferredSize(new java.awt.Dimension(292, 446)); { jPanel5 = new JPanel(); jPanel2.add(jPanel5); jPanel5.setPreferredSize(new java.awt.Dimension(292, 109)); { { jTextArea1 = new JTextArea(); jTextArea1.setWrapStyleWord(true); jTextArea1.setLineWrap(true); DefaultCaret caret = (DefaultCaret) jTextArea1.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); jTextArea1.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent evt) { if (jTable1.getModel().getRowCount() == 0 && !jButton1.isEnabled()) { jButton1.setEnabled(true); jTextArea1.setText(""); } } }); JScrollPane sp = new JScrollPane(); sp.setPreferredSize(new java.awt.Dimension(281, 97)); sp.setViewportView(jTextArea1); jPanel5.add(sp, BorderLayout.CENTER); } } } { jPanel4 = new JPanel(); jPanel2.add(jPanel4); FlowLayout jPanel4Layout = new FlowLayout(); jPanel4Layout.setAlignment(FlowLayout.RIGHT); jPanel4.setPreferredSize(new java.awt.Dimension(292, 45)); jPanel4.setSize(102, 51); jPanel4.setLayout(jPanel4Layout); { jButton1 = new JButton(); jPanel4.add(jButton1); jButton1.setText("Get Quotes"); jButton1.setSize(100, 50); jButton1.setPreferredSize(new java.awt.Dimension(100, 26)); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // String tickerStr = jTextArea1.getText(); if (tickerStr.equals("") || tickerStr.equals(null) || tickerStr.equals(" ")) { jTextArea1.setText(" "); return; } StringTokenizer tokenizer = new StringTokenizer(tickerStr, " "); String[] tickers = new String[tokenizer.countTokens()]; int i = 0; while (tokenizer.hasMoreTokens()) { tickers[i] = tokenizer.nextToken(); i++; } try { Controller.getQuotes(tickers); } catch (CloneNotSupportedException e) { JOptionPane.showMessageDialog(jPanel1, " "); } jButton1.setEnabled(false); } }); } } { jPanel6 = new JPanel(); BorderLayout jPanel6Layout = new BorderLayout(); jPanel6.setLayout(jPanel6Layout); jPanel2.add(jPanel6); { jScrollPane1 = new JScrollPane(); jPanel6.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(292, 341)); { TableModel jTable1Model = new DefaultTableModel(null, new String[] { "", "MA Value", "", "MA Value" }); jTable1 = new JTable(); jScrollPane1.setViewportView(jTable1); jTable1.setModel(jTable1Model); jTable1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } } } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jPanel1.add(jPanel3, BorderLayout.CENTER); { // chart = ChartFactory.createLineChart(" ", "dates", "correlation ratio", null, // PlotOrientation.VERTICAL, true, true, false); // ChartPanel chartPanel = new ChartPanel(chart); // chartPanel.setPreferredSize( new java.awt.Dimension( 560 , 367 ) ); // jPanel3.add(chartPanel); } { } } } this.setSize(966, 531); { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { // newFileMenuItem = new JMenuItem(); // jMenu3.add(newFileMenuItem); // newFileMenuItem.setText("New"); // newFileMenuItem.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent evt) { //// jTextArea1.setText(""); //// DefaultTableModel model = (DefaultTableModel)jTable1.getModel(); //// model.setRowCount(0); //// Controller.clearPortfolio(); // } // }); } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { int action = JOptionPane.showConfirmDialog(jPanel1, " ?", "Confirm Exit", JOptionPane.OK_CANCEL_OPTION); if (action == JOptionPane.OK_OPTION) System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { cutMenuItem = new JMenuItem(); jMenu4.add(cutMenuItem); cutMenuItem.setText("Cut"); cutMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String txt = jTextArea1.getText(); StringSelection selection = new StringSelection(txt); Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard(); clp.setContents(selection, null); jTextArea1.setText(""); } }); } { copyMenuItem = new JMenuItem(); jMenu4.add(copyMenuItem); copyMenuItem.setText("Copy"); copyMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String txt = jTextArea1.getText(); StringSelection selection = new StringSelection(txt); Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard(); clp.setContents(selection, null); } }); } { pasteMenuItem = new JMenuItem(); jMenu4.add(pasteMenuItem); pasteMenuItem.setText("Paste"); pasteMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard(); try { String data = (String) clp.getData(DataFlavor.stringFlavor); jTextArea1.setText(data); } catch (UnsupportedFlavorException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("About"); helpMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JOptionPane.showMessageDialog(jPanel1, " . r.zhumagulov@gmail.com", "About", JOptionPane.PLAIN_MESSAGE); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java
public boolean isConfirmed() { Object[] options = { "Yes", "No" }; int option = JOptionPane.showOptionDialog(panelMain, "Are you sure you want to generate '" + model.getFileName() + "' ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, new ImageIcon(getClass().getResource(ICON_CONFIRM)), options, options[0]); return option == JOptionPane.OK_OPTION; }