List of usage examples for javax.swing JOptionPane OK_OPTION
int OK_OPTION
To view the source code for javax.swing JOptionPane OK_OPTION.
Click Source Link
From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java
private void filterSampleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filterSampleButtonActionPerformed int r = JOptionPane.showConfirmDialog(chartPanel, filterPanel, "Select evaluation sample", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (r == JOptionPane.OK_OPTION) { updateChart();/*from ww w . ja v a 2 s .c o m*/ } }
From source file:com.smanempat.controller.ControllerEvaluation.java
public void proccessMining(JTable tableDataSetModel, JTable tableDataSetTesting, JTextField txtNumberOfK, JLabel labelPesanError, JTabbedPane jTabbedPane1, JTable tableResult, JTable tableConfMatrix, JTable tableTahunTesting, JLabel totalAccuracy, JPanel panelChart, JPanel panelChart1, JPanel panelChart2, JRadioButton singleTesting, JRadioButton multiTesting, JTextArea txtArea) throws SQLException { Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); modelEvaluation = new ModelEvaluation(); int rowCountModel = tableDataSetModel.getRowCount(); int rowCountTest = tableDataSetTesting.getRowCount(); int[] tempK;//w w w . j av a 2 s . co m double[][] tempEval; double[][] evalValue; boolean valid = false; /*Validasi Dataset Model dan Dataset Uji*/ if (rowCountModel == 0) { JOptionPane.showMessageDialog(null, "Pilih dataset model terlebih dahulu!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); txtNumberOfK.requestFocus(); } else if (rowCountTest == 0) { JOptionPane.showMessageDialog(null, "Pilih dataset uji terlebih dahulu!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); txtNumberOfK.requestFocus(); } else { valid = true; } /*Validasi Dataset Model dan Dataset Uji*/ if (valid == true) { if (multiTesting.isSelected()) { String iterasi = JOptionPane.showInputDialog("Input Jumlah Iterasi Pengujian :"); boolean validMulti = false; if (iterasi != null) { /*Validasi Jumlah Iterasi*/ if (Pattern.matches("[0-9]+", iterasi) == false && iterasi.length() > 0) { JOptionPane.showMessageDialog(null, "Nilai iterasi tidak valid!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else if (iterasi.isEmpty()) { JOptionPane.showMessageDialog(null, "Nilai iterasi tidak boleh kosong!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else if (iterasi.length() == 9) { JOptionPane.showMessageDialog(null, "Nilai iterasi terlalu panjang!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else if (rowCountTest > rowCountModel) { JOptionPane.showMessageDialog(null, "Data Uji tidak boleh lebih besar daripada data Model!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else { validMulti = true; System.out.println("valiMulti = " + validMulti + " Kok"); } /*Validasi Jumlah Iterasi*/ } if (validMulti == true) { tempK = new int[Integer.parseInt(iterasi)]; evalValue = new double[3][tempK.length]; for (int i = 0; i < Integer.parseInt(iterasi); i++) { validMulti = false; String k = JOptionPane .showInputDialog("Input Nilai Nearest Neighbor (k) ke " + (i + 1) + " :"); if (k != null) { /*Validasi Nilai K Tiap Iterasi*/ if (Pattern.matches("[0-9]+", k) == false && k.length() > 0) { JOptionPane.showMessageDialog(null, "Nilai nearest neighbor (k) tidak valid!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else if (k.isEmpty()) { JOptionPane.showMessageDialog(null, "Nilai nearest neighbor (k) tidak boleh kosong!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else if (k.length() == 9) { JOptionPane.showMessageDialog(null, "Nilai nearest neighbor (k) terlalu panjang!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else { validMulti = true; } /*Validasi Nilai K Tiap Iterasi*/ } if (validMulti == true) { tempK[i] = Integer.parseInt(k); System.out.println(tempK[i]); } else { break; } } if (validMulti == true) { for (int i = 0; i < tempK.length; i++) { int kValue = tempK[i]; String[][] modelValue = getModelValue(rowCountModel, tableDataSetModel); double[][] testValue = getTestvalue(rowCountTest, tableDataSetTesting); String[] knnValue = getKNNValue(rowCountModel, rowCountTest, modelValue, testValue, kValue); tempEval = evaluationModel(tableResult, tableConfMatrix, totalAccuracy, tableTahunTesting, tableDataSetTesting, knnValue, i, tempK, panelChart); //Menampung nilai Accuracy evalValue[0][i] = tempEval[0][i]; //Menampung nilai Recall evalValue[1][i] = tempEval[1][i]; //Menampung nilai Precision evalValue[2][i] = tempEval[2][i]; jTabbedPane1.setSelectedIndex(1); txtArea.append( "Tingkat Keberhasilan Sistem dengan Nilai Number of Nearest Neighbor (K) = " + tempK[i] + "\n"); txtArea.append("Akurasi\t\t: " + evalValue[0][i] * 100 + " %\n"); txtArea.append("Recall\t\t: " + evalValue[1][i] * 100 + " %\n"); txtArea.append("Precision\t: " + evalValue[2][i] * 100 + " %\n"); txtArea.append( "=============================================================================\n"); } showChart(tempK, evalValue, panelChart, panelChart1, panelChart2); } } } else if (singleTesting.isSelected()) { boolean validSingle = false; String k = txtNumberOfK.getText(); int nilaiK = 0; evalValue = new double[3][1]; /*Validasi Nilai Number of Nearest Neighbor*/ if (Pattern.matches("[0-9]+", k) == false && k.length() > 0) { labelPesanError.setText("Number of Nearest Neighbor tidak valid"); JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak valid!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); txtNumberOfK.requestFocus(); } else if (k.isEmpty()) { JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh kosong!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); labelPesanError.setText("Number of Nearest Neighbor tidak boleh kosong"); txtNumberOfK.requestFocus(); } else if (rowCountModel == 0 && Integer.parseInt(k) >= rowCountModel) { JOptionPane.showMessageDialog(null, "Pilih dataset model terlebih dahulu!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); txtNumberOfK.requestFocus(); } else if (rowCountTest == 0 && Integer.parseInt(k) >= rowCountTest) { JOptionPane.showMessageDialog(null, "Pilih dataset uji terlebih dahulu!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); txtNumberOfK.requestFocus(); } else if (Integer.parseInt(k) >= rowCountModel) { JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + " !", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); txtNumberOfK.requestFocus(); } else { validSingle = true; nilaiK = Integer.parseInt(k); } /*Validasi Nilai Number of Nearest Neighbor*/ if (validSingle == true) { int confirm; int i = 0; confirm = JOptionPane.showOptionDialog(null, "Yakin ingin memproses data?", "Proses Klasifikasi", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == JOptionPane.OK_OPTION) { int kValue = Integer.parseInt(txtNumberOfK.getText()); String[][] modelValue = getModelValue(rowCountModel, tableDataSetModel); double[][] testValue = getTestvalue(rowCountTest, tableDataSetTesting); String[] knnValue = getKNNValue(rowCountModel, rowCountTest, modelValue, testValue, kValue); tempEval = evaluationModel(tableResult, tableConfMatrix, totalAccuracy, tableTahunTesting, tableDataSetTesting, knnValue, nilaiK, panelChart); evalValue[0][i] = tempEval[0][0]; evalValue[1][i] = tempEval[1][0]; evalValue[2][i] = tempEval[2][0]; jTabbedPane1.setSelectedIndex(1); } System.out.println("com.smanempat.controller.ControllerEvaluation.proccessMining()OKOKOK"); showChart(nilaiK, evalValue, panelChart, panelChart1, panelChart2); Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); } } } }
From source file:com.sshtools.common.vomanagementtool.common.VOHelper.java
public static boolean createAddVODialog() { boolean isSuccessful = false; NewVOPanel newVOPanel = new NewVOPanel(); while (true) { int result = JOptionPane.showConfirmDialog(null, newVOPanel, "New VO", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, new ResourceIcon(newVOPanel.getClass(), ConfigHelper.ICON)); if (result == JOptionPane.OK_OPTION) { String msg = ""; if (newVOPanel.getServerIssuerDN().equals("")) { msg = "Field 'Server Certificate Issuer DN' cannot be empty."; }//w w w . j a v a 2 s . co m if (newVOPanel.getServerDN().equals("")) { msg = "Field 'Server DN' cannot be empty.\n" + msg; } if (newVOPanel.getPort() == 0) { msg = "Field 'Port' cannot be empty.\n" + msg; } if (newVOPanel.getServer().equals("")) { msg = "Field 'Server' cannot be empty.\n" + msg; } if (newVOPanel.getVOName().equals("")) { msg = "Field 'VO name' cannot be empty.\n" + msg; } if (!msg.equals("")) { JOptionPane.showMessageDialog(null, msg, "Error: Add new VO", JOptionPane.ERROR_MESSAGE); } else { TreeMap vo = new TreeMap(); vo.put("localvoname", newVOPanel.getVOName()); vo.put("servervoname", newVOPanel.getVOName()); vo.put("server", newVOPanel.getServer()); vo.put("port", newVOPanel.getPort()); vo.put("serverdn", newVOPanel.getServerDN()); vo.put("serverissuerdn", newVOPanel.getServerIssuerDN()); try { isSuccessful = addNewVO(vo); break; } catch (IOException e) { JOptionPane.showMessageDialog(null, e.getMessage(), "Error: Add new VO", JOptionPane.ERROR_MESSAGE); } } } else { break; } } return isSuccessful; }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
private void showPropertyEditor(int tabIndex) { Hist2DChartEditor editor = new Hist2DChartEditor(getChart(), this); editor.getTabs().setSelectedIndex(tabIndex); int result = JOptionPane.showConfirmDialog(this, editor, localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { editor.updateChart(getChart());// www. java 2 s. co m } }
From source file:com.sshtools.sshvnc.SshVNCPanel.java
public void authenticationComplete(boolean newProfile) throws SshException, IOException {/* w ww .j a va2 s . co m*/ statusBar.setStatusText("User authenticated"); setContainerTitle(getCurrentConnectionProfile().getHost()); int localPort = 0; String host = getCurrentConnectionProfile().getApplicationProperty(PROFILE_PROPERTY_VNC_HOST, "localhost"); String port = getCurrentConnectionProfile().getApplicationProperty(PROFILE_PROPERTY_VNC_DISPLAY, "5900"); final VNCDisplay display = new VNCDisplay(host + ":" + port, 5900); final String addr = "0.0.0.0"; String command = getCurrentConnectionProfile().getApplicationProperty( PROFILE_PRE_VNC_COMMAND, null); if (command != null && command.trim().length() > 0) { statusBar.setStatusText("Executing command: " + command); remove(vnc); add(terminal, BorderLayout.CENTER); emulation.reset(); emulation.clearScreen(); emulation.setCursorPosition(0, 0); terminal.refresh(); log.debug("Executing pre VNC command" + command); SessionChannelClient session = ssh.openSessionChannel(); session.requestPseudoTerminal("vt100", 80, 24, 0, 0, ""); if (session.executeCommand(command)) { session.bindInputStream(emulation.getTerminalInputStream()); session.bindOutputStream(emulation.getTerminalOutputStream()); } try { session.getState().waitForState(ChannelState.CHANNEL_CLOSED); } catch (InterruptedException ex) { } finally { remove(terminal); add(vnc, BorderLayout.CENTER); } } statusBar.setStatusText("Setting up VNC forwarding"); if (log.isDebugEnabled()) { log.debug("Setting up forwarding on " + addr + " (" + localPort + ") to " + display.getHost() + ":" + display.getPort()); } final SshVNCOptions options = new SshVNCOptions(getCurrentConnectionProfile()); statusBar.setStatusText("Initialising VNC"); ForwardingConfiguration config = new ForwardingConfiguration( "VNC", "forwarded-channel", 0, display.getHost(), display.getPort()); channel = new ForwardingIOChannel( ForwardingIOChannel.LOCAL_FORWARDING_CHANNEL, "VNC", config.getHostToConnect(), config.getPortToConnect(), addr, display.getPort()); if (ssh.openChannel(channel)) { // The forwarding channel is open so forward to the // VNC protocol channel.addEventListener(new DataNotificationListener(statusBar)); if (newProfile) { setNeedSave(true); } new SshThread(new Runnable() { public void run() { initVNC( channel.getInputStream(), channel.getOutputStream(), options); } } , "VNC", true).start(); } else { // We need to close the connection and inform the user // that the forwarding failed to start try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { JOptionPane.showMessageDialog( SshVNCPanel.this, "SSHVnc failed to open a forwarding channel to " + display.toString(), "SSHVnc", JOptionPane.OK_OPTION); } }); } catch (Exception ex) { statusBar.setStatusText( "Could not connect to local forwarding server"); } finally { closeConnection(true); } } }
From source file:com.nbt.TreeFrame.java
private void createActions() { newAction = new NBTAction("New", "New", "New", KeyEvent.VK_N) { {/*from w ww. j av a 2s . c om*/ putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('N', Event.CTRL_MASK)); } @Override public void actionPerformed(ActionEvent e) { updateTreeTable(new CompoundTag("")); } }; browseAction = new NBTAction("Browse...", "Open", "Browse...", KeyEvent.VK_O) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('O', Event.CTRL_MASK)); } @Override public void actionPerformed(ActionEvent e) { JFileChooser fc = createFileChooser(); switch (fc.showOpenDialog(TreeFrame.this)) { case JFileChooser.APPROVE_OPTION: File file = fc.getSelectedFile(); Preferences prefs = getPreferences(); prefs.put(KEY_FILE, file.getAbsolutePath()); doImport(file); break; } } }; saveAction = new NBTAction("Save", "Save", "Save", KeyEvent.VK_S) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('S', Event.CTRL_MASK)); } @Override public void actionPerformed(ActionEvent e) { String path = textFile.getText(); File file = new File(path); if (file.canWrite()) { doExport(file); } else { saveAsAction.actionPerformed(e); } } }; saveAsAction = new NBTAction("Save As...", "SaveAs", "Save As...", KeyEvent.VK_UNDEFINED) { public void actionPerformed(ActionEvent e) { JFileChooser fc = createFileChooser(); switch (fc.showSaveDialog(TreeFrame.this)) { case JFileChooser.APPROVE_OPTION: File file = fc.getSelectedFile(); Preferences prefs = getPreferences(); prefs.put(KEY_FILE, file.getAbsolutePath()); doExport(file); break; } } }; refreshAction = new NBTAction("Refresh", "Refresh", "Refresh", KeyEvent.VK_F5) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("F5")); } public void actionPerformed(ActionEvent e) { String path = textFile.getText(); File file = new File(path); if (file.canRead()) doImport(file); else showErrorDialog("The file could not be read."); } }; exitAction = new NBTAction("Exit", "Exit", KeyEvent.VK_ESCAPE) { @Override public void actionPerformed(ActionEvent e) { // TODO: this should check to see if any changes have been made // before exiting System.exit(0); } }; cutAction = new DefaultEditorKit.CutAction() { { String name = "Cut"; putValue(NAME, name); putValue(SHORT_DESCRIPTION, name); putValue(MNEMONIC_KEY, KeyEvent.VK_X); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('X', Event.CTRL_MASK)); ImageFactory factory = new ImageFactory(); try { putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize))); } catch (IOException e) { e.printStackTrace(); } try { putValue(LARGE_ICON_KEY, new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize))); } catch (IOException e) { e.printStackTrace(); } } }; copyAction = new DefaultEditorKit.CopyAction() { { String name = "Copy"; putValue(NAME, name); putValue(SHORT_DESCRIPTION, name); putValue(MNEMONIC_KEY, KeyEvent.VK_C); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('C', Event.CTRL_MASK)); ImageFactory factory = new ImageFactory(); try { putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize))); } catch (IOException e) { e.printStackTrace(); } try { putValue(LARGE_ICON_KEY, new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize))); } catch (IOException e) { e.printStackTrace(); } } }; pasteAction = new DefaultEditorKit.CutAction() { { String name = "Paste"; putValue(NAME, name); putValue(SHORT_DESCRIPTION, name); putValue(MNEMONIC_KEY, KeyEvent.VK_V); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('V', Event.CTRL_MASK)); ImageFactory factory = new ImageFactory(); try { putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize))); } catch (IOException e) { e.printStackTrace(); } try { putValue(LARGE_ICON_KEY, new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize))); } catch (IOException e) { e.printStackTrace(); } } }; deleteAction = new NBTAction("Delete", "Delete", "Delete", KeyEvent.VK_DELETE) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("DELETE")); } public void actionPerformed(ActionEvent e) { int row = treeTable.getSelectedRow(); TreePath path = treeTable.getPathForRow(row); Object last = path.getLastPathComponent(); if (last instanceof NBTFileBranch) { NBTFileBranch branch = (NBTFileBranch) last; File file = branch.getFile(); String name = file.getName(); String message = "Are you sure you want to delete " + name + "?"; String title = "Continue?"; int option = JOptionPane.showConfirmDialog(TreeFrame.this, message, title, JOptionPane.OK_CANCEL_OPTION); switch (option) { case JOptionPane.CANCEL_OPTION: return; } if (!FileUtils.deleteQuietly(file)) { showErrorDialog(name + " could not be deleted."); return; } } TreePath parentPath = path.getParentPath(); Object parentLast = parentPath.getLastPathComponent(); NBTTreeTableModel model = treeTable.getTreeTableModel(); int index = model.getIndexOfChild(parentLast, last); if (parentLast instanceof Mutable<?>) { Mutable<?> mutable = (Mutable<?>) parentLast; if (last instanceof ByteWrapper) { ByteWrapper wrapper = (ByteWrapper) last; index = wrapper.getIndex(); } mutable.remove(index); } else { System.err.println(last.getClass()); return; } updateTreeTable(); treeTable.expandPath(parentPath); scrollTo(parentLast); treeTable.setRowSelectionInterval(row, row); } }; openAction = new NBTAction("Open...", "Open...", KeyEvent.VK_T) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('T', Event.CTRL_MASK)); final int diamondPickaxe = 278; SpriteRecord record = NBTTreeTable.register.getRecord(diamondPickaxe); BufferedImage image = record.getImage(); setSmallIcon(image); int width = 24, height = 24; Dimension size = new Dimension(width, height); Map<RenderingHints.Key, ?> hints = Thumbnail.createRenderingHints(Thumbnail.QUALITY); BufferedImage largeImage = Thumbnail.createThumbnail(image, size, hints); setLargeIcon(largeImage); } public void actionPerformed(ActionEvent e) { TreePath path = treeTable.getPath(); if (path == null) return; Object last = path.getLastPathComponent(); if (last instanceof Region) { Region region = (Region) last; createAndShowTileCanvas(new TileCanvas.TileWorld(region)); return; } else if (last instanceof World) { World world = (World) last; createAndShowTileCanvas(world); return; } if (last instanceof NBTFileBranch) { NBTFileBranch fileBranch = (NBTFileBranch) last; File file = fileBranch.getFile(); try { open(file); } catch (IOException ex) { ex.printStackTrace(); showErrorDialog(ex.getMessage()); } } } private void open(File file) throws IOException { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(file); } } } }; addByteAction = new NBTAction("Add Byte", NBTConstants.TYPE_BYTE, "Add Byte", KeyEvent.VK_1) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('1', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new ByteTag("new byte", (byte) 0)); } }; addShortAction = new NBTAction("Add Short", NBTConstants.TYPE_SHORT, "Add Short", KeyEvent.VK_2) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('2', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new ShortTag("new short", (short) 0)); } }; addIntAction = new NBTAction("Add Integer", NBTConstants.TYPE_INT, "Add Integer", KeyEvent.VK_3) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('3', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new IntTag("new int", 0)); } }; addLongAction = new NBTAction("Add Long", NBTConstants.TYPE_LONG, "Add Long", KeyEvent.VK_4) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('4', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new LongTag("new long", 0)); } }; addFloatAction = new NBTAction("Add Float", NBTConstants.TYPE_FLOAT, "Add Float", KeyEvent.VK_5) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('5', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new FloatTag("new float", 0)); } }; addDoubleAction = new NBTAction("Add Double", NBTConstants.TYPE_DOUBLE, "Add Double", KeyEvent.VK_6) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('6', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new DoubleTag("new double", 0)); } }; addByteArrayAction = new NBTAction("Add Byte Array", NBTConstants.TYPE_BYTE_ARRAY, "Add Byte Array", KeyEvent.VK_7) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('7', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new ByteArrayTag("new byte array")); } }; addStringAction = new NBTAction("Add String", NBTConstants.TYPE_STRING, "Add String", KeyEvent.VK_8) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('8', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new StringTag("new string", "...")); } }; addListAction = new NBTAction("Add List Tag", NBTConstants.TYPE_LIST, "Add List Tag", KeyEvent.VK_9) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('9', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { Class<? extends Tag> type = queryType(); if (type != null) addTag(new ListTag("new list", null, type)); } private Class<? extends Tag> queryType() { Object[] items = { NBTConstants.TYPE_BYTE, NBTConstants.TYPE_SHORT, NBTConstants.TYPE_INT, NBTConstants.TYPE_LONG, NBTConstants.TYPE_FLOAT, NBTConstants.TYPE_DOUBLE, NBTConstants.TYPE_BYTE_ARRAY, NBTConstants.TYPE_STRING, NBTConstants.TYPE_LIST, NBTConstants.TYPE_COMPOUND }; JComboBox comboBox = new JComboBox(new DefaultComboBoxModel(items)); comboBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof Integer) { Integer i = (Integer) value; Class<? extends Tag> c = NBTUtils.getTypeClass(i); String name = NBTUtils.getTypeName(c); setText(name); } return this; } }); Object[] message = { new JLabel("Please select a type."), comboBox }; String title = "Title goes here"; int result = JOptionPane.showOptionDialog(TreeFrame.this, message, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); switch (result) { case JOptionPane.OK_OPTION: ComboBoxModel model = comboBox.getModel(); Object item = model.getSelectedItem(); if (item instanceof Integer) { Integer i = (Integer) item; return NBTUtils.getTypeClass(i); } } return null; } }; addCompoundAction = new NBTAction("Add Compound Tag", NBTConstants.TYPE_COMPOUND, "Add Compound Tag", KeyEvent.VK_0) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('0', Event.CTRL_MASK)); } public void actionPerformed(ActionEvent e) { addTag(new CompoundTag()); } }; String name = "About " + TITLE; helpAction = new NBTAction(name, "Help", name, KeyEvent.VK_F1) { { putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("F1")); } public void actionPerformed(ActionEvent e) { Object[] message = { new JLabel(TITLE + " " + VERSION), new JLabel("\u00A9 Copyright Taggart Spilman 2011. All rights reserved."), new Hyperlink("<html><a href=\"#\">NamedBinaryTag.com</a></html>", "http://www.namedbinarytag.com"), new Hyperlink("<html><a href=\"#\">Contact</a></html>", "mailto:tagadvance@gmail.com"), new JLabel(" "), new Hyperlink("<html><a href=\"#\">JNBT was written by Graham Edgecombe</a></html>", "http://jnbt.sf.net"), new Hyperlink("<html><a href=\"#\">Available open-source under the BSD license</a></html>", "http://jnbt.sourceforge.net/LICENSE.TXT"), new JLabel(" "), new JLabel("This product includes software developed by"), new Hyperlink("<html><a href=\"#\">The Apache Software Foundation</a>.</html>", "http://www.apache.org"), new JLabel(" "), new JLabel("Default texture pack:"), new Hyperlink("<html><a href=\"#\">SOLID COLOUR. SOLID STYLE.</a></html>", "http://www.minecraftforum.net/topic/72253-solid-colour-solid-style/"), new JLabel("Bundled with the permission of Trigger_Proximity."), }; String title = "About"; JOptionPane.showMessageDialog(TreeFrame.this, message, title, JOptionPane.INFORMATION_MESSAGE); } }; }
From source file:net.sf.firemox.Magic.java
public void actionPerformed(ActionEvent e) { final String command = e.getActionCommand(); final Object obj = e.getSource(); if (obj == sendButton) { if (sendTxt.getText().length() != 0) { MChat.getInstance().sendMessage(sendTxt.getText() + "\n"); sendTxt.setText(""); }/*from ww w. j a va2 s. c o m*/ } else if (command != null && command.startsWith("border-")) { for (int i = cardBorderMenu.getComponentCount(); i-- > 0;) { ((JRadioButtonMenuItem) cardBorderMenu.getComponent(i)).setSelected(false); } ((JRadioButtonMenuItem) obj).setSelected(true); CardFactory.updateColor(command.substring("border-".length())); CardFactory.updateAllCardsUI(); magicForm.repaint(); } else if ("menu_help_mailing".equals(command)) { try { WebBrowser.launchBrowser( "http://lists.sourceforge.net/lists/listinfo/" + IdConst.PROJECT_NAME + "-user"); } catch (Exception e1) { JOptionPane.showOptionDialog(this, LanguageManager.getString("error") + " : " + e1.getMessage(), LanguageManager.getString("web-pb"), JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE, UIHelper.getIcon("wiz_update_error.gif"), null, null); } } else if ("menu_options_settings".equals(command)) { // Setting panel final Wizard settingsPanel = new Settings(); settingsPanel.setVisible(true); } else if ("menu_help_check-update".equals(command)) { VersionChecker.checkVersion(this); } else if ("menu_game_new_client".equals(command)) { new net.sf.firemox.ui.wizard.Client().setVisible(true); } else if ("menu_game_new_server".equals(command)) { new net.sf.firemox.ui.wizard.Server().setVisible(true); } else if ("menu_tools_log".equals(command)) { new net.sf.firemox.ui.wizard.Log().setVisible(true); } else if ("menu_tools_featurerequest".equals(command)) { new Feature().setVisible(true); } else if ("menu_tools_bugreport".equals(command)) { new Bug().setVisible(true); } else if ("menu_game_skip".equals(command)) { if (ConnectionManager.isConnected() && skipButton.isEnabled() && StackManager.idHandedPlayer == 0) { StackManager.noReplayToken.take(); try { manualSkip(); } catch (Throwable t) { t.printStackTrace(); } finally { StackManager.noReplayToken.release(); } } } else if ("menu_game_disconnect".equals(command)) { ConnectionManager.closeConnexions(); } else if ("menu_tools_jdb".equals(command)) { DeckBuilder.loadFromMagic(); } else if ("menu_game_exit".equals(command)) { exitForm(null); } else if (obj == autoManaMenu) { /* * invoked you click directly on the "auto-mana option" of the menu * "options". The opponent has to know that we are in "auto colorless mana * use", since player will no longer click on the mana icon to define * which colored mana active player has used as colorless mana, then the * opponent have not to wait for active player choice, but apply the same * Algorithm calculating which colored manas are used as colorless manas. * This information is not sent immediately, but will be sent with the * next action of active player. */ MCommonVars.autoMana = autoManaMenu.isSelected(); } else if (obj == autoPlayMenu) { /* * invoked you click directly on the "auto-play option" of the menu * "options". */ MCommonVars.autoStack = autoPlayMenu.isSelected(); } else if ("menu_tools_jcb".equals(command)) { // TODO cardBuilderMenu -> not yet implemented Log.info("cardBuilderMenu -> not yet implemented"); } else if ("menu_game_proxy".equals(command)) { new ProxyConfiguration().setVisible(true); } else if ("menu_help_help".equals(command)) { /* * Invoked you click directly on youLabel. Opponent will receive this * information. */ try { WebBrowser.launchBrowser("http://prdownloads.sourceforge.net/" + IdConst.PROJECT_NAME + "/7e_rulebook_EN.pdf?download"); } catch (Exception e1) { JOptionPane.showOptionDialog(this, LanguageManager.getString("error") + " : " + e1.getMessage(), LanguageManager.getString("web-pb"), JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE, UIHelper.getIcon("wiz_update_error.gif"), null, null); } } else if ("menu_help_about".equals(command)) { new About(this).setVisible(true); } else if ("menu_help_about.tbs".equals(command)) { new AboutMdb(this).setVisible(true); } else if (obj == reverseArtCheck || obj == reverseSideCheck) { Configuration.setProperty("reverseArt", reverseArtCheck.isSelected()); Configuration.setProperty("reverseSide", reverseSideCheck.isSelected()); ZoneManager.updateReversed(); StackManager.PLAYERS[1].updateReversed(); repaint(); SwingUtilities.invokeLater(SkinLF.REFRESH_RUNNER); } else if (obj == soundMenu) { Configuration.setProperty("sound", soundMenu.isSelected()); soundMenu.setIcon( soundMenu.isSelected() ? UIHelper.getIcon("sound.gif") : UIHelper.getIcon("soundoff.gif")); } else if ("menu_lf_randomAngle".equals(command)) { Configuration.setProperty("randomAngle", ((AbstractButton) e.getSource()).isSelected()); CardFactory.updateAllCardsUI(); } else if ("menu_lf_powerToughnessColor".equals(command)) { final Color powerToughnessColor = JColorChooser.showDialog(this, LanguageManager.getString("menu_lf_powerToughnessColor"), CardFactory.powerToughnessColor); if (powerToughnessColor != null) { Configuration.setProperty("powerToughnessColor", powerToughnessColor.getRGB()); CardFactory.updateColor(null); repaint(); } } else if (obj == initialdelayMenu) { // TODO factor this code with the one of Magic.class final ToolTipManager toolTipManager = ToolTipManager.sharedInstance(); new InputNumber(LanguageManager.getString("initialdelay"), LanguageManager.getString("initialdelay.tooltip"), 0, Integer.MAX_VALUE, toolTipManager.getInitialDelay()).setVisible(true); if (Wizard.optionAnswer == JOptionPane.YES_OPTION) { toolTipManager.setEnabled(Wizard.indexAnswer != 0); toolTipManager.setInitialDelay(Wizard.indexAnswer); initialdelayMenu.setText(LanguageManager.getString("initialdelay") + (toolTipManager.isEnabled() ? " : " + Wizard.indexAnswer + " ms" : "(disabled)")); Configuration.setProperty("initialdelay", Wizard.indexAnswer); } } else if (obj == dismissdelayMenu) { // TODO factor this code with the one of Magic.class final ToolTipManager toolTipManager = ToolTipManager.sharedInstance(); new InputNumber(LanguageManager.getString("dismissdelay"), LanguageManager.getString("dismissdelay.tooltip"), 0, Integer.MAX_VALUE, toolTipManager.getDismissDelay()).setVisible(true); if (Wizard.optionAnswer == JOptionPane.YES_OPTION) { toolTipManager.setDismissDelay(Wizard.indexAnswer); Configuration.setProperty("dismissdelay", Wizard.indexAnswer); dismissdelayMenu.setText(LanguageManager.getString("dismissdelay") + Wizard.indexAnswer + " ms"); } } }
From source file:br.com.jinsync.view.FrmJInSync.java
/** * Initialize the contents of the frame. *///from w w w .j a v a2 s .c om private void initialize() { Language.loadParameters(); setBounds(100, 100, 1136, 665); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 0, 0 }; gridBagLayout.rowHeights = new int[] { 600, 53, 0, 0 }; gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { 1.0, 0.0, 0.0, Double.MIN_VALUE }; getContentPane().setLayout(gridBagLayout); grpFontes = new JTabbedPane(SwingConstants.TOP); GridBagConstraints gbc_grpFontes = new GridBagConstraints(); gbc_grpFontes.insets = new Insets(0, 0, 5, 0); gbc_grpFontes.fill = GridBagConstraints.BOTH; gbc_grpFontes.gridx = 0; gbc_grpFontes.gridy = 0; getContentPane().add(grpFontes, gbc_grpFontes); tabCopybook = new JPanel(); tabCopybook.setBackground(Color.WHITE); grpFontes.addTab(Language.tabCopy, null, tabCopybook, null); GridBagLayout gbl_tabCopybook = new GridBagLayout(); gbl_tabCopybook.columnWidths = new int[] { 10, 1, 0, 349, 0, 0, 62, 28, 71, 0, 0, 0 }; gbl_tabCopybook.rowHeights = new int[] { 1, 0, 0, 0 }; gbl_tabCopybook.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_tabCopybook.rowWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE }; tabCopybook.setLayout(gbl_tabCopybook); JLabel lblCopybook = new JLabel(Language.txtFilePds); GridBagConstraints gbc_lblCopybook = new GridBagConstraints(); gbc_lblCopybook.anchor = GridBagConstraints.EAST; gbc_lblCopybook.insets = new Insets(0, 0, 5, 5); gbc_lblCopybook.gridx = 1; gbc_lblCopybook.gridy = 1; tabCopybook.add(lblCopybook, gbc_lblCopybook); txtPath = new JTextField(); GridBagConstraints gbc_txtPath = new GridBagConstraints(); gbc_txtPath.gridwidth = 4; gbc_txtPath.insets = new Insets(0, 0, 5, 5); gbc_txtPath.fill = GridBagConstraints.HORIZONTAL; gbc_txtPath.gridx = 2; gbc_txtPath.gridy = 1; tabCopybook.add(txtPath, gbc_txtPath); txtPath.setColumns(10); JButton btnDiretorio = new JButton(""); btnDiretorio.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/folder.png"))); btnDiretorio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { openDirectory(); } }); GridBagConstraints gbc_btnDiretorio = new GridBagConstraints(); gbc_btnDiretorio.insets = new Insets(0, 0, 5, 5); gbc_btnDiretorio.gridx = 6; gbc_btnDiretorio.gridy = 1; tabCopybook.add(btnDiretorio, gbc_btnDiretorio); btnClearCopy = new JButton(""); btnClearCopy.setEnabled(false); btnClearCopy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { tableCopy = new JTable(); scrCopy.setViewportView(tableCopy); tableString = new JTable(); scrTableString.setViewportView(tableString); btnExcelString.setEnabled(false); btnClearString.setEnabled(false); textAreaString.setText(""); console.removeAllElements(); btnExcel.setEnabled(false); btnClearCopy.setEnabled(false); grpFontes.setEnabledAt(1, false); tableFile = new JTable(); scrFile.setViewportView(tableFile); btnExcelFile.setEnabled(false); btnClearFile.setEnabled(false); grpFontes.setEnabledAt(2, false); } }); btnClearCopy.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png"))); GridBagConstraints gbc_btnLimpar = new GridBagConstraints(); gbc_btnLimpar.fill = GridBagConstraints.BOTH; gbc_btnLimpar.insets = new Insets(0, 0, 5, 5); gbc_btnLimpar.gridx = 9; gbc_btnLimpar.gridy = 1; tabCopybook.add(btnClearCopy, gbc_btnLimpar); JButton btnProcessarBook = new JButton(""); btnProcessarBook.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadData(); btnClearCopy.setEnabled(true); grpFontes.setEnabledAt(1, true); grpFontes.setEnabledAt(2, true); } }); btnProcessarBook.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png"))); GridBagConstraints gbc_btnProcessarBook = new GridBagConstraints(); gbc_btnProcessarBook.fill = GridBagConstraints.VERTICAL; gbc_btnProcessarBook.insets = new Insets(0, 0, 5, 5); gbc_btnProcessarBook.gridx = 7; gbc_btnProcessarBook.gridy = 1; tabCopybook.add(btnProcessarBook, gbc_btnProcessarBook); btnExcel = new JButton(""); btnExcel.setEnabled(false); btnExcel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { expExcelBook(); // exportarExcelBook(tableCopy, txtPath.getText(), // "Horizontal"); } }); btnExcel.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png"))); GridBagConstraints gbc_btnExcel = new GridBagConstraints(); gbc_btnExcel.insets = new Insets(0, 0, 5, 5); gbc_btnExcel.gridx = 8; gbc_btnExcel.gridy = 1; tabCopybook.add(btnExcel, gbc_btnExcel); // JScrollPane scrCopy = new JScrollPane(); gbc_scrCopy = new GridBagConstraints(); gbc_scrCopy.gridwidth = 9; gbc_scrCopy.insets = new Insets(0, 0, 0, 5); gbc_scrCopy.fill = GridBagConstraints.BOTH; gbc_scrCopy.gridx = 1; gbc_scrCopy.gridy = 2; // tabCopybook.add(scrCopy, gbc_scrCopy); panelConsole = new Panel(); GridBagConstraints gbc_panelConsole = new GridBagConstraints(); gbc_panelConsole.insets = new Insets(0, 0, 5, 0); gbc_panelConsole.fill = GridBagConstraints.BOTH; gbc_panelConsole.gridx = 0; gbc_panelConsole.gridy = 1; getContentPane().add(panelConsole, gbc_panelConsole); panelConsole.setLayout(new BorderLayout(0, 0)); listTerminal = new JList<String>(); listTerminal.setFont(new Font("Courier New", Font.PLAIN, 11)); listTerminal.setModel(console); scrConsole = new JScrollPane(listTerminal); panelConsole.add(scrConsole); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnNewMenu = new JMenu(Language.menuParam); menuBar.add(mnNewMenu); JMenuItem mnItemUsuario = new JMenuItem(Language.menuParamUser); mnItemUsuario.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FrmUser frmUsuar = new FrmUser(); frmUsuar.setLocationRelativeTo(null); frmUsuar.setVisible(true); setUser(); } }); mnNewMenu.add(mnItemUsuario); JMenuItem mnItemFtp = new JMenuItem(Language.menuParamFtp); mnItemFtp.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FrmFtp frmFtp = new FrmFtp(); frmFtp.setLocationRelativeTo(null); frmFtp.setVisible(true); setFtp(); } }); mnNewMenu.add(mnItemFtp); JMenu mnAjuda = new JMenu(Language.menuHelp); menuBar.add(mnAjuda); JMenuItem mntmNewMenuItem = new JMenuItem(Language.menuHelpAbout); mntmNewMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { FrmAbout frmSobre = new FrmAbout(); frmSobre.setLocationRelativeTo(null); frmSobre.setVisible(true); } }); mnAjuda.add(mntmNewMenuItem); tabCopybook.setFont(new Font("Arial", Font.PLAIN, 12)); tabCopybook.add(scrCopy, gbc_scrCopy); tabString = new JPanel(); tabString.setFont(new Font("Arial", Font.PLAIN, 12)); tabString.setBackground(Color.WHITE); grpFontes.addTab(Language.tabString, null, tabString, null); grpFontes.setEnabledAt(1, false); GridBagLayout gbl_tabString = new GridBagLayout(); gbl_tabString.columnWidths = new int[] { 10, 1, 346, 349, 0, 0, 62, 28, 71, 0, 0, 0 }; gbl_tabString.rowHeights = new int[] { 1, 0, 0, 17, 22, 0, 259, 0 }; gbl_tabString.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_tabString.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; tabString.setLayout(gbl_tabString); JLabel lblString = new JLabel("String:"); GridBagConstraints gbc_lblString = new GridBagConstraints(); gbc_lblString.anchor = GridBagConstraints.WEST; gbc_lblString.insets = new Insets(0, 0, 5, 5); gbc_lblString.gridx = 1; gbc_lblString.gridy = 1; tabString.add(lblString, gbc_lblString); textAreaString = new JTextArea(); JScrollPane scrStringData = new JScrollPane(textAreaString); GridBagConstraints gbc_scrString = new GridBagConstraints(); gbc_scrString.gridheight = 3; gbc_scrString.gridwidth = 8; gbc_scrString.insets = new Insets(0, 0, 5, 5); gbc_scrString.fill = GridBagConstraints.BOTH; gbc_scrString.gridx = 1; gbc_scrString.gridy = 2; tabString.add(scrStringData, gbc_scrString); btnClearString = new JButton(""); btnClearString.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scrTableString.setViewportView(tableString); btnExcelString.setEnabled(false); btnClearString.setEnabled(false); textAreaString.setText(""); tableString = new JTable(); scrTableString.setViewportView(tableString); } }); btnExcelString = new JButton(""); btnExcelString.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { expExcelString(); } }); JButton btnProcessarArq = new JButton(""); btnProcessarArq.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { processString(); } }); btnProcessarArq.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png"))); GridBagConstraints gbc_btnProcessarArq = new GridBagConstraints(); gbc_btnProcessarArq.fill = GridBagConstraints.VERTICAL; gbc_btnProcessarArq.insets = new Insets(0, 0, 5, 5); gbc_btnProcessarArq.gridx = 9; gbc_btnProcessarArq.gridy = 2; tabString.add(btnProcessarArq, gbc_btnProcessarArq); btnExcelString.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png"))); btnExcelString.setEnabled(false); GridBagConstraints gbc_btnExcelString = new GridBagConstraints(); gbc_btnExcelString.fill = GridBagConstraints.VERTICAL; gbc_btnExcelString.insets = new Insets(0, 0, 5, 5); gbc_btnExcelString.gridx = 9; gbc_btnExcelString.gridy = 3; tabString.add(btnExcelString, gbc_btnExcelString); btnClearString.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png"))); btnClearString.setEnabled(false); GridBagConstraints gbc_btnClearString = new GridBagConstraints(); gbc_btnClearString.fill = GridBagConstraints.VERTICAL; gbc_btnClearString.insets = new Insets(0, 0, 5, 5); gbc_btnClearString.gridx = 9; gbc_btnClearString.gridy = 4; tabString.add(btnClearString, gbc_btnClearString); JLabel lblSaida = new JLabel(Language.txtOutput); GridBagConstraints gbc_lblSaida = new GridBagConstraints(); gbc_lblSaida.insets = new Insets(0, 0, 5, 5); gbc_lblSaida.gridx = 1; gbc_lblSaida.gridy = 5; tabString.add(lblSaida, gbc_lblSaida); GridBagConstraints gbc_scrArquivo = new GridBagConstraints(); gbc_scrArquivo.fill = GridBagConstraints.BOTH; gbc_scrArquivo.gridwidth = 9; gbc_scrArquivo.insets = new Insets(0, 0, 0, 5); gbc_scrArquivo.gridx = 1; gbc_scrArquivo.gridy = 6; tabString.add(scrTableString, gbc_scrArquivo); tabFile = new JPanel(); tabFile.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub if (isProcessStarted) { int key = e.getKeyCode(); if (key == KeyEvent.VK_ESCAPE) { int opc = JOptionPane.showConfirmDialog(null, Language.msgCancelProcess, Language.msgInf, JOptionPane.OK_CANCEL_OPTION); if (opc == JOptionPane.OK_OPTION) { escProcessFile(); } } } } @Override public void keyReleased(KeyEvent arg0) { // TODO Auto-generated method stub } @Override public void keyTyped(KeyEvent arg0) { // TODO Auto-generated method stub } }); tabFile.setFont(new Font("Arial", Font.PLAIN, 12)); tabFile.setBackground(Color.WHITE); grpFontes.addTab(Language.tabFile, null, tabFile, null); grpFontes.setEnabledAt(2, false); GridBagLayout gbl_tabFile = new GridBagLayout(); gbl_tabFile.columnWidths = new int[] { 10, 1, 49, 459, 0, 0, 62, 28, 0, 71, 0, 0, 0, 0 }; gbl_tabFile.rowHeights = new int[] { 1, 0, 0, 17, 22, 0, 259, 0, 0 }; gbl_tabFile.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_tabFile.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; tabFile.setLayout(gbl_tabFile); JLabel lblFile = new JLabel(Language.txtFilePds); GridBagConstraints gbc_lblFile = new GridBagConstraints(); gbc_lblFile.anchor = GridBagConstraints.EAST; gbc_lblFile.insets = new Insets(0, 0, 5, 5); gbc_lblFile.gridx = 1; gbc_lblFile.gridy = 1; tabFile.add(lblFile, gbc_lblFile); txtFile = new JTextField(); txtFile.setColumns(10); GridBagConstraints gbc_txtFile = new GridBagConstraints(); gbc_txtFile.gridwidth = 5; gbc_txtFile.insets = new Insets(0, 0, 5, 5); gbc_txtFile.fill = GridBagConstraints.HORIZONTAL; gbc_txtFile.gridx = 2; gbc_txtFile.gridy = 1; tabFile.add(txtFile, gbc_txtFile); btnClearFile = new JButton(""); btnClearFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { tableFile = new JTable(); scrFile.setViewportView(tableFile); btnExcelFile.setEnabled(false); btnClearFile.setEnabled(false); progressBar.setStringPainted(true); progressBar.setValue(0); progressBar.setString(""); } }); btnExcelFile = new JButton(""); btnExcelFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { expExcelFile(); } }); btnProcFile = new JButton(""); btnProcFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadFile(); } }); btnDirFile = new JButton(""); btnDirFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openDirFile(); } }); btnDirFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/folder.png"))); GridBagConstraints gbc_btnDirFile = new GridBagConstraints(); gbc_btnDirFile.fill = GridBagConstraints.VERTICAL; gbc_btnDirFile.insets = new Insets(0, 0, 5, 5); gbc_btnDirFile.gridx = 7; gbc_btnDirFile.gridy = 1; tabFile.add(btnDirFile, gbc_btnDirFile); btnProcFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png"))); GridBagConstraints gbc_btnProcFile = new GridBagConstraints(); gbc_btnProcFile.fill = GridBagConstraints.VERTICAL; gbc_btnProcFile.insets = new Insets(0, 0, 5, 5); gbc_btnProcFile.gridx = 8; gbc_btnProcFile.gridy = 1; tabFile.add(btnProcFile, gbc_btnProcFile); btnExcelFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png"))); btnExcelFile.setEnabled(false); GridBagConstraints gbc_btnExcelFile = new GridBagConstraints(); gbc_btnExcelFile.insets = new Insets(0, 0, 5, 5); gbc_btnExcelFile.gridx = 9; gbc_btnExcelFile.gridy = 1; tabFile.add(btnExcelFile, gbc_btnExcelFile); btnClearFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png"))); btnClearFile.setEnabled(false); GridBagConstraints gbc_btnLimparFile = new GridBagConstraints(); gbc_btnLimparFile.fill = GridBagConstraints.VERTICAL; gbc_btnLimparFile.insets = new Insets(0, 0, 5, 5); gbc_btnLimparFile.gridx = 10; gbc_btnLimparFile.gridy = 1; tabFile.add(btnClearFile, gbc_btnLimparFile); JLabel lblTamanho = new JLabel(Language.txtFileLength); GridBagConstraints gbc_lblTamanho = new GridBagConstraints(); gbc_lblTamanho.anchor = GridBagConstraints.WEST; gbc_lblTamanho.insets = new Insets(0, 0, 5, 5); gbc_lblTamanho.gridx = 1; gbc_lblTamanho.gridy = 2; tabFile.add(lblTamanho, gbc_lblTamanho); txtLength = new JTextField(); GridBagConstraints gbc_txtTamanho = new GridBagConstraints(); gbc_txtTamanho.fill = GridBagConstraints.HORIZONTAL; gbc_txtTamanho.insets = new Insets(0, 0, 5, 5); gbc_txtTamanho.gridx = 2; gbc_txtTamanho.gridy = 2; tabFile.add(txtLength, gbc_txtTamanho); txtLength.setColumns(10); JLabel label_1 = new JLabel(Language.txtOutput); GridBagConstraints gbc_label_1 = new GridBagConstraints(); gbc_label_1.anchor = GridBagConstraints.WEST; gbc_label_1.insets = new Insets(0, 0, 5, 5); gbc_label_1.gridx = 1; gbc_label_1.gridy = 3; tabFile.add(label_1, gbc_label_1); GridBagConstraints gbc_scrFile = new GridBagConstraints(); gbc_scrFile.gridheight = 3; gbc_scrFile.fill = GridBagConstraints.BOTH; gbc_scrFile.gridwidth = 10; gbc_scrFile.insets = new Insets(0, 0, 5, 5); gbc_scrFile.gridx = 1; gbc_scrFile.gridy = 4; tabFile.add(scrFile, gbc_scrFile); progressBar = new JProgressBar(); GridBagConstraints gbc_progressBar = new GridBagConstraints(); gbc_progressBar.fill = GridBagConstraints.HORIZONTAL; gbc_progressBar.gridwidth = 10; gbc_progressBar.insets = new Insets(0, 0, 0, 5); gbc_progressBar.gridx = 1; gbc_progressBar.gridy = 7; tabFile.add(progressBar, gbc_progressBar); JLabel lblNewLabel = new JLabel(Language.txtDeveloped + " Rodrigo Augusto Silva dos Santos - 2016"); GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); gbc_lblNewLabel.gridx = 0; gbc_lblNewLabel.gridy = 2; getContentPane().add(lblNewLabel, gbc_lblNewLabel); loadParameters(); }
From source file:pi.bestdeal.gui.InterfacePrincipale.java
private void Add_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Add_ButtonActionPerformed Panel_Ajouter panajout = new Panel_Ajouter(); Deal deal = new Deal(); int result = JOptionPane.showConfirmDialog(null, panajout, "Test", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { deal.setTitreDeal_Deal(panajout.txtTitre.getText()); Vendeur vendeur = new Vendeur(); VendeurDAO daov = VendeurDAO.getInstance(); for (Vendeur a : daov.displayvendeurByNom(String.valueOf(panajout.jList1.getSelectedValue()))) { vendeur = a;//from w w w . jav a 2 s . c o m } if (panajout.jList1.getSelectedValue() == null) { vendeur.setIdVendeur(0); } deal.setDescDeal_Deal(panajout.txtDesc.getText()); deal.setPrixDeal_Deal(Double.valueOf(panajout.txtPrix.getText())); deal.setNbrAchatValidation(Integer.valueOf(panajout.txtValidation.getText())); deal.setNbrAchatActuelDeal_Deal(0); deal.setNbrAffichage_Deal(0); deal.setEtatDeal_Deal("Comming"); deal.setCategorie_Deal(panajout.ComboCategorie.getSelectedItem().toString()); deal.setStatutDeal_Deal(false); java.util.Date d1 = panajout.jdateDebut.getCalendar().getTime(); java.sql.Date sqlDate = new java.sql.Date(d1.getTime()); java.util.Date d2 = panajout.jdateFin.getCalendar().getTime(); java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime()); if (d1.after(d2)) { JOptionPane.showMessageDialog(null, "les Dates sont non compatibles"); } else { deal.setDateDebutDeal_Deal(sqlDate); deal.setDateFinDeal_Deal(sqlDate2); deal.setIdVendeur_Deal(vendeur.getIdVendeur()); DealDAO dealdao = DealDAO.getInstance(); dealdao.insertDeal(deal); Deal dd = dealdao.displayDeal().get((dealdao.displayDeal().size() - 1)); y = dd.getIdDeal_Deal(); System.out.println(y); if (panajout.fc.getSelectedFiles().length != 0) { for (int i = 0; i < panajout.fc.getSelectedFiles().length; i++) { FileInputStream fis = null; try { fis = new FileInputStream(panajout.file[i]); } catch (FileNotFoundException ex) { Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex); } ImageDeal imgdeal = new ImageDeal(); Path path = Paths.get(panajout.file[i].getAbsolutePath()); try { imgdeal.setImage(Files.readAllBytes(path)); } catch (IOException ex) { Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex); } imgdeal.setIdDeal(y); ImageDAO im = ImageDAO.getInstance(); im.InsertImage(imgdeal); } } JOptionPane.showMessageDialog(null, "Ajout termin"); DealTableModel mymodel = new DealTableModel(list.displayDeal()); jTable1.setModel(mymodel); jTable1.removeColumn(jTable1.getColumn("ID")); jTable1.removeColumn(jTable1.getColumn("Description")); jTable1.removeColumn(jTable1.getColumn("Achat Actuel")); jTable1.removeColumn(jTable1.getColumn("Etat")); jTable1.removeColumn(jTable1.getColumn("Statut")); jTable1.removeColumn(jTable1.getColumn("Nombre d'Affichage")); jTable1.removeColumn(jTable1.getColumn("Vendeur")); jTable1.getColumnModel().setColumnMargin(20); jTable1.setRowSelectionInterval(0, 0); y = mymodel.getRowCount(); panajout.w = y; System.out.println("la valeur de y est :" + y + "et " + panajout.w); } } else { System.out.println("Cancelled"); } }
From source file:com.sec.ose.osi.ui.frm.main.manage.JPanManageMain.java
/** * This method initializes jButtonSearch * /*from www.j av a2 s .com*/ * @return javax.swing.JButton */ private JButton getJButtonAdd() { if (jButtonAdd == null) { jButtonAdd = new JButton(); jButtonAdd.setText(" Add "); jButtonAdd.setPreferredSize(new Dimension(75, 28)); jButtonAdd.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { log.debug("actionPerformed() : Add Button Clicked!"); if (OSIProjectInfoMgr.getInstance().getAllProjects().size() > 0) { JDlgProjectAdd dlgProjectList = new JDlgProjectAdd(frmOwner); dlgProjectList.setManageMain(JPanManageMain.this); dlgProjectList.setSize(600, 300); WindowUtil.locateCenter(dlgProjectList); dlgProjectList.setVisible(true); } else { String[] buttonOK = { "OK" }; JOptionPane.showOptionDialog(null, "There is no project", "Search Project", JOptionPane.OK_OPTION, JOptionPane.WARNING_MESSAGE, null, buttonOK, "OK"); return; } } }); } return jButtonAdd; }