List of usage examples for java.awt.event MouseEvent getSource
public Object getSource()
From source file:de.mendelson.comm.as2.client.AS2Gui.java
@Override public void mouseClicked(MouseEvent evt) { if (evt.isPopupTrigger() || evt.isMetaDown()) { if (evt.getSource().equals(this.jTableMessageOverview)) { this.jPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); }//ww w. ja va 2 s . c o m } }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java
/** Initializes the components composing the display. */ private void initComponents() { setLayout(new BorderLayout()); setBackground(UIUtilities.BACKGROUND); setBorder(new SeparatorOneLineBorder()); toReplace = new ArrayList<FileAnnotationData>(); IconManager icons = IconManager.getInstance(); filter = SHOW_ALL;//from ww w. j a va2 s .c om filterButton = new JButton(NAMES[SHOW_ALL]); filterButton.setToolTipText("Filter tags and attachments."); UIUtilities.unifiedButtonLookAndFeel(filterButton); Font font = filterButton.getFont(); filterButton.setFont(font.deriveFont(font.getStyle(), font.getSize() - 2)); filterButton.setIcon(icons.getIcon(IconManager.UP_DOWN_9_12)); filterButton.setBackground(UIUtilities.BACKGROUND_COLOR); filterButton.addMouseListener(new MouseAdapter() { /** * Brings up the menu. * @see MouseListener#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent me) { Object source = me.getSource(); if (source instanceof Component) displayMenu((Component) source, me.getPoint()); } }); otherRating = new JLabel(); otherRating.setBackground(UIUtilities.BACKGROUND_COLOR); font = otherRating.getFont(); otherRating.setFont(font.deriveFont(Font.ITALIC, font.getSize() - 2)); content = new JPanel(); content.setBackground(UIUtilities.BACKGROUND_COLOR); content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); tagFlag = false; docFlag = false; otherFlag = false; tagNames = new ArrayList<String>(); tagsDocList = new ArrayList<DocComponent>(); filesDocList = new ArrayList<DocComponent>(); otherList = new ArrayList<DocComponent>(); existingTags = new HashMap<String, TagAnnotationData>(); addTagsButton = new JButton(icons.getIcon(IconManager.PLUS_12)); UIUtilities.unifiedButtonLookAndFeel(addTagsButton); addTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR); addTagsButton.setToolTipText("Add Tags."); addTagsButton.addActionListener(controller); addTagsButton.setActionCommand("" + EditorControl.ADD_TAGS); addDocsButton = new JButton(icons.getIcon(IconManager.PLUS_12)); addDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR); addDocsButton.setToolTipText("Attach a document."); addDocsButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { if (addDocsButton.isEnabled()) { Point p = e.getPoint(); createDocSelectionMenu().show(addDocsButton, p.x, p.y); } } }); UIUtilities.unifiedButtonLookAndFeel(addDocsButton); removeTagsButton = new JButton(icons.getIcon(IconManager.MINUS_12)); UIUtilities.unifiedButtonLookAndFeel(removeTagsButton); removeTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR); removeTagsButton.setToolTipText("Remove Tags."); removeTagsButton.addMouseListener(controller); removeTagsButton.setActionCommand("" + EditorControl.REMOVE_TAGS); removeDocsButton = new JButton(icons.getIcon(IconManager.MINUS_12)); UIUtilities.unifiedButtonLookAndFeel(removeDocsButton); removeDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR); removeDocsButton.setToolTipText("Remove Attachments."); removeDocsButton.addMouseListener(controller); removeDocsButton.setActionCommand("" + EditorControl.REMOVE_DOCS); removeOtherAnnotationsButton = new JButton(icons.getIcon(IconManager.MINUS_12)); UIUtilities.unifiedButtonLookAndFeel(removeOtherAnnotationsButton); removeOtherAnnotationsButton.setBackground(UIUtilities.BACKGROUND_COLOR); removeOtherAnnotationsButton.setToolTipText("Remove Annotations."); removeOtherAnnotationsButton.addMouseListener(controller); removeOtherAnnotationsButton.setActionCommand("" + EditorControl.REMOVE_OTHER_ANNOTATIONS); selectedValue = 0; initialValue = selectedValue; rating = new RatingComponent(selectedValue, RatingComponent.MEDIUM_SIZE); rating.setOpaque(false); rating.setBackground(UIUtilities.BACKGROUND_COLOR); rating.addPropertyChangeListener(this); unrateButton = new JButton(icons.getIcon(IconManager.MINUS_12)); UIUtilities.unifiedButtonLookAndFeel(unrateButton); unrateButton.setBackground(UIUtilities.BACKGROUND_COLOR); unrateButton.setToolTipText("Unrate."); unrateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rating.setValue(0); view.saveData(true); } }); tagsPane = new JPanel(); tagsPane.setLayout(new BoxLayout(tagsPane, BoxLayout.Y_AXIS)); tagsPane.setBackground(UIUtilities.BACKGROUND_COLOR); DocComponent doc = new DocComponent(null, model); tagsDocList.add(doc); tagsPane.add(doc); docPane = new JPanel(); docPane.setLayout(new BoxLayout(docPane, BoxLayout.Y_AXIS)); docPane.setBackground(UIUtilities.BACKGROUND_COLOR); docRef = docPane; doc = new DocComponent(null, model); filesDocList.add(doc); docPane.add(doc); publishedBox = new JCheckBox(); publishedBox.setBackground(UIUtilities.BACKGROUND_COLOR); publishedBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { firePropertyChange(EditorControl.SAVE_PROPERTY, Boolean.FALSE, Boolean.TRUE); } }); mapsPane = new MapAnnotationsComponent(model, view); otherPane = new JPanel(); otherPane.setLayout(new GridBagLayout()); otherPane.setBackground(UIUtilities.BACKGROUND_COLOR); }
From source file:cfa.vo.sed.science.stacker.SedStackerFrame.java
private void sedsTableMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sedsTableMousePressed if (evt.isPopupTrigger()) { JTable source = (JTable) evt.getSource(); int row = source.rowAtPoint(evt.getPoint()); int column = source.columnAtPoint(evt.getPoint()); if (!source.isRowSelected(row)) source.changeSelection(row, column, false, false); sedsTable.changeSelection(row, column, false, false); jPopupMenu2.show(evt.getComponent(), evt.getX(), evt.getY()); }//from w w w. j a va 2s .c o m }
From source file:com.u2apple.tool.ui.MainFrame.java
private void initRowSelectionEvent() { deviceTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> { int row = deviceTable.getSelectedRow(); //When refresh table model data, row will be -1. if (row >= 0) { String vid = (String) deviceTable.getValueAt(row, 0); String model = (String) deviceTable.getValueAt(row, 1); String brand = (String) deviceTable.getValueAt(row, 2); vidTextField.setText(vid);/*from w w w . j a v a2 s . c o m*/ modelTextField.setText(model); brandTextField.setText(brand); } //Auto fullfil device information. initDevice(); }); deviceTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent me) { JTable table = (JTable) me.getSource(); Point p = me.getPoint(); int row = table.rowAtPoint(p); if (me.getClickCount() == 2) { String vid = (String) deviceTable.getValueAt(row, 0); String model = (String) deviceTable.getValueAt(row, 1); String brand = (String) deviceTable.getValueAt(row, 2); AndroidDeviceRanking androidDevice = new AndroidDeviceRanking(); androidDevice.setVid(vid); androidDevice.setRoProductModel(model); androidDevice.setRoProductBrand(brand); androidDevice.setCheckDate(new Date()); try { DeviceCache.markDeviceChecked(androidDevice); } catch (JAXBException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } DeviceTableModel tableModel = (DeviceTableModel) deviceTable.getModel(); tableModel.removeRow(row); } } }); }
From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java
public Jmetrik() { super("jMetrik"); setPreferredSize(new Dimension(1024, 650)); setDefaultCloseOperation(EXIT_ON_CLOSE); //properly close database if user closes window this.addWindowListener(new WindowAdapter() { @Override// w ww . j a v a 2s. c o m public void windowClosing(WindowEvent we) { if (workspace != null) { workspace.closeDatabase(); } System.exit(0); } }); //add statusbar statusBar = new StatusBar(1024, 30); statusBar.setBorder(new EmptyBorder(2, 2, 2, 2)); getContentPane().add(statusBar, BorderLayout.SOUTH); //start logging startLog(); //left-right splitpane JSplitPane splitPane1 = new JSplitPane(); splitPane1.setDividerLocation(200); //setup workspace list workspaceList = new JList(); workspaceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); workspaceList.setModel(new SortedListModel<DataTableName>()); workspaceList.addKeyListener(new DeleteKeyListener()); // workspaceList.getInsets().set(5, 5, 5, 5); //add icon to list cell renderer String urlString = "/images/spreadsheet.png"; URL url = this.getClass().getResource(urlString); final ImageIcon tableIcon = new ImageIcon(url, "Table"); workspaceList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); label.setIcon(tableIcon); return label; } }); JScrollPane scrollPane1 = new JScrollPane(workspaceList); scrollPane1.setPreferredSize(new Dimension(200, 698)); splitPane1.setLeftComponent(scrollPane1); //tabbed pane for top pane tabbedPane = new JTabbedPane(); tabbedPane.setTabPlacement(JTabbedPane.BOTTOM); //setup data table dataTable = new DataTable(); dataTable.setRowHeight(18); //change size of table header and center text JTableHeader header = dataTable.getTableHeader(); header.setDefaultRenderer(new TableHeaderCellRenderer()); JScrollPane dataScrollPane = new JScrollPane(dataTable); tabbedPane.addTab("Data", dataScrollPane); //setup variable table variableTable = new DataTable(); variableTable.setRowHeight(18); variableTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if (e.getClickCount() == 2) { JTable target = (JTable) e.getSource(); int row = target.getSelectedRow(); int col = target.getSelectedColumn(); if (col == 0) { if (target.getModel() instanceof VariableModel) { VariableModel vModel = (VariableModel) target.getModel(); String s = (String) vModel.getValueAt(row, col); DatabaseName db = workspace.getDatabaseName(); DataTableName table = workspace.getCurrentDataTable(); RenameVariableDialog renameVariableDialog = new RenameVariableDialog(Jmetrik.this, db, table, s); renameVariableDialog.setVisible(true); if (renameVariableDialog.canRun()) { RenameVariableCommand command = renameVariableDialog.getCommand(); workspace.runProcess(command); } } //end instanceof } //end if col==0 } //end if click count==2 }//end mouse clicked }); //change size of table header and center text JTableHeader variableHeader = variableTable.getTableHeader(); variableHeader.setDefaultRenderer(new TableHeaderCellRenderer()); variableHeader.setPreferredSize(new Dimension(30, 21)); JScrollPane variableScrollPane = new JScrollPane(variableTable); tabbedPane.addTab("Variables", variableScrollPane); splitPane1.setRightComponent(tabbedPane); getContentPane().add(splitPane1, BorderLayout.CENTER); //add status bar listener - needed to display status message that are generated within this class this.addPropertyChangeListener(statusBar.getStatusListener()); //add listener for displaying error messages - needed to display errors and exceptions this.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); //instantiate file utilities fileUtils = new JmetrikFileUtils(); fileUtils.addPropertyChangeListener(statusBar.getStatusListener()); //set import and export path to user's documents folder JFileChooser chooser = new JFileChooser(); FileSystemView fw = chooser.getFileSystemView(); importExportPath = fw.getDefaultDirectory().toString().replaceAll("\\\\", "/"); //create and start a workspace startWorkspace(); //create menu bar and tool bar this.setJMenuBar(createMenuBar()); JToolBar toolBar = createToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); getContentPane().add(toolBar, BorderLayout.PAGE_START); pack(); }
From source file:edu.ucla.stat.SOCR.analyses.gui.NormalPower.java
public void mouseClicked(MouseEvent event) { if (event.getSource() == criticalValueBox) { hypothesisPanel.setVisible(false); sampleSizePanel.setVisible(false); powerPanel.setVisible(false);/*w w w . j a v a 2 s . c o m*/ muAPanel.setVisible(false); sigmaPanel.setVisible(false); mu0Panel.setVisible(false); alphaPanel.setVisible(false); mu0ZTestPanel.setVisible(true); sigmaZTestPanel.setVisible(true); xValuePanel.setVisible(true); useCV = true; useSampleSize = false; usePower = false; } if (event.getSource() == checkSampleSizeBox) { useSampleSize = true; usePower = false; useCV = false; if (useSampleSize) { hypothesisPanel.setVisible(true); sampleSizePanel.setVisible(true); mu0Panel.setVisible(true); muAPanel.setVisible(true); sigmaPanel.setVisible(true); alphaPanel.setVisible(true); powerPanel.setVisible(false); xValuePanel.setVisible(false); sigmaZTestPanel.setVisible(false); mu0ZTestPanel.setVisible(false); this.power = 0; powerText.setText(""); } else if (usePower) { hypothesisPanel.setVisible(true); sampleSizePanel.setVisible(false); powerPanel.setVisible(true); xValuePanel.setVisible(false); sigmaZTestPanel.setVisible(false); mu0ZTestPanel.setVisible(false); mu0Panel.setVisible(true); muAPanel.setVisible(true); sigmaPanel.setVisible(true); alphaPanel.setVisible(true); this.sampleSize = 0; sampleSizeText.setText(""); } } if (event.getSource() == checkPowerBox) { usePower = true; useSampleSize = false; useCV = false; if (useSampleSize) { hypothesisPanel.setVisible(true); sampleSizePanel.setVisible(true); powerPanel.setVisible(false); xValuePanel.setVisible(false); sigmaZTestPanel.setVisible(false); mu0ZTestPanel.setVisible(false); mu0Panel.setVisible(true); muAPanel.setVisible(true); sigmaPanel.setVisible(true); alphaPanel.setVisible(true); this.power = 0; powerText.setText(""); } else if (usePower) { hypothesisPanel.setVisible(true); sampleSizePanel.setVisible(false); powerPanel.setVisible(true); xValuePanel.setVisible(false); sigmaZTestPanel.setVisible(false); mu0ZTestPanel.setVisible(false); mu0Panel.setVisible(true); muAPanel.setVisible(true); sigmaPanel.setVisible(true); alphaPanel.setVisible(true); this.sampleSize = 0; sampleSizeText.setText(""); } } if (event.getSource() == checkNE) { useNE = true; useLT = false; useGT = false; try { hypothesisType = NormalPowerResult.HYPOTHESIS_TYPE_NE; graphSampleMean.resetHypotheseType(); } catch (Exception e) { } } else if (event.getSource() == checkLT) { useNE = false; useLT = true; useGT = false; try { hypothesisType = NormalPowerResult.HYPOTHESIS_TYPE_LT; graphSampleMean.resetHypotheseType(); } catch (Exception e) { } } else if (event.getSource() == checkGT) { useNE = false; useLT = false; useGT = true; try { hypothesisType = NormalPowerResult.HYPOTHESIS_TYPE_GT; graphSampleMean.resetHypotheseType(); } catch (Exception e) { } } else if (event.getSource() == alphaCombo) { try { alpha = Double.parseDouble((String) (alphaCombo.getSelectedItem())); } catch (Exception e) { } } else if (event.getSource() == sampleSizeText) { try { sampleSize = Integer.parseInt((String) (sampleSizeText.getText())); } catch (Exception e) { } } else if (event.getSource() == sigmaText) { try { sigma = Double.parseDouble((String) (sigmaText.getText())); } catch (Exception e) { } } else if (event.getSource() == mu0Text) { try { mu0 = Double.parseDouble((String) (mu0Text.getText())); } catch (Exception e) { } } else if (event.getSource() == muAText) { try { muA = Double.parseDouble((String) (muAText.getText())); } catch (Exception e) { } } else if (event.getSource() == powerText) { try { power = Double.parseDouble((String) (powerText.getText())); } catch (Exception e) { } } else if (event.getSource() == xValueText) { try { xValue = Double.parseDouble((String) (xValueText.getText())); } catch (Exception e) { } } }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java
/** * Brings up the <code>Available Scripts</code> on top of the specified * component at the specified location./*from w ww .jav a2s . c o m*/ * * @param c The component that requested the pop-pup menu. * @param p The point at which to display the menu, relative to the * <code>component</code>'s coordinates. */ void showAvailableScriptsMenu(Component c, Point p) { if (p == null) return; if (c == null) { c = scriptButton; } IconManager icons = IconManager.getInstance(); Collection<ScriptObject> scripts = model.getAvailableScripts(); if (CollectionUtils.isEmpty(scripts)) return; if (scriptsMenu == null) { scriptsMenu = new JPopupMenu(); JMenuItem refresh = new JMenuItem(icons.getIcon(IconManager.REFRESH)); refresh.setText("Reload Scripts"); refresh.setToolTipText("Reloads the existing scripts."); refresh.addMouseListener(new MouseAdapter() { /** * Launches the dialog when the user releases the mouse. * MouseAdapter#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent e) { model.setAvailableScripts(null); scriptsMenu = null; controller.reloadAvailableScripts(e.getPoint()); } }); scriptsMenu.add(refresh); scriptsMenu.add(new JSeparator()); ScriptObject so; Map<String, JMenu> menus = new HashMap<String, JMenu>(); String path; Icon icon = icons.getIcon(IconManager.ANALYSIS); Icon largeIcon = icons.getIcon(IconManager.ANALYSIS_48); ActionListener listener = new ActionListener() { /** * Listens to the selection of a script. * @see ActionListener#actionPerformed(ActionEvent) */ public void actionPerformed(ActionEvent e) { ScriptMenuItem item = (ScriptMenuItem) e.getSource(); controller.handleScriptSelection(item.getScript()); } }; String name = ""; //loop twice to check if we need to add the first element String refString = null; int count = 0; Iterator<ScriptObject> i = scripts.iterator(); String sep; String[] values; String value; while (i.hasNext()) { so = i.next(); value = ""; path = so.getPath(); if (path != null) { sep = FilenameUtils.getPrefix(path); if (path.startsWith(sep)) path = path.substring(1, path.length()); values = UIUtilities.splitString(path); if (values != null && values.length > 0) value = values[0]; } if (refString == null) { refString = value; count++; } else if (refString.equals(value)) count++; } int index = 0; if (scripts.size() == count) index++; i = scripts.iterator(); List<JMenuItem> topMenus = new ArrayList<JMenuItem>(); JMenu ref = null; while (i.hasNext()) { so = i.next(); path = so.getPath(); if (path != null) { sep = FilenameUtils.getPrefix(path); if (path.startsWith(sep)) path = path.substring(1, path.length()); values = UIUtilities.splitString(path); if (values != null) { for (int j = index; j < values.length; j++) { value = values[j]; JMenu v; String text = name + value; if (menus.containsKey(text)) { v = menus.get(text); } else { value = value.replace(ScriptObject.PARAMETER_SEPARATOR, ScriptObject.PARAMETER_UI_SEPARATOR); v = new JMenu(value); } if (ref == null) topMenus.add(v); else ref.add(v); ref = v; name += values[j]; menus.put(name, v); } } } ScriptMenuItem item = new ScriptMenuItem(so); item.addActionListener(listener); if (ref != null) ref.add(item); else topMenus.add(item); name = ""; ref = null; if (so.getIcon() == null) { so.setIcon(icon); so.setIconLarge(largeIcon); } } Iterator<JMenuItem> j = topMenus.iterator(); while (j.hasNext()) { scriptsMenu.add(j.next()); } } scriptsMenu.show(c, p.x, p.y); }
From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java
/** * Setup the JTable with its desired characteristics *///from w w w . jav a 2s.c o m private void setupTable() { table = new CustomTable(spreadsheetModel); table.setShowGrid(true); table.setGridColor(Color.BLACK); table.setShowVerticalLines(true); table.setShowHorizontalLines(true); table.setGridColor(UIHelper.LIGHT_GREEN_COLOR); table.setRowSelectionAllowed(true); table.setColumnSelectionAllowed(true); table.setAutoCreateColumnsFromModel(false); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.getSelectionModel().addListSelectionListener(this); table.getColumnModel().getSelectionModel().addListSelectionListener(this); table.getTableHeader().setReorderingAllowed(true); table.getColumnModel().addColumnModelListener(this); try { table.setDefaultRenderer(Class.forName("java.lang.Object"), new SpreadsheetCellRenderer()); } catch (ClassNotFoundException e) { // ignore this error } table.addMouseListener(this); table.getTableHeader().addMouseMotionListener(new MouseMotionListener() { public void mouseDragged(MouseEvent event) { } public void mouseMoved(MouseEvent event) { // display a tooltip when user hovers over a column. tooltip is derived // from the description of a field from the TableReferenceObject. JTable table = ((JTableHeader) event.getSource()).getTable(); TableColumnModel colModel = table.getColumnModel(); int colIndex = colModel.getColumnIndexAtX(event.getX()); // greater than 1 to account for the row no. being the first col if (colIndex >= 1) { TableColumn tc = colModel.getColumn(colIndex); if (tc != null) { try { table.getTableHeader().setToolTipText(getFieldDescription(tc)); } catch (Exception e) { // ignore this error } } } } }); //table.getColumnModel().addColumnModelListener(this); InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0); // Override the default tab behaviour // Tab to the next editable cell. When no editable cells goto next cell. final Action previousTabAction = table.getActionMap().get(im.get(tab)); Action newTabAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { // maintain previous tab action procedure previousTabAction.actionPerformed(e); JTable table = (JTable) e.getSource(); int row = table.getSelectedRow(); int originalRow = row; int column = table.getSelectedColumn(); int originalColumn = column; while (!table.isCellEditable(row, column)) { previousTabAction.actionPerformed(e); row = table.getSelectedRow(); column = table.getSelectedColumn(); // Back to where we started, get out. if ((row == originalRow) && (column == originalColumn)) { break; } } if (table.editCellAt(row, column)) { table.getEditorComponent().requestFocusInWindow(); } } }; table.getActionMap().put(im.get(tab), newTabAction); TableColumnModel model = table.getColumnModel(); String previousColumnName = null; for (int columnIndex = 0; columnIndex < tableReferenceObject.getHeaders().size(); columnIndex++) { if (!model.getColumn(columnIndex).getHeaderValue().toString() .equals(TableReferenceObject.ROW_NO_TEXT)) { model.getColumn(columnIndex).setHeaderRenderer(columnRenderer); model.getColumn(columnIndex).setPreferredWidth(spreadsheetFunctions .calcColWidths(model.getColumn(columnIndex).getHeaderValue().toString())); // add appropriate cell editor for cell. spreadsheetFunctions.addCellEditor(model.getColumn(columnIndex), previousColumnName); previousColumnName = model.getColumn(columnIndex).getHeaderValue().toString(); } else { model.getColumn(columnIndex).setHeaderRenderer(new RowNumberCellRenderer()); } } JTableHeader header = table.getTableHeader(); header.setBackground(UIHelper.BG_COLOR); header.addMouseListener(new HeaderListener(header, columnRenderer)); table.addNotify(); }
From source file:base.BasePlayer.AddGenome.java
@Override public void mousePressed(MouseEvent e) { if (e.getSource() == tree) { if (selectedNode != null && selectedNode.toString().contains("Add new refe")) { try { FileDialog fs = new FileDialog(frame, "Select reference fasta-file", FileDialog.LOAD); fs.setDirectory(Main.downloadDir); fs.setVisible(true);//from www.j av a 2s .co m String filename = fs.getFile(); fs.setFile("*.fasta;*.fa"); fs.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().contains(".fasta") || name.toLowerCase().contains(".fa"); } }); if (filename != null) { File addfile = new File(fs.getDirectory() + "/" + filename); if (addfile.exists()) { genomeFile = addfile; Main.downloadDir = genomeFile.getParent(); Main.writeToConfig("DownloadDir=" + genomeFile.getParent()); OutputRunner runner = new OutputRunner(genomeFile.getName().replace(".fasta", "") .replace(".fa", "").replace(".gz", ""), genomeFile, null); runner.createGenome = true; runner.execute(); } else { Main.showError("File does not exists.", "Error", frame); } } if (1 == 1) { return; } JFileChooser chooser = new JFileChooser(Main.downloadDir); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); MyFilterFasta fastaFilter = new MyFilterFasta(); chooser.addChoosableFileFilter(fastaFilter); chooser.setDialogTitle("Select reference fasta-file"); if (Main.screenSize != null) { chooser.setPreferredSize(new Dimension((int) Main.screenSize.getWidth() / 3, (int) Main.screenSize.getHeight() / 3)); } int returnVal = chooser.showOpenDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { genomeFile = chooser.getSelectedFile(); Main.downloadDir = genomeFile.getParent(); Main.writeToConfig("DownloadDir=" + genomeFile.getParent()); OutputRunner runner = new OutputRunner( genomeFile.getName().replace(".fasta", "").replace(".gz", ""), genomeFile, null); runner.createGenome = true; runner.execute(); } } catch (Exception ex) { ex.printStackTrace(); } } else if (selectedNode != null && selectedNode.isLeaf() && selectedNode.toString().contains("Add new anno")) { try { FileDialog fs = new FileDialog(frame, "Select annotation gff3/gtf-file", FileDialog.LOAD); fs.setDirectory(Main.downloadDir); fs.setVisible(true); String filename = fs.getFile(); fs.setFile("*.gff3;*.gtf"); fs.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().contains(".gff3") || name.toLowerCase().contains(".gtf"); } }); if (filename != null) { File addfile = new File(fs.getDirectory() + "/" + filename); if (addfile.exists()) { annotationFile = addfile; Main.downloadDir = annotationFile.getParent(); Main.writeToConfig("DownloadDir=" + annotationFile.getParent()); OutputRunner runner = new OutputRunner(selectedNode.getParent().toString(), null, annotationFile); runner.createGenome = true; runner.execute(); } else { Main.showError("File does not exists.", "Error", frame); } } if (1 == 1) { return; } JFileChooser chooser = new JFileChooser(Main.downloadDir); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); MyFilterGFF gffFilter = new MyFilterGFF(); chooser.addChoosableFileFilter(gffFilter); chooser.setDialogTitle("Select annotation gff3-file"); if (Main.screenSize != null) { chooser.setPreferredSize(new Dimension((int) Main.screenSize.getWidth() / 3, (int) Main.screenSize.getHeight() / 3)); } int returnVal = chooser.showOpenDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { annotationFile = chooser.getSelectedFile(); Main.downloadDir = annotationFile.getParent(); Main.writeToConfig("DownloadDir=" + annotationFile.getParent()); OutputRunner runner = new OutputRunner(selectedNode.getParent().toString(), null, annotationFile); runner.createGenome = true; runner.execute(); } } catch (Exception ex) { ex.printStackTrace(); } } } if (e.getSource() == genometable) { if (new File(".").getFreeSpace() / 1048576 < sizeHash.get(genometable.getValueAt(genometable.getSelectedRow(), 0))[0] / 1048576) { sizeError.setVisible(true); download.setEnabled(false); AddGenome.getLinks.setEnabled(false); } else { sizeError.setVisible(false); download.setEnabled(true); AddGenome.getLinks.setEnabled(true); } tree.clearSelection(); remove.setEnabled(false); checkUpdates.setEnabled(false); } }
From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java
private void selectionDataSource(MouseEvent e) { if (e.getClickCount() == 2) { return;//from ww w . j a v a 2s.co m } AddDataSourceAction addDSAction = new AddDataSourceAction(); JPopupMenu popupMenu = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(addDSAction); popupMenu.add(menuItem); popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); }