List of usage examples for javax.swing JOptionPane showConfirmDialog
public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType) throws HeadlessException
optionType
parameter. From source file:com.holycityaudio.SpinCAD.SpinCADFile.java
public void fileSaveSpj(SpinCADBank bank) { // Create a file chooser String savedPath = prefs.get("MRUSpjFolder", ""); String[] spnFileNames = new String[8]; final JFileChooser fc = new JFileChooser(savedPath); // In response to a button click: FileNameExtensionFilter filter = new FileNameExtensionFilter("Spin Project Files", "spj"); fc.setFileFilter(filter);//from w w w . ja va2s . c o m // XXX debug fc.showSaveDialog(new JFrame()); File fileToBeSaved = fc.getSelectedFile(); if (!fc.getSelectedFile().getAbsolutePath().endsWith(".spj")) { fileToBeSaved = new File(fc.getSelectedFile() + ".spj"); } int n = JOptionPane.YES_OPTION; if (fileToBeSaved.exists()) { JFrame frame1 = new JFrame(); n = JOptionPane.showConfirmDialog(frame1, "Would you like to overwrite it?", "File already exists!", JOptionPane.YES_NO_OPTION); } if (n == JOptionPane.YES_OPTION) { // filePath points at the desired Spj file String filePath = fileToBeSaved.getPath(); String folder = fileToBeSaved.getParent().toString(); // export the individual SPN files for (int i = 0; i < 8; i++) { try { String asmFileNameRoot = FilenameUtils.removeExtension(bank.patch[i].patchFileName); String asmFileName = folder + "\\" + asmFileNameRoot + ".spn"; if (bank.patch[i].patchFileName != "Untitled") { fileSaveAsm(bank.patch[i], asmFileName); spnFileNames[i] = asmFileName; } } catch (IOException e) { JOptionPane.showOptionDialog(null, "File save error!", "Error", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); e.printStackTrace(); } finally { } } // now create the Spin Project file fileToBeSaved.delete(); BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(fileToBeSaved, true)); } catch (IOException e1) { e1.printStackTrace(); } try { writer.write("NUMDOCS:8"); writer.newLine(); } catch (IOException e1) { e1.printStackTrace(); } for (int i = 0; i < 8; i++) { try { if (bank.patch[i].patchFileName != "Untitled") { writer.write(spnFileNames[i] + ",1"); } else { writer.write(",0"); } writer.newLine(); } catch (IOException e) { JOptionPane.showOptionDialog(null, "File save error!\n" + filePath, "Error", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); e.printStackTrace(); } } // write the build flags try { writer.write(",1,1,1"); writer.newLine(); } catch (IOException e1) { e1.printStackTrace(); } try { writer.close(); } catch (IOException e) { e.printStackTrace(); } saveMRUSpjFolder(filePath); } }
From source file:fi.hoski.remote.ui.Admin.java
private JMenuItem menuItemRemoveYear() { final String title = TextUtil.getText("REMOVE YEAR"); JMenuItem removeEntityItem = new JMenuItem(title); ActionListener removeEntityAction = new ActionListener() { @Override//ww w . j av a 2 s . c om public void actionPerformed(ActionEvent e) { Object yearString = JOptionPane.showInputDialog(frame, title, "", JOptionPane.OK_CANCEL_OPTION); if (yearString != null) { String confirm = TextUtil.getText("CONFIRM REMOVE") + " " + yearString; if (JOptionPane.showConfirmDialog(frame, confirm, "", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { long year = Long.parseLong(yearString.toString()); Day now = new Day(); if (year < now.getYear()) { int count = dss.remove(year); JOptionPane.showMessageDialog(frame, TextUtil.getText("REMOVED") + " " + count); } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("CANNOT REMOVE") + " " + year); } } } } }; removeEntityAction = createActionListener(frame, removeEntityAction); removeEntityItem.addActionListener(removeEntityAction); return removeEntityItem; }
From source file:com.sec.ose.osi.thread.ui_related.UserCommandExecutionThread.java
private void syncToServer() { long start = System.currentTimeMillis(); boolean result = IdentifyQueue.getInstance().makeBackup(); if (result == false) { mObserver.setResult(UIResponseObserver.RESULT_FAIL); mObserver.setFailMessage("Can't make backup file"); return;//from w w w . j a v a2s.com } Property.getInstance().setProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH, "false"); while (IdentifyQueue.getInstance().size() > 0) { if (IdentifyQueue.getInstance().size() <= 1) { Property.getInstance().setProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH, "true"); } else { Property.getInstance().setProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH, "false"); } try { Thread.sleep(50); } catch (Exception e) { } mObserver.setMessageHeader("Flushing items in identify queue to Protex Server - " + IdentifyQueue.getInstance().size() + " file(s) remains.\n"); IdentifyData iData = IdentifyQueue.getInstance().firstElement(); if (iData == null) break; String fullPathMessage = iData.getFilePath().toString(); String displayedFullPath = ""; while (fullPathMessage.length() > 75) { displayedFullPath += fullPathMessage.substring(0, 75) + "\n "; fullPathMessage = fullPathMessage.substring(75); } displayedFullPath += fullPathMessage; String out = " > Identifying \"" + iData.getProjectName() + "\"\n" + " " + displayedFullPath + "\n " + " (identified at " + iData.getTimeStamp() + ")"; mObserver.pushMessageWithHeader(out); } Property.getInstance().setProperty(Property.IDENTIFICATION_WITH_SYNCHRONOUS_BOM_REFRESH, "true"); String title = "Sync to server - " + IdentifyMediator.getInstance().getSelectedProjectName(); String message = "\"Sync To Server\" finished.\n" + "Do you want to progress \"Sync From Server\" for UI updating?"; int yesNo = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION); if (yesNo == JOptionPane.YES_OPTION) { long end = System.currentTimeMillis(); log.debug("@@@ To Server TIME : " + (end - start) / 1000.0); syncFromServer(); } }
From source file:br.com.jinsync.view.FrmJInSync.java
/** * Initialize the contents of the frame. *///from w w w . j av a 2 s. co m 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:edu.ku.brc.af.ui.db.DatabaseLoginPanel.java
/** * Creates the UI for the login and hooks up any listeners. * @param isDlg whether the parent is a dialog (false mean JFrame) * @param iconName the icon that will be shown in the panel * @param engageUPPrefs whether it should load and save the username password into the prefs * @param helpContext the help context to use. *///from ww w .j av a 2s . c o m protected void createUI(final boolean isDlg, final String iconName, final String helpContext) { final boolean isNotEmbedded = !DBConnection.getInstance().isEmbedded() && !UIRegistry.isMobile(); final AppPreferences localPrefs = AppPreferences.getLocalPrefs(); //Font cachedFont = UIManager.getFont("JLabel.font"); SkinItem skinItem = SkinsMgr.getSkinItem("LoginPanel"); if (skinItem != null) { skinItem.pushFG("Label.foreground"); } if (isNotEmbedded) { SpinnerModel portModel = new SpinnerNumberModel(3306, //initial value 0, //min Integer.MAX_VALUE, //max 1); //step portSpinner = new JSpinner(portModel); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(portSpinner, "#"); portSpinner.setEditor(editor); portSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex()); if (drvInfo != null && isNotEmbedded && portSpinner != null) { drvInfo.setPort((Integer) portSpinner.getValue()); } } }); setControlSize(portSpinner); } // First create the controls and hook up listeners dbPickList = new PropertiesPickListAdapter("login.databases"); //$NON-NLS-1$ svPickList = new PropertiesPickListAdapter("login.servers"); //$NON-NLS-1$ username = createTextField(15); password = createPasswordField(15); FocusAdapter focusAdp = new FocusAdapter() { @Override public void focusGained(FocusEvent e) { super.focusGained(e); JTextField tf = (JTextField) e.getSource(); tf.selectAll(); } }; username.addFocusListener(focusAdp); password.addFocusListener(focusAdp); databases = new ValComboBox(dbPickList); if (databases.getComboBox() instanceof Java2sAutoComboBox) { ((Java2sAutoComboBox) databases.getComboBox()).setCaseSensitive(true); } servers = new ValComboBox(svPickList); dbPickList.setComboBox(databases); svPickList.setComboBox(servers); setControlSize(password); setControlSize(databases); setControlSize(servers); if (masterUsrPwdProvider != null) { editKeyInfoBtn = UIHelper.createI18NButton("CONFIG_MSTR_KEY"); editKeyInfoBtn.setIcon(IconManager.getIcon("Key", IconManager.IconSize.Std20)); editKeyInfoBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (masterUsrPwdProvider != null && databases != null) { String itemName = null; if (databases.getComboBox().getSelectedItem() instanceof String) { itemName = (String) databases.getComboBox().getSelectedItem(); } else { PickListItemIFace pli = (PickListItemIFace) databases.getComboBox().getSelectedItem(); if (pli != null && pli.getValue() != null) { itemName = pli.getValue(); } } if (itemName != null) { masterUsrPwdProvider.editMasterInfo(username.getText(), itemName, false); } } } }); } rememberUsernameCBX = createCheckBox(getResourceString("rememberuser")); //$NON-NLS-1$ rememberUsernameCBX.setEnabled(engageUPPrefs); statusBar = new JStatusBar(); statusBar.setErrorIcon(IconManager.getIcon("Error", IconManager.IconSize.Std16)); //$NON-NLS-1$ cancelBtn = createButton(getResourceString("CANCEL")); //$NON-NLS-1$ loginBtn = createButton(getResourceString("Login")); //$NON-NLS-1$ helpBtn = createButton(getResourceString("HELP")); //$NON-NLS-1$ forwardImgIcon = IconManager.getIcon("Forward"); //$NON-NLS-1$ downImgIcon = IconManager.getIcon("Down"); //$NON-NLS-1$ moreBtn = new JCheckBox(getResourceString("LOGIN_DLG_MORE"), forwardImgIcon); // XXX I18N //$NON-NLS-1$ setControlSize(moreBtn); // Extra dbDrivers = DatabaseDriverInfo.getDriversList(); dbDriverCBX = createComboBox(dbDrivers); dbDriverCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateUIControls(); DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex()); if (drvInfo != null && isNotEmbedded && portSpinner != null) { Integer defPort = drvInfo.getPortAsInt(); int portFromPref = localPrefs.getInt(LOGIN_PORT, defPort); portSpinner.setValue(portFromPref); drvInfo.setPort(portFromPref); } } }); if (dbDrivers.size() > 0) { if (dbDrivers.size() == 1) { dbDriverCBX.setSelectedIndex(0); dbDriverCBX.setEnabled(false); } else { String selectedStr = localPrefs.get("login.dbdriver_selected", "MySQL"); //$NON-NLS-1$ //$NON-NLS-2$ int inx = Collections.binarySearch(dbDrivers, new DatabaseDriverInfo(selectedStr, null, null, false, null)); dbDriverCBX.setSelectedIndex(inx > -1 ? inx : -1); } } else { JOptionPane.showConfirmDialog(null, getResourceString("NO_DBDRIVERS"), //$NON-NLS-1$ getResourceString("NO_DBDRIVERS_TITLE"), JOptionPane.CLOSED_OPTION); //$NON-NLS-1$ System.exit(1); } addFocusListenerForTextComp(username); addFocusListenerForTextComp(password); addKeyListenerFor(username, !isDlg); addKeyListenerFor(password, !isDlg); addKeyListenerFor(databases.getTextField(), !isDlg); addKeyListenerFor(servers.getTextField(), !isDlg); if (!isDlg) { addKeyListenerFor(loginBtn, true); } rememberUsernameCBX.setSelected(engageUPPrefs ? localPrefs.getBoolean("login.rememberuser", false) : false); //$NON-NLS-1$ cancelBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (dbListener != null) { dbListener.cancelled(); } } }); loginBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doLogin(); } }); HelpMgr.registerComponent(helpBtn, helpContext); //$NON-NLS-1$ moreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (extraPanel.isVisible()) { if (dbDriverCBX.getSelectedIndex() != -1) { extraPanel.setVisible(false); moreBtn.setIcon(forwardImgIcon); } } else { extraPanel.setVisible(true); moreBtn.setIcon(downImgIcon); } if (window != null) { window.pack(); } } }); // Ask the PropertiesPickListAdapter to set the index from the prefs dbPickList.setSelectedIndex(); svPickList.setSelectedIndex(); servers.getTextField().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateUIControls(); } }); databases.getTextField().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateUIControls(); } }); databases.getTextField().addFocusListener(new FocusAdapter() { String server = null; private String getServerStr() { String serverStr = null; Object serverObj = servers.getValue(); if (serverObj != null) { serverStr = serverObj.toString(); } return serverStr; } @Override public void focusGained(FocusEvent e) { server = getServerStr(); } @Override public void focusLost(FocusEvent e) { if (server != null) { String newVal = getServerStr(); if (newVal != null && !newVal.equals(server)) { setUsrPwdControlsFromPrefs(); } } } }); setUsrPwdControlsFromPrefs(); // Layout the form PanelBuilder formBuilder = new PanelBuilder(new FormLayout("p,3dlu,p:g", "p,2dlu,p,2dlu,p,2dlu,p,2dlu,p")); //$NON-NLS-1$ //$NON-NLS-2$ CellConstraints cc = new CellConstraints(); formBuilder.addSeparator(getResourceString("LOGINLABEL"), cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$ addLine("username", username, formBuilder, cc, 3); //$NON-NLS-1$ addLine("password", password, formBuilder, cc, 5); //$NON-NLS-1$ formBuilder.add(moreBtn, cc.xy(3, 7)); PanelBuilder extraPanelBlder = new PanelBuilder(new FormLayout("p,3dlu,p:g", //$NON-NLS-1$ UIHelper.createDuplicateJGoodiesDef("p", "2dlu", isNotEmbedded ? 9 : 11))); //$NON-NLS-1$ //$NON-NLS-2$ extraPanel = extraPanelBlder.getPanel(); extraPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 4, 2)); //extraPanelBlder.addSeparator("", cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$ int y = 1; y = addLine(null, rememberUsernameCBX, extraPanelBlder, cc, y); y = addLine("databases", databases, extraPanelBlder, cc, y); //$NON-NLS-1$ y = addLine("servers", servers, extraPanelBlder, cc, y); //$NON-NLS-1$ y = addLine("driver", dbDriverCBX, extraPanelBlder, cc, y); //$NON-NLS-1$ if (isNotEmbedded) { y = addLine("port", portSpinner, extraPanelBlder, cc, y); //$NON-NLS-1$ } if (editKeyInfoBtn != null) { PanelBuilder pb = new PanelBuilder(new FormLayout("p,f:p:g", "p")); pb.add(editKeyInfoBtn, cc.xy(1, 1)); y = addLine(null, pb.getPanel(), extraPanelBlder, cc, y); pb.getPanel().setOpaque(false); } extraPanel.setVisible(false); formBuilder.add(extraPanelBlder.getPanel(), cc.xywh(3, 9, 1, 1)); PanelBuilder outerPanel = new PanelBuilder(new FormLayout("p,3dlu,p:g", "t:p,2dlu,p,2dlu,p"), this); //$NON-NLS-1$ //$NON-NLS-2$ JLabel icon = StringUtils.isNotEmpty(iconName) ? new JLabel(IconManager.getIcon(iconName)) : null; if (icon != null) { icon.setBorder(BorderFactory.createEmptyBorder(10, 10, 2, 2)); } formBuilder.getPanel().setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 5)); if (icon != null) { outerPanel.add(icon, cc.xy(1, 1)); } JPanel btnPanel = ButtonBarFactory.buildOKCancelHelpBar(loginBtn, cancelBtn, helpBtn); outerPanel.add(formBuilder.getPanel(), cc.xy(3, 1)); outerPanel.add(btnPanel, cc.xywh(1, 3, 3, 1)); outerPanel.add(statusBar, cc.xywh(1, 5, 3, 1)); formBuilder.getPanel().setOpaque(false); outerPanel.getPanel().setOpaque(false); btnPanel.setOpaque(false); updateUIControls(); if (skinItem != null) { skinItem.popFG("Label.foreground"); } if (AppPreferences.getLocalPrefs().getBoolean(expandExtraPanelName, false)) { extraPanel.setVisible(true); moreBtn.setIcon(downImgIcon); } }
From source file:com.proyecto.vista.MantenimientoFactura.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = Controlador.ELIMINAR;//ww w.ja v a 2 s. c o m if (tblFactura.getSelectedRow() != -1) { Integer codigo = tblFactura.getSelectedRow(); Factura factura = facturaControlador.buscarPorId(lista.get(codigo).getId()); if (factura != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar el Tipo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tblFactura.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Factura factura2 = lista.get(filas[0]); lista.remove(factura2); facturaControlador.setSeleccionado(factura2); facturaControlador.accion(accion); } if (facturaControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Tipo eliminado correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Tipo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Tipo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Tipo", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:com.dragoniade.deviantart.favorites.FavoritesDownloader.java
private int showConfirmDialog(Component parentComponent, final Object message, final String title, final int optionType) { final SwingThread<Integer> command = new SwingThread<Integer>() { int result = -1; public void run() { result = JOptionPane.showConfirmDialog(owner, message, title, optionType); }//from ww w .jav a 2 s . c o m public Integer getResult() { return result; } }; SwingThread.runSync(command); return command.getResult(); }