List of usage examples for java.awt.event MouseEvent getButton
public int getButton()
From source file:gov.noaa.ncdc.iosp.avhrr.util.AvhrrLevel1B2Netcdf.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./* ww w.ja v a2 s . c o m*/ */ // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { // Create a file chooser this.setTitle("NCDC sat2netcdf converter"); aboutDialog = new javax.swing.JDialog(); aboutButton = new javax.swing.JButton(); aboutLabel = new javax.swing.JLabel(); aboutDialog.setTitle("About"); aboutDialog.setName("aboutDialog"); // NOI18N aboutDialog.setSize(250, 200); aboutButton.setText("OK"); aboutButton.setName("aboutButton"); // NOI18N aboutButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDialog.hide(); } }); aboutLabel.setText( "<html>\nNCDC sat2netcdf Converter<br> </br>\nCopyright (c) 2008 Work of U.S. Government.<br></br>\nNCDC<br></br>\nContact: ncdc.satorder@noaa.gov\n</html>"); fc = new JFileChooser(); fc.setMultiSelectionEnabled(true); // output directory file chooser outFc = new JFileChooser(); outFc.setMultiSelectionEnabled(false); outFc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); activityMonitor = new Timer(100, new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { convertMonitorActionPerformed(evt); } }); menuBar = new JMenuBar(); logMenu = new JMenu("Log"); logMenuItem = new JMenuItem("View Log"); logMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logDialog.show(); } }); logMenu.add(logMenuItem); menuBar.add(logMenu); helpMenu = new JMenu("Help"); menuBar.add(helpMenu); helpMenuItem = new JMenuItem("Help"); helpMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { helpMenuActionPerformed(evt); } }); helpMenu.add(helpMenuItem); aboutMenuItem = new JMenuItem("About"); aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDialog.show(); } }); helpMenu.add(aboutMenuItem); this.setJMenuBar(menuBar); jButton4 = new javax.swing.JButton(); openButton = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jLabel1 = new javax.swing.JLabel(); outdirButton = new javax.swing.JButton(); outdirText = new javax.swing.JTextField(); jPanel1 = new javax.swing.JPanel(); allChanCheckBox = new javax.swing.JCheckBox(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); chan1CheckBox = new javax.swing.JCheckBox(); chan2CheckBox = new javax.swing.JCheckBox(); chan3CheckBox = new javax.swing.JCheckBox(); chan4CheckBox = new javax.swing.JCheckBox(); chan5CheckBox = new javax.swing.JCheckBox(); rawCheckBox = new javax.swing.JCheckBox(); radCheckBox = new javax.swing.JCheckBox(); tempCheckBox = new javax.swing.JCheckBox(); allVarCheckBox = new javax.swing.JCheckBox(); qualityCheckBox = new javax.swing.JCheckBox(); calCheckBox = new javax.swing.JCheckBox(); latlonCheckBox = new javax.swing.JCheckBox(); metaCheckBox = new javax.swing.JCheckBox(); jLabel2 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); convertButton = new javax.swing.JButton(); exitButton = new javax.swing.JButton(); jButton4.setText("jButton4"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); openButton.setText("Select Files"); openButton.setName("selectButton"); // NOI18N openButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { openButtonActionPerformed(evt); } }); fm = new FileModel(); jTable1 = new JTable(fm); jTable1.setName("table"); // NOI18N jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); setTableCellRenderer(jTable1, new ToolCellRenderer()); // remove popup for table removeItem = new JMenuItem("Remove"); removeItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { int[] selected = jTable1.getSelectedRows(); for (int i : selected) { logTextArea.append("Removed File: " + fm.getFileAtRow(i).getName() + "\n"); } fm.removeRows(selected); } }); popup = new JPopupMenu(); popup.add(removeItem); // Add listener to the jtable so the popup menu can come up. // MouseListener popupListener = new PopupListener(jTable1); // jTable1.addMouseListener(popupListener); jTable1.addMouseListener(new MouseListener() { public void mousePressed(MouseEvent e) { int button = e.getButton(); int[] selected = jTable1.getSelectedRows(); if (button != 1 && selected.length > 0) { popup.show(e.getComponent(), e.getX(), e.getY()); } } public void mouseClicked(MouseEvent e) { int button = e.getButton(); int column = jTable1.getSelectedColumn(); if (0 == column && 1 == button) { updateOutputSize(); } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }); TableColumn col = jTable1.getColumnModel().getColumn(1); col.setPreferredWidth(250); col = jTable1.getColumnModel().getColumn(3); col.setPreferredWidth(100); jScrollPane1.setViewportView(jTable1); jLabel1.setText("Select output directory"); outdirButton.setText("Browse"); outdirButton.setName("outdirButton"); // NOI18N outdirButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { outdirButtonActionPerformed(evt); } }); outdirText.setName("outdirText"); // NOI18N try { outdirText.setText(new File(".").getCanonicalPath()); } catch (IOException ioe) { ioe.printStackTrace(); } jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanel1.setName("optionPanel"); // NOI18N allChanCheckBox.setText("All Channels"); allChanCheckBox.setSelected(true); allChanCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleChannelBoxes("jCheckBox1", allChanCheckBox); updateFileSize(); } }); jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel3.setText("Channels"); jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel4.setText("Calibration"); jLabel4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel5.setText("Additional Data"); jLabel5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); chan1CheckBox.setText("Channel 1"); chan1CheckBox.setSelected(true); chan1CheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleChannelBoxes("chan1CheckBox", chan1CheckBox); updateFileSize(); } }); chan2CheckBox.setText("Channel 2"); chan2CheckBox.setSelected(true); chan2CheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleChannelBoxes("chan2CheckBox", chan2CheckBox); updateFileSize(); } }); chan3CheckBox.setText("Channel 3A/B"); chan3CheckBox.setSelected(true); chan3CheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleChannelBoxes("chan3CheckBox", chan3CheckBox); updateFileSize(); } }); chan4CheckBox.setLabel("Channel 4"); chan4CheckBox.setSelected(true); chan4CheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleChannelBoxes("chan4CheckBox", chan4CheckBox); updateFileSize(); } }); chan5CheckBox.setLabel("Channel 5"); chan5CheckBox.setSelected(true); chan5CheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleChannelBoxes("chan5CheckBox", chan5CheckBox); updateFileSize(); } }); rawCheckBox.setText("Raw Data"); rawCheckBox.setSelected(true); rawCheckBox.setToolTipText("Counts for each pixel"); rawCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleCalibrationCheckBoxes(rawCheckBox); updateFileSize(); } }); radCheckBox.setText("Radiance"); radCheckBox.setToolTipText("Radiance Values"); radCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleCalibrationCheckBoxes(radCheckBox); updateFileSize(); } }); tempCheckBox.setText("Brightness Temperature"); tempCheckBox.setToolTipText("Albedo for visible channels, Brightness Temperature for IR channels"); tempCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleCalibrationCheckBoxes(tempCheckBox); updateFileSize(); } }); allVarCheckBox.setText("All Variables"); allVarCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleAllVariablesCheckBox(); updateFileSize(); } }); qualityCheckBox.setText("Quality Flags"); qualityCheckBox.setToolTipText("Quality Variables"); qualityCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleOtherCheckbox(qualityCheckBox); updateFileSize(); } }); calCheckBox.setText("Calibration Coefficients"); calCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleOtherCheckbox(calCheckBox); updateFileSize(); } }); jLabel2.setText("Select output options"); convertButton.setText("Convert"); convertButton.setName("convertButton"); // NOI18N convertButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { convertButtonActionPerformed(evt); } }); exitButton.setText("Exit"); exitButton.setName("exitButton"); // NOI18N exitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitButtonActionPerformed(evt); } }); // help dialog helpDialog = new javax.swing.JDialog(); helpCloseButton = new javax.swing.JButton("Close"); helpScrollPane = new javax.swing.JScrollPane(); // helpEditorPane = new javax.swing.JEditorPane("text/rtf", helpText); helpEditorPane = new javax.swing.JEditorPane(); helpEditorPane.setContentType("text/html"); InputStream stream = null; try { stream = AvhrrLevel1B2Netcdf.class.getResourceAsStream("/help.html"); if (stream != null) { helpEditorPane.read(stream, "html"); } } catch (IOException e1) { e1.printStackTrace(); } helpScrollPane.setViewportView(helpEditorPane); helpDialog.setSize(450, 500); helpCloseButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { helpDialog.dispose(); } }); // Log Dialog logDialog = new javax.swing.JDialog(); logScrollPane = new javax.swing.JScrollPane(); logTextArea = new javax.swing.JTextArea(); logCloseButton = new javax.swing.JButton(); clearButton = new javax.swing.JButton(); logDialog.setTitle("Log"); logDialog.setName("logDialog"); // NOI18N logDialog.setSize(450, 500); logScrollPane.setName("logScrollPane"); // NOI18N logTextArea.setColumns(20); logTextArea.setRows(5); logTextArea.setName("logTextArea"); // NOI18N logScrollPane.setViewportView(logTextArea); logCloseButton.setText("Close"); logCloseButton.setName("logCloseButton"); // NOI18N logCloseButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { logDialog.hide(); } }); clearButton.setText("Clear"); clearButton.setName("clearButton"); // NOI18N clearButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { logTextArea.setText(""); } }); latlonCheckBox.setText("Lat/Lon"); latlonCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleLatLonCheckbox(); updateFileSize(); } }); metaCheckBox.setText("Other metadata"); metaCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleMetadataCheckbox(); updateFileSize(); } }); jLabel2.setText("Select output options"); convertButton.setText("Convert"); convertButton.setName("convertButton"); exitButton.setText("Exit"); exitButton.setName("exitButton"); exitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitButtonActionPerformed(evt); } }); jLabel2.setText("Select output options"); // NOI18N convertButton.setText("Convert"); // NOI18N convertButton.setName("convertButton"); // NOI18N exitButton.setText("Exit"); // NOI18N exitButton.setName("exitButton"); // NOI18N exitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitButtonActionPerformed(evt); } }); jLabel6.setFont(new java.awt.Font("Dialog", 1, 11)); jLabel6.setText("Estimated output size: "); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup().addContainerGap().add(jPanel1Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(chan5CheckBox) .add(jPanel1Layout.createSequentialGroup().add(jPanel1Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup().add(jPanel1Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.LEADING, allChanCheckBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .add(chan1CheckBox).add(chan2CheckBox)).add(36, 36, 36) .add(jPanel1Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(radCheckBox) .add(tempCheckBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE) .add(rawCheckBox).add(jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .add(chan3CheckBox).add(chan4CheckBox)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(metaCheckBox).add(latlonCheckBox).add(allVarCheckBox) .add(jLabel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 113, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(qualityCheckBox).add(calCheckBox)))) .add(67, 67, 67))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup().addContainerGap() .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel3).add(jLabel5).add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(allChanCheckBox).add(allVarCheckBox).add(rawCheckBox)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(chan1CheckBox).add(qualityCheckBox).add(radCheckBox)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(chan2CheckBox).add(calCheckBox).add(tempCheckBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(chan3CheckBox).add(latlonCheckBox)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(chan4CheckBox).add(metaCheckBox)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(chan5CheckBox) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jLabel2.setText("Select output options"); // NOI18N convertButton.setText("Convert"); // NOI18N convertButton.setName("convertButton"); // NOI18N exitButton.setText("Exit"); // NOI18N exitButton.setName("exitButton"); // NOI18N exitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitButtonActionPerformed(evt); } }); jLabel6.setFont(new java.awt.Font("Dialog", 1, 11)); jLabel6.setText("Estimated output size: "); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup().addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE) .add(layout.createSequentialGroup().add(outdirButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(outdirText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE)) .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE) .add(openButton) .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 291, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(layout.createSequentialGroup().add(convertButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 442, Short.MAX_VALUE)) .add(exitButton).add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE)) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(layout .createSequentialGroup().addContainerGap().add(openButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 173, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jLabel1) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(outdirButton).add( outdirText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 27, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false).add(convertButton) .add(jLabel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(exitButton).add(12, 12, 12))); // log dialog layout org.jdesktop.layout.GroupLayout logDialogLayout = new org.jdesktop.layout.GroupLayout( logDialog.getContentPane()); logDialog.getContentPane().setLayout(logDialogLayout); logDialogLayout.setHorizontalGroup( logDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add( org.jdesktop.layout.GroupLayout.TRAILING, logDialogLayout.createSequentialGroup().addContainerGap() .add(logDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(org.jdesktop.layout.GroupLayout.LEADING, logScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE) .add(logDialogLayout.createSequentialGroup().add(clearButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(logCloseButton))) .addContainerGap())); logDialogLayout.setVerticalGroup(logDialogLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, logDialogLayout.createSequentialGroup() .addContainerGap() .add(logScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE) .add(18, 18, 18) .add(logDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(logCloseButton).add(clearButton)) .addContainerGap())); // help dialog layout org.jdesktop.layout.GroupLayout helpDialogLayout = new org.jdesktop.layout.GroupLayout( helpDialog.getContentPane()); helpDialog.getContentPane().setLayout(helpDialogLayout); helpDialogLayout.setHorizontalGroup( helpDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add( org.jdesktop.layout.GroupLayout.TRAILING, helpDialogLayout.createSequentialGroup().addContainerGap() .add(helpDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(org.jdesktop.layout.GroupLayout.LEADING, helpScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE) .add(helpDialogLayout.createSequentialGroup() .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(helpCloseButton))) .addContainerGap())); helpDialogLayout.setVerticalGroup(helpDialogLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, helpDialogLayout.createSequentialGroup() .addContainerGap() .add(helpScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE) .add(18, 18, 18).add(helpDialogLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(helpCloseButton)) .addContainerGap())); // about dialog layout org.jdesktop.layout.GroupLayout aboutDialogLayout = new org.jdesktop.layout.GroupLayout( aboutDialog.getContentPane()); aboutDialog.getContentPane().setLayout(aboutDialogLayout); aboutDialogLayout.setHorizontalGroup( aboutDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add( org.jdesktop.layout.GroupLayout.TRAILING, aboutDialogLayout.createSequentialGroup().addContainerGap() .add(aboutDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(org.jdesktop.layout.GroupLayout.LEADING, aboutLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE) .add(aboutButton)) .addContainerGap())); aboutDialogLayout.setVerticalGroup( aboutDialogLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add( org.jdesktop.layout.GroupLayout.TRAILING, aboutDialogLayout.createSequentialGroup().addContainerGap() .add(aboutLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 103, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 35, Short.MAX_VALUE) .add(aboutButton).add(21, 21, 21))); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); pack(); JOptionPane.showMessageDialog(this, "Warning! \nThis program is untested.\nPlease read help file for\nsupported files, limitations and license.\n"); // + "Please view Help for more information."); }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
@Override public void mouseReleased(final MouseEvent e) { if (this.application == null) { if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == 0 && e.isPopupTrigger()) { final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint()); onPopup(e.getPoint(), hexNumber); } else {/*from w ww. j a va 2 s .c o m*/ switch (e.getButton()) { case MouseEvent.BUTTON3: { this.dragging = false; this.hexMapPanelDesktop.endDrag(); } break; } } } else if (e.getButton() == MouseEvent.BUTTON3) { this.dragging = false; this.hexMapPanelDesktop.endDrag(); } }
From source file:corelyzer.ui.CorelyzerGLCanvas.java
public void mouseReleased(final MouseEvent e) { // For mouse right-click or Ctrl-Left-Click if (e.isPopupTrigger()) { this.handleRightMouseClick(e); return;/* w ww.ja v a 2s . c o m*/ } if (e.getButton() == MouseEvent.BUTTON1) { if (canvasMode == CorelyzerApp.APP_CLAST_MODE) { this.handleClastMouseReleased(e); } else if (canvasMode == CorelyzerApp.APP_CUT_MODE) { this.handleCutMouseReleased(e); } } prePos.setLocation(0, 0); canvas.setCursor(Cursor.getDefaultCursor()); CorelyzerApp.getApp().updateGLWindows(); }
From source file:display.containers.FileManager.java
public Container getPane() { //if (gui==null) { fileSystemView = FileSystemView.getFileSystemView(); desktop = Desktop.getDesktop(); JPanel detailView = new JPanel(new BorderLayout(3, 3)); //fileTableModel = new FileTableModel(); table = new JTable(); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.setAutoCreateRowSorter(true);//from w w w . j ava 2 s . c om table.setShowVerticalLines(false); table.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.getClickCount() >= 2) { Point p = e.getPoint(); int row = table.convertRowIndexToModel(table.rowAtPoint(p)); int column = table.convertColumnIndexToModel(table.columnAtPoint(p)); if (row >= 0 && column >= 0) { mouseDblClicked(row, column); } } } }); table.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { if (KeyEvent.VK_DELETE == arg0.getKeyCode()) { if (mode != 2) { parentFrame.setLock(true); parentFrame.getProgressBarPanel().setVisible(true); Thread t = new Thread(new Runnable() { @Override public void run() { try { deleteSelectedFiles(); } catch (IOException e) { JOptionPane.showMessageDialog(parentFrame, "Error during the deletion.", "Deletion error", JOptionPane.ERROR_MESSAGE); WindowManager.mwLogger.log(Level.SEVERE, "Error during the deletion.", e); } finally { parentFrame.setLock(false); refresh(); parentFrame.getProgressBarPanel().setVisible(false); } } }); t.start(); } else { if (UserProfile.CURRENT_USER.getLevel() == 3) { parentFrame.setLock(true); parentFrame.getProgressBarPanel().setVisible(true); Thread delThread = new Thread(new Runnable() { @Override public void run() { int[] rows = table.getSelectedRows(); int[] columns = table.getSelectedColumns(); for (int i = 0; i < rows.length; i++) { if (!continueAction) { continueAction = true; return; } int row = table.convertRowIndexToModel(rows[i]); try { deleteServerFile(row); } catch (Exception e) { WindowManager.mwLogger.log(Level.SEVERE, "Error during the deletion.", e); } } refresh(); parentFrame.setLock(false); parentFrame.getProgressBarPanel().setVisible(false); } }); delThread.start(); } } } } @Override public void keyPressed(KeyEvent arg0) { // TODO Auto-generated method stub } }); table.getSelectionModel().addListSelectionListener(listSelectionListener); JScrollPane tableScroll = new JScrollPane(table); Dimension d = tableScroll.getPreferredSize(); tableScroll.setPreferredSize(new Dimension((int) d.getWidth(), (int) d.getHeight() / 2)); detailView.add(tableScroll, BorderLayout.CENTER); // the File tree DefaultMutableTreeNode root = new DefaultMutableTreeNode(); treeModel = new DefaultTreeModel(root); table.getRowSorter().addRowSorterListener(new RowSorterListener() { @Override public void sorterChanged(RowSorterEvent e) { ((FileTableModel) table.getModel()).fireTableDataChanged(); } }); // show the file system roots. File[] roots = fileSystemView.getRoots(); for (File fileSystemRoot : roots) { DefaultMutableTreeNode node = new DefaultMutableTreeNode(fileSystemRoot); root.add(node); //showChildren(node); // File[] files = fileSystemView.getFiles(fileSystemRoot, true); for (File file : files) { if (file.isDirectory()) { node.add(new DefaultMutableTreeNode(file)); } } // } JScrollPane treeScroll = new JScrollPane(); Dimension preferredSize = treeScroll.getPreferredSize(); Dimension widePreferred = new Dimension(200, (int) preferredSize.getHeight()); treeScroll.setPreferredSize(widePreferred); JPanel fileView = new JPanel(new BorderLayout(3, 3)); detailView.add(fileView, BorderLayout.SOUTH); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeScroll, detailView); JPanel simpleOutput = new JPanel(new BorderLayout(3, 3)); progressBar = new JProgressBar(); simpleOutput.add(progressBar, BorderLayout.EAST); progressBar.setVisible(false); showChildren(getCurrentDir().toPath()); //table.setDragEnabled(true); table.setColumnSelectionAllowed(false); // Menu popup Pmenu = new JPopupMenu(); changeProjectitem = new JMenuItem("Reassign"); renameProjectitem = new JMenuItem("Rename"); twitem = new JMenuItem("To workspace"); tlitem = new JMenuItem("To local"); processitem = new JMenuItem("Select for process"); switch (mode) { case 0: Pmenu.add(twitem); twitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { parentFrame.getBtnlocalTowork().doClick(); } }); break; case 1: Pmenu.add(tlitem); Pmenu.add(processitem); tlitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { parentFrame.getBtnWorkTolocal().doClick(); } }); processitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { SwingUtilities.invokeLater(new Runnable() { public void run() { // Recupere les lignes selectionnees int[] indices = table.getSelectedRows(); // On recupere les fichiers correspondants ArrayList<File> files = new ArrayList<File>(); for (int i = 0; i < indices.length; i++) { int row = table.convertRowIndexToModel(indices[i]); File fi = ((FileTableModel) table.getModel()).getFile(row); if (fi.isDirectory()) files.add(fi); } ImageProcessingFrame imf = new ImageProcessingFrame(files); } }); } }); break; case 2: if (UserProfile.CURRENT_USER.getLevel() == 3) { Pmenu.add(changeProjectitem); Pmenu.add(renameProjectitem); } Pmenu.add(twitem); twitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { parentFrame.getBtndistToWorkspace().doClick(); } }); Pmenu.add(tlitem); tlitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { parentFrame.getBtndistToLocal().doClick(); } }); break; } changeProjectitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { table.setEnabled(false); File from = ((FileTableModel) table.getModel()) .getFile(table.convertRowIndexToModel(table.getSelectedRows()[0])); ReassignProjectPanel reas = new ReassignProjectPanel(from.toPath()); // mode creation de liens Popup popup = PopupFactory.getSharedInstance().getPopup(WindowManager.MAINWINDOW, reas, (int) WindowManager.MAINWINDOW.getX() + 200, (int) WindowManager.MAINWINDOW.getY() + 150); reas.setPopupWindow(popup); popup.show(); table.setEnabled(true); } }); renameProjectitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { table.setEnabled(false); final File from = ((FileTableModel) table.getModel()) .getFile(table.convertRowIndexToModel(table.getSelectedRows()[0])); JDialog.setDefaultLookAndFeelDecorated(true); String s = (String) JOptionPane.showInputDialog(WindowManager.MAINWINDOW, "New project name ?", "Rename project", JOptionPane.PLAIN_MESSAGE, null, null, from.getName()); //If a string was returned, say so. if ((s != null) && (s.length() > 0)) { ProjectDAO pdao = new MySQLProjectDAO(); if (new File(from.getParent() + File.separator + s).exists()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Couldn't rename " + from.getName() + " (A file with this filename already exists)", "Renaming error", JOptionPane.ERROR_MESSAGE); } }); WindowManager.mwLogger.log(Level.SEVERE, "Error during file project renaming (" + from.getName() + "). [Duplication error]"); } else { try { boolean succeed = pdao.renameProject(from.getName(), s); if (!succeed) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Couldn't rename " + from.getName() + " (no project with this name)", "Renaming error", JOptionPane.ERROR_MESSAGE); } }); } else { from.renameTo(new File(from.getParent() + File.separator + s)); // on renomme le repertoire nifti ou dicom correspondant si il existe switch (from.getParentFile().getName()) { case ServerInfo.NRI_ANALYSE_NAME: if (new File(from.getAbsolutePath().replaceAll(ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)).exists()) try { Files.move(Paths.get(from.getAbsolutePath().replaceAll( ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)), Paths.get(from.getParent().replaceAll( ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME) + File.separator + s)); } catch (IOException e) { e.printStackTrace(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Couldn't rename " + from.getName() + " (error with file system)", "Renaming error", JOptionPane.ERROR_MESSAGE); } }); WindowManager.mwLogger.log(Level.SEVERE, "Error during file project renaming (" + from.getName() + ")", e); } //from.renameTo(new File(from.getParent().replaceAll(ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)+File.separator+s)); break; case ServerInfo.NRI_DICOM_NAME: if (new File(from.getAbsolutePath().replaceAll(ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)).exists()) try { Files.move(Paths.get(from.getAbsolutePath().replaceAll( ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)), Paths.get(from.getParent().replaceAll(ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME) + File.separator + s)); } catch (IOException e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Couldn't rename " + from.getName() + " (error with file system)", "Renaming error", JOptionPane.ERROR_MESSAGE); } }); e.printStackTrace(); WindowManager.mwLogger.log(Level.SEVERE, "Error during file project renaming (" + from.getName() + ")", e); } //from.renameTo(new File(from.getParent().replaceAll(ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)+File.separator+s)); break; } refresh(); } } catch (final SQLException e) { WindowManager.mwLogger.log(Level.SEVERE, "Error during SQL project renaming", e); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Exception : " + e.toString(), "Openning error", JOptionPane.ERROR_MESSAGE); } }); } } } table.setEnabled(true); } }); table.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent me) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent me) { if (me.getButton() == 3 && table.getSelectedRowCount() > 0) { int row = table.convertRowIndexToModel(table.rowAtPoint(me.getPoint())); changeProjectitem.setVisible(isPatient(((FileTableModel) table.getModel()).getFile(row))); renameProjectitem.setVisible(isProject(((FileTableModel) table.getModel()).getFile(row))); Pmenu.show(me.getComponent(), me.getX(), me.getY()); } } }); // //} return tableScroll; }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
@Override public void mousePressed(final MouseEvent e) { final boolean ctrlPressed = (e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0; if (this.application == null) { if (!ctrlPressed && e.isPopupTrigger()) { final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint()); onPopup(e.getPoint(), hexNumber); } else {// w w w.j a v a 2 s. c o m switch (e.getButton()) { case MouseEvent.BUTTON1: { if (selectedToolType != null && this.selectedLayer != null) { addedUndoStep(new HexFieldLayer[] { this.selectedLayer }); final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint()); useCurrentToolAtPosition(hexNumber); } } break; case MouseEvent.BUTTON3: { if (ctrlPressed) { this.dragging = true; this.hexMapPanelDesktop.initDrag(e.getPoint()); } } break; } } } else if (!ctrlPressed && e.isPopupTrigger() && this.application.allowPopupTrigger()) { this.application.processHexAction(this.hexMapPanel, e, HexAction.POPUP_TRIGGER, this.hexMapPanel.getHexPosition(e.getPoint())); } else if (e.getButton() == MouseEvent.BUTTON3) { this.dragging = true; this.hexMapPanelDesktop.initDrag(e.getPoint()); } }
From source file:ru.goodfil.catalog.ui.forms.CarsPanel.java
private void vechicleTypesListMouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { if (vechicleTypes.size() > 0) { listsPopupMenu.show(vechicleTypesList, e.getX(), e.getY()); }// w w w . j a v a 2 s . co m } }
From source file:ru.goodfil.catalog.ui.forms.CarsPanel.java
private void manufactorsListMouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { if (manufactors.size() > 0) { listsPopupMenu.show(manufactorsList, e.getX(), e.getY()); }/*from w w w. j a v a 2 s .c o m*/ } }
From source file:ru.goodfil.catalog.ui.forms.CarsPanel.java
private void seriesListMouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { if (series.size() > 0) { listsPopupMenu.show(seriesList, e.getX(), e.getY()); }/*from w ww. j av a 2 s. c om*/ } }
From source file:ru.goodfil.catalog.ui.forms.CarsPanel.java
private void motorsTableMouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { if (motors.size() > 0) { listsPopupMenu.show(motorsTable, e.getX(), e.getY()); }/*from w ww. j a va2 s . com*/ } }
From source file:ru.goodfil.catalog.ui.forms.CarsPanel.java
private void filtersTableMouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { if (filters.size() > 0) { listsPopupMenu.show(filtersTable, e.getX(), e.getY()); }//from w w w . ja v a2s .co m } }