List of usage examples for java.awt.event MouseEvent getClickCount
public int getClickCount()
From source file:com.diversityarrays.kdxplore.curate.fieldview.FieldLayoutViewPanel.java
@SuppressWarnings("unchecked") public FieldLayoutViewPanel(@SuppressWarnings("rawtypes") MutableComboBoxModel comboBoxModel, JCheckBox alwaysOnTopOption, CurationData cd, CurationTableModel ctm, SelectedValueStore svs, PlotCellChoicesPanel pccp, JPopupMenu popuMenu, Font fontForResizeControls, Action curationHelpAction, MessagePrinter mp, Closure<String> selectionClosure, CurationContext curationContext, CurationMenuProvider curationMenuProvider, FieldLayoutTableModel fieldLayoutTableModel, CellSelectableTable fieldLayoutTable, FieldViewSelectionModel fvsm,/*from w w w. j a v a2s. c o m*/ JButton undockButton) { super(new BorderLayout()); this.traitInstanceCombo.setModel(comboBoxModel); this.curationData = cd; this.messagePrinter = mp; this.selectionClosure = selectionClosure; this.curationTableModel = ctm; this.fieldLayoutTableModel = fieldLayoutTableModel; this.fieldLayoutTable = fieldLayoutTable; this.fieldViewSelectionModel = fvsm; traitInstanceCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object item = comboBoxModel.getSelectedItem(); if (item instanceof TraitInstance) { TraitInstance ti = (TraitInstance) item; plotCellRenderer.setActiveInstance(ti); } } }); rhtm = new RowHeaderTableModel(true, fieldLayoutTable, rowRemovable) { public String getRowLabel(int rowIndex) { int yCoord = FieldLayoutUtil.convertRowIndexToYCoord(rowIndex, trial, fieldLayoutTableModel.getFieldLayout()); return String.valueOf(yCoord); } }; rowHeaderTable = new RowHeaderTable(SwingConstants.CENTER, false, fieldLayoutTable, rowRemovable, rhtm, RowHeaderTable.createDefaultColumnModel("X/Y")) { public String getMarkerIndexName(int viewRow) { return "MIN-" + viewRow; //$NON-NLS-1$ } }; rhtTableRowResizer = new TableRowResizer(rowHeaderTable, true); curationData.addCurationDataChangeListener(plotActivationListener); curationTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { fieldLayoutTable.repaint(); } }); plotCellRenderer = new PlotCellRenderer(plotAttributeProvider, curationTableModel); TraitInstanceCellRenderer tiCellRenderer = new TraitInstanceCellRenderer( curationData.getTraitColorProvider(), instanceNameProvider); traitInstanceCombo.setRenderer(tiCellRenderer); traitInstanceCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateActiveTraitInstance(); } }); traitInstanceCombo.getModel().addListDataListener(new ListDataListener() { @Override public void intervalRemoved(ListDataEvent e) { updateActiveTraitInstance(); } @Override public void intervalAdded(ListDataEvent e) { updateActiveTraitInstance(); } @Override public void contentsChanged(ListDataEvent e) { updateActiveTraitInstance(); } }); this.trial = curationData.getTrial(); this.plotCellChoicesPanel = pccp; for (TraitInstance t : curationData.getTraitInstances()) { String id = InstanceIdentifierUtil.getInstanceIdentifier(t); traitById.put(id, t); } // fieldViewSelectionModel = new FieldViewSelectionModel( // fieldLayoutTable, // fieldLayoutTableModel, // svs); fieldLayoutTable.setSelectionModel(fieldViewSelectionModel); plotCellRenderer.setCurationData(curationData); plotCellRenderer.setSelectionModel(fieldViewSelectionModel); plotCellChoicesPanel.addPlotCellChoicesListener(plotCellChoicesListener); fieldLayoutTableModel.setTrial(trial); // IMPORTANT: DO NOT SORT THE FIELD LAYOUT TABLE fieldLayoutTable.setAutoCreateRowSorter(false); JScrollPane fieldTableScrollPane = new JScrollPane(fieldLayoutTable); if (undockButton != null) { fieldTableScrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, undockButton); } fieldTableScrollPane.setRowHeaderView(rowHeaderTable); ChangeListener scrollBarChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { fireRefreshRequired(); } }; fieldTableScrollPane.getVerticalScrollBar().getModel().addChangeListener(scrollBarChangeListener); fieldTableScrollPane.getHorizontalScrollBar().getModel().addChangeListener(scrollBarChangeListener); fieldLayoutTable.setRowHeaderTable(rowHeaderTable); // fieldLayoutTable.setComponentPopupMenu(popuMenu); initFieldLayoutTable(); Map<Integer, Plot> plotById = new HashMap<>(); FieldLayout<Integer> plotIdLayout = FieldLayoutUtil.createPlotIdLayout(trial.getTrialLayout(), trial.getPlotIdentSummary(), curationData.getPlots(), plotById); KdxploreFieldLayout<Plot> kdxFieldLayout = new KdxploreFieldLayout<Plot>(Plot.class, plotIdLayout.imageId, plotIdLayout.xsize, plotIdLayout.ysize); kdxFieldLayout.warning = plotIdLayout.warning; for (int y = 0; y < plotIdLayout.ysize; ++y) { for (int x = 0; x < plotIdLayout.xsize; ++x) { Integer id = plotIdLayout.cells[y][x]; if (id != null) { Plot plot = plotById.get(id); kdxFieldLayout.store_xy(plot, x, y); } } } fieldLayoutTableModel.setFieldLayout(kdxFieldLayout); if (kdxFieldLayout.warning != null && !kdxFieldLayout.warning.isEmpty()) { warningMessage.setText(kdxFieldLayout.warning); } else { warningMessage.setText(""); //$NON-NLS-1$ } changeVisitOrderAction.putValue(Action.SMALL_ICON, KDClientUtils.getIcon(kdxFieldLayout.imageId)); List<Component> components = new ArrayList<>(); components.add(alwaysOnTopOption); Collections.addAll(components, new JButton(changeVisitOrderAction), new JButton(curationHelpAction), traitInstanceCombo); Box resizeControls = KDClientUtils.createResizeControls(fieldLayoutTable, fontForResizeControls, components.toArray(new Component[components.size()])); resizeCombo = KDClientUtils.findResizeCombo(resizeControls); if (RunMode.getRunMode().isDeveloper()) { new FieldLayoutViewPanel.DebugSettings(resizeControls, messagePrinter); } JPanel fieldPanel = new JPanel(new BorderLayout()); // if (useSeparator) { // SeparatorPanel separator = GuiUtil.createLabelSeparator("Field Layout:", resizeControls); // fieldPanel.add(separator, BorderLayout.NORTH); // fieldPanel.add(fieldTableScrollPane, BorderLayout.CENTER); // } // else { fieldPanel.add(resizeControls, BorderLayout.NORTH); fieldPanel.add(fieldTableScrollPane, BorderLayout.CENTER); // } // splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, // plotCellChoicesPanel, // fieldPanel); // splitPane.setResizeWeight(0.0); // splitPane.setOneTouchExpandable(true); add(warningMessage, BorderLayout.NORTH); add(fieldPanel, BorderLayout.CENTER); // splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, // plotCellChoicesPanel, // fieldPanel); // splitPane.setResizeWeight(0.0); // splitPane.setOneTouchExpandable(true); // // add(warningMessage, BorderLayout.NORTH); // add(splitPane, BorderLayout.CENTER); fieldLayoutTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (SwingUtilities.isRightMouseButton(me) && 1 == me.getClickCount()) { me.consume(); List<Plot> plots = getSelectedPlots(); List<TraitInstance> checkedInstances = new ArrayList<>(); for (int index = traitInstanceCombo.getItemCount(); --index >= 1;) { Object item = traitInstanceCombo.getItemAt(index); if (item instanceof TraitInstance) { checkedInstances.add((TraitInstance) item); } } TraitInstance ti = fieldViewSelectionModel.getActiveTraitInstance(true); List<PlotOrSpecimen> plotSpecimens = new ArrayList<>(); plotSpecimens.addAll(plots); curationMenuProvider.showFieldViewToolMenu(me, plotSpecimens, ti, checkedInstances); } } }); }
From source file:VASSAL.build.module.map.PieceMover.java
protected boolean canHandleEvent(MouseEvent e) { return !e.isShiftDown() && !e.isControlDown() && !e.isMetaDown() && e.getClickCount() < 2 && !e.isConsumed();//from w ww . ja va 2s.co m }
From source file:org.yccheok.jstock.gui.NewBuyTransactionJDialog.java
private MouseListener getJFormattedTextFieldMouseListener() { MouseListener ml = new MouseAdapter() { @Override//from w w w . j a va 2s. com public void mousePressed(final MouseEvent e) { if (e.getClickCount() == 2) { // Ignore double click. return; } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JTextField tf = (JTextField) e.getSource(); int offset = tf.viewToModel(e.getPoint()); tf.setCaretPosition(offset); } }); } }; return ml; }
From source file:fi.todoordelay.gui.GuiMainFrame.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.// www .ja v a 2 s . co m */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { menuBar = new javax.swing.JMenuBar(); projectMenu = new javax.swing.JMenu(); addprojectMenuItem = new javax.swing.JMenuItem(); saveMenuItem = new javax.swing.JMenuItem(); saveAsMenuItem = new javax.swing.JMenuItem(); exitMenuItem = new javax.swing.JMenuItem(); taskMenu = new javax.swing.JMenu(); addtaskMenuItem = new javax.swing.JMenuItem(); copyMenuItem = new javax.swing.JMenuItem(); pasteMenuItem = new javax.swing.JMenuItem(); deleteMenuItem = new javax.swing.JMenuItem(); ownlistMenu = new javax.swing.JMenu(); addownlistMenuItem = new javax.swing.JMenuItem(); aboutMenuItem = new javax.swing.JMenuItem(); projectListModel = new javax.swing.DefaultListModel(); projectsList = new javax.swing.JList(projectListModel); projectsPane = new javax.swing.JScrollPane(projectsList); taskListModel = new javax.swing.DefaultListModel(); tasksList = new javax.swing.JList(taskListModel); tasksPane = new javax.swing.JScrollPane(tasksList); informationTextArea = new javax.swing.JTextArea(); informationPane = new javax.swing.JScrollPane(informationTextArea); addItemDialog = new javax.swing.JOptionPane(); editItemDialog = new javax.swing.JOptionPane(); mainLogic = new fi.todoordelay.logic.LogicMain(); projectsListMouseListener = new MouseListener() { public void mouseClicked(MouseEvent evt) { int index = projectsList.locationToIndex(evt.getPoint()); selectedProject = index; selectionGroup = 0; if (evt.getButton() == 3) { int d = editItemDialog.showConfirmDialog(null, "ARE YOU SURE YOU WANT TO DELETE CHOSEN PROJECT?", "Delete project dialog", editItemDialog.YES_NO_OPTION, editItemDialog.WARNING_MESSAGE); if (d == 0) { mainLogic.removeProject(mainLogic.getProjects().get(selectedProject)); } selectedProject = -1; updateProjectListModel(); } if (evt.getClickCount() == 2 && selectedProject > -1) { List pl = mainLogic.getProjects(); Project p = (Project) pl.get(index); editItemDialog.setWantsInput(true); String name = editItemDialog.showInputDialog(null, "New project name (required):", "Edit project dialog", editItemDialog.INFORMATION_MESSAGE); String description = editItemDialog.showInputDialog(null, "New project description:", "Edit project dialog", editItemDialog.INFORMATION_MESSAGE); String dueString = editItemDialog.showInputDialog(null, "New due date in x day(s):", "Edit project dialog", editItemDialog.INFORMATION_MESSAGE); try { if (name.equals("")) { JOptionPane.showMessageDialog(editItemDialog, "Project name cannot be empty (exiting without changes)"); } else if (Long.parseLong(dueString) < 0) { JOptionPane.showMessageDialog(editItemDialog, "Due date must be zero or higher"); } else { p.setName(name); p.setDescription(description); p.setDuedate(LocalDateTime.now().plusDays(Long.parseLong(dueString))); } } catch (Exception e) { JOptionPane.showMessageDialog(editItemDialog, "Due date must be valid number"); } } updateProjectListModel(); mouseClickedOnProjectActionPerformed(evt); } public void mouseEntered(MouseEvent evt) { } public void mouseExited(MouseEvent evt) { } public void mouseReleased(MouseEvent evt) { } public void mousePressed(MouseEvent evt) { } }; projectsList.addMouseListener(projectsListMouseListener); tasksListMouseListener = new MouseListener() { public void mouseClicked(MouseEvent evt) { int index = tasksList.locationToIndex(evt.getPoint()); selectedTask = index; selectionGroup = 1; if (evt.getButton() == 3) { int d = editItemDialog.showConfirmDialog(null, "ARE YOU SURE YOU WANT TO DELETE CHOSEN TASK?", "Delete task dialog", editItemDialog.YES_NO_OPTION, editItemDialog.WARNING_MESSAGE); if (d == 0) { mainLogic.getProjects().get(selectedProject).removeTask( mainLogic.getProjects().get(selectedProject).getTasks().get(selectedTask)); } updateProjectListModel(); } if (evt.getClickCount() == 2 && selectedTask > -1) { List tl = mainLogic.getProjects().get(selectedProject).getTasks(); Task t = (Task) tl.get(index); editItemDialog.setWantsInput(true); String name = editItemDialog.showInputDialog(null, "New task name (required):", "Edit task dialog", editItemDialog.INFORMATION_MESSAGE); String description = editItemDialog.showInputDialog(null, "New task description:", "Edit task dialog", editItemDialog.INFORMATION_MESSAGE); String dueString = editItemDialog.showInputDialog(null, "New due date in x day(s):", "Edit task dialog", editItemDialog.INFORMATION_MESSAGE); try { if (name.equals("")) { JOptionPane.showMessageDialog(editItemDialog, "Task name cannot be empty (exiting without changes)"); } else if (Long.parseLong(dueString) < 0) { JOptionPane.showMessageDialog(editItemDialog, "Due date must be zero or higher"); } else { t.setName(name); t.setDescription(description); t.setDuedate(LocalDateTime.now().plusDays(Long.parseLong(dueString))); } } catch (Exception e) { JOptionPane.showMessageDialog(editItemDialog, "Due date must be valid number"); } } updateProjectListModel(); mouseClickedOnProjectActionPerformed(evt); } public void mouseEntered(MouseEvent evt) { } public void mouseExited(MouseEvent evt) { } public void mouseReleased(MouseEvent evt) { } public void mousePressed(MouseEvent evt) { } }; tasksList.addMouseListener(tasksListMouseListener); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); projectsPane.setBorder(javax.swing.BorderFactory.createTitledBorder("Projects")); projectsPane.setViewportBorder(null); tasksPane.setBorder(javax.swing.BorderFactory.createTitledBorder("Tasks")); tasksPane.setViewportBorder(null); informationPane.setBorder(javax.swing.BorderFactory.createTitledBorder("Description")); projectsPane.setViewportBorder(null); projectMenu.setText("Project"); addprojectMenuItem.setMnemonic('p'); addprojectMenuItem.setText("Add Project"); projectMenu.add(addprojectMenuItem); addprojectMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addItemDialog.setWantsInput(true); String name = addItemDialog.showInputDialog(null, "Project name (required):", "Add project dialog", addItemDialog.INFORMATION_MESSAGE); String description = addItemDialog.showInputDialog(null, "Project description:", "Add project dialog", addItemDialog.INFORMATION_MESSAGE); String due_at = addItemDialog.showInputDialog(null, "Due in x day(s):", "Add project dialog", addItemDialog.INFORMATION_MESSAGE); Project newProject = new Project(name, description, Long.parseLong(due_at)); mainLogic.addProject(newProject); projectListModel.addElement(name); updateProjectListModel(); addprojectMenuItemActionPerformed(evt); } }); menuBar.add(projectMenu); taskMenu.setText("Task"); addtaskMenuItem.setMnemonic('t'); addtaskMenuItem.setText("Add Task"); taskMenu.add(addtaskMenuItem); addtaskMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addItemDialog.setWantsInput(true); String name = addItemDialog.showInputDialog(null, "Task name (required):", "Add task dialog", addItemDialog.INFORMATION_MESSAGE); String description = addItemDialog.showInputDialog(null, "Task description:", "Add task dialog", addItemDialog.INFORMATION_MESSAGE); String due_at = addItemDialog.showInputDialog(null, "Due in x day(s):", "Add task dialog", addItemDialog.INFORMATION_MESSAGE); Task newTask = new Task(name, description, Long.parseLong(due_at)); Project s = mainLogic.getProjects().get(selectedProject); s.addTask(newTask); taskListModel.addElement(name); updateProjectListModel(); addprojectMenuItemActionPerformed(evt); } }); menuBar.add(taskMenu); setJMenuBar(menuBar); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap().addComponent( projectsPane, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( layout.createSequentialGroup().addGap(312, 312, 312).addComponent(tasksPane, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup().addGap(624, 624, 624).addComponent( informationPane, javax.swing.GroupLayout.PREFERRED_SIZE, 300, Short.MAX_VALUE))) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(informationPane, javax.swing.GroupLayout.DEFAULT_SIZE, 860, Short.MAX_VALUE) .addComponent(tasksPane, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(projectsPane, javax.swing.GroupLayout.Alignment.LEADING)) .addContainerGap())); pack(); }
From source file:com.unicauca.braim.braimclient.BraimGui.java
private void add_mouse_listener_to_list() { MouseListener mouseListener = new MouseAdapter() { @Override/*ww w. j av a 2 s . co m*/ public void mouseClicked(MouseEvent mouseEvent) { JList theList = (JList) mouseEvent.getSource(); if (mouseEvent.getClickCount() == 2) { int index = theList.locationToIndex(mouseEvent.getPoint()); if (index >= 0) { actualSong = actualSongList[index]; lbl_song_name.setText(actualSong.getName()); play_song(actualSong); } } } }; list_songs.addMouseListener(mouseListener); }
From source file:savant.view.swing.GraphPane.java
/** * {@inheritDoc}/* w ww .j av a 2 s . c o m*/ */ @Override public void mouseClicked(MouseEvent event) { if (event.getClickCount() == 2) { LocationController.getInstance().zoomInOnMouse(); return; } trySelect(event.getPoint()); setMouseModifier(event); }
From source file:edu.ku.brc.specify.ui.treetables.TreeDefinitionEditor.java
/** * @param treeDef/* w w w .j a v a 2 s .co m*/ */ protected void initTreeDefEditorComponent(final D treeDef) { Set<I> defItems = treeDef.getTreeDefItems(); tableModel = new TreeDefEditorTableModel<T, D, I>(defItems); defItemsTable = new JTable(tableModel); defItemsTable.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false)); defItemsTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { SwingUtilities.invokeLater(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { editTreeDefItem(defItemsTable.getSelectedRow()); } }); } } }); defItemsTable.setRowHeight(24); // Center the boolean Columns BiColorTableCellRenderer centeredRenderer = new BiColorTableCellRenderer(); TableColumn tc = defItemsTable.getColumnModel().getColumn(2); tc.setCellRenderer(centeredRenderer); tc = defItemsTable.getColumnModel().getColumn(3); tc.setCellRenderer(centeredRenderer); if (isEditMode) { defItemsTable.setRowSelectionAllowed(true); defItemsTable.setColumnSelectionAllowed(false); defItemsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else { defItemsTable.setRowSelectionAllowed(false); } UIHelper.makeTableHeadersCentered(defItemsTable, false); defNameLabel.setText(treeDef.getName()); Font f = defNameLabel.getFont(); Font boldF = f.deriveFont(Font.BOLD); defNameLabel.setFont(boldF); // put everything in the main panel this.add(UIHelper.createScrollPane(defItemsTable), BorderLayout.CENTER); this.add(titlePanel, BorderLayout.NORTH); // Only add selection listener if the botton panel is there for editing if (edaPanel != null) { PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,p,10px", "p")); //$NON-NLS-1$ //$NON-NLS-2$ pb.add(edaPanel, new CellConstraints().xy(2, 1)); add(pb.getPanel(), BorderLayout.SOUTH); addSelectionListener(); } repaint(); }
From source file:org.revager.gui.findings_list.FindingsListFrame.java
private void createAttPanel() { GridLayout grid = new GridLayout(4, 1); grid.setVgap(8);/*from w ww. j av a 2 s . c o m*/ JPanel attendeeButtons = new JPanel(grid); addResiAtt = GUITools.newImageButton(); addResiAtt.setIcon(Data.getInstance().getIcon("addResiAtt_25x25_0.png")); addResiAtt.setRolloverIcon(Data.getInstance().getIcon("addResiAtt_25x25.png")); addResiAtt.setToolTipText(translate("Add Attendee from the Attendee Pool")); addResiAtt.addActionListener(ActionRegistry.getInstance().get(AddResiAttToProtAction.class.getName())); attendeeButtons.add(addResiAtt); JButton addAttendee = GUITools.newImageButton(); addAttendee.setIcon(Data.getInstance().getIcon("addAttendee_25x25_0.png")); addAttendee.setRolloverIcon(Data.getInstance().getIcon("addAttendee_25x25.png")); addAttendee.setToolTipText(translate("Add Attendee")); addAttendee.addActionListener(ActionRegistry.getInstance().get(AddAttToProtAction.class.getName())); attendeeButtons.add(addAttendee); removeAttendee = GUITools.newImageButton(); removeAttendee.setIcon(Data.getInstance().getIcon("removeAttendee_25x25_0.png")); removeAttendee.setRolloverIcon(Data.getInstance().getIcon("removeAttendee_25x25.png")); removeAttendee.setToolTipText(translate("Remove Attendee")); removeAttendee.addActionListener(ActionRegistry.getInstance().get(RemAttFromProtAction.class.getName())); attendeeButtons.add(removeAttendee); editAttendee = GUITools.newImageButton(); editAttendee.setIcon(Data.getInstance().getIcon("editAttendee_25x25_0.png")); editAttendee.setRolloverIcon(Data.getInstance().getIcon("editAttendee_25x25.png")); editAttendee.setToolTipText(translate("Edit Attendee")); editAttendee.addActionListener(ActionRegistry.getInstance().get(EditAttFromProtAction.class.getName())); attendeeButtons.add(editAttendee); editAttendee.setEnabled(false); removeAttendee.setEnabled(false); presentAttTable.setRowHeight(55); presentAttTable.getColumnModel().getColumn(0).setMaxWidth(55); presentAttTable.setShowHorizontalLines(false); presentAttTable.setShowVerticalLines(true); presentAttTable.setShowGrid(true); presentAttTable.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { ActionRegistry.getInstance().get(EditAttFromProtAction.class.getName()).actionPerformed(null); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }); TableCellRenderer renderer = (table, value, isSelected, hasFocus, row, column) -> { JLabel label = new JLabel((String) value); label.setOpaque(true); label.setBorder(new EmptyBorder(5, 5, 5, 5)); label.setFont(UI.VERY_LARGE_FONT); if (isSelected) { label.setBackground(presentAttTable.getSelectionBackground()); } else { if (row % 2 == 0) { label.setBackground(UI.TABLE_ALT_COLOR); } else { label.setBackground(presentAttTable.getBackground()); } } return label; }; for (int i = 1; i <= 4; i++) { presentAttTable.getColumnModel().getColumn(i).setCellRenderer(renderer); } TableColumn col = presentAttTable.getColumnModel().getColumn(0); col.setCellRenderer((table, value, isSelected, hasFocus, row, column) -> { JPanel localPnl = new JPanel(); localPnl.add(new JLabel(Data.getInstance().getIcon("attendee_40x40.png"))); if (isSelected) { localPnl.setBackground(presentAttTable.getSelectionBackground()); } else { if (row % 2 == 0) { localPnl.setBackground(UI.TABLE_ALT_COLOR); } else { localPnl.setBackground(presentAttTable.getBackground()); } } return localPnl; }); presentAttTable.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { updateAttButtons(); } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }); scrllP = GUITools.setIntoScrollPane(presentAttTable); scrllP.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); scrllP.setToolTipText(translate("Add Attendee to Meeting")); scrllP.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (isAddResiAttPossible()) { ActionRegistry.getInstance().get(AddResiAttToProtAction.class.getName()).actionPerformed(null); } else { ActionRegistry.getInstance().get(AddAttToProtAction.class.getName()).actionPerformed(null); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }); JLabel labelAttendees = new JLabel(translate("Attendees of the current meeting:")); labelAttendees.setFont(UI.HUGE_FONT_BOLD); GUITools.addComponent(attPanel, gbl, labelAttendees, 0, 0, 2, 1, 1.0, 0.0, 20, 20, 0, 20, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); GUITools.addComponent(attPanel, gbl, scrllP, 0, 1, 1, 1, 1.0, 1.0, 20, 20, 0, 20, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); GUITools.addComponent(attPanel, gbl, attendeeButtons, 1, 1, 1, 1, 0, 0, 20, 0, 20, 20, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); }
From source file:ca.sqlpower.swingui.enterprise.client.ServerProjectsManagerPanel.java
/** * Creates a dialog that lets the user choose a server connection and then a * project.//from w w w . j a v a 2 s. c o m * * @param serverManager * This object contains all of the server information objects * known and the servers based on their information will be * displayed in a list so a user can navigate to different * projects in different servers. * @param dialogOwner * The dialog to parent new dialogs to. * @param upf * A user prompter factory for displaying error and warning * messages to users. * @param closeAction * An action that will close the dialog or frame that this dialog * is contained in. * @param defaultFileDirectory * A default file directory to start looking for files in if the * user wants to upload a project. If null this will default to * the user's home directory. * @param cookieStore * A cookie store for HTTP requests. Used by the * {@link ClientSideSessionUtils}. */ public ServerProjectsManagerPanel(SPServerInfoManager serverManager, Component dialogOwner, UserPrompterFactory upf, Action closeAction, File defaultFileDirectory, CookieStore cookieStore) { this.dialogOwner = dialogOwner; this.upf = upf; this.closeAction = closeAction; this.defaultFileDirectory = defaultFileDirectory; this.cookieStore = cookieStore; cookieStore.clear(); DefaultFormBuilder builder = new DefaultFormBuilder( new FormLayout("pref:grow, 5dlu, pref:grow, 5dlu, pref", "pref, pref, pref")); servers = new JList(new DefaultListModel()); servers.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e)) { refreshInfoList(); } } }); DefaultListModel serversModel = (DefaultListModel) servers.getModel(); serversModel.removeAllElements(); if (serverManager.getServers(false).size() > 0) { for (SPServerInfo serverInfo : serverManager.getServers(false)) { serversModel.addElement(serverInfo); } } else { serversModel.addElement("No Servers"); servers.setEnabled(false); } projects = new JList(new DefaultListModel()); projects.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { refreshPanel(); if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) { getOpenAction().actionPerformed(null); } } }); JScrollPane projectsPane = new JScrollPane(projects); projectsPane.setPreferredSize(new Dimension(250, 300)); JScrollPane serverPane = new JScrollPane(servers); serverPane.setPreferredSize(new Dimension(250, 300)); CellConstraints cc = new CellConstraints(); builder.add(new JLabel("Servers:"), cc.xyw(1, 1, 2)); builder.add(new JLabel("Projects:"), cc.xyw(3, 1, 2)); builder.nextLine(); builder.add(serverPane, cc.xywh(1, 2, 1, 2)); builder.add(projectsPane, cc.xywh(3, 2, 1, 2)); DefaultFormBuilder buttonBarBuilder = new DefaultFormBuilder(new FormLayout("pref")); buttonBarBuilder.append(new JButton(refreshAction)); buttonBarBuilder.append(securityButton); buttonBarBuilder.append(new JButton(newAction)); buttonBarBuilder.append(openButton); buttonBarBuilder.append(new JButton(uploadAction)); buttonBarBuilder.append(new JButton(deleteAction)); buttonBarBuilder.append(new JButton(closeAction)); builder.add(buttonBarBuilder.getPanel(), cc.xy(5, 2)); builder.setDefaultDialogBorder(); panel = builder.getPanel(); }
From source file:com.vgi.mafscaling.LogView.java
private void createLogViewPanel() { logViewPanel = new JPanel(); GridBagLayout gbl_logViewPanel = new GridBagLayout(); gbl_logViewPanel.columnWidths = new int[] { 0 }; gbl_logViewPanel.rowHeights = new int[] { 0, 0 }; gbl_logViewPanel.columnWeights = new double[] { 1.0 }; gbl_logViewPanel.rowWeights = new double[] { 1.0, 0.0 }; logViewPanel.setLayout(gbl_logViewPanel); try {//from ww w . ja va2 s. co m logDataTable = new DBTable(); logDataTable.copyColumnHeaderNames = true; logDataTable.defaultClickCountToStartEditor = 2; logDataTable.doNotUseDatabaseSort = true; logDataTable.listenKeyPressEventsWholeWindow = true; logDataTable.createControlPanel(DBTable.READ_NAVIGATION); logDataTable.enableExcelCopyPaste(); logDataTable.setSortEnabled(false); logDataTable.setSkin(new TableSkin()); logDataTable.refresh(new String[1][25]); logDataTable.setComparator(new DoubleComparator()); logDataTable.getTable().setCellSelectionEnabled(true); logDataTable.getTable().setColumnSelectionAllowed(true); logDataTable.getTable().setRowSelectionAllowed(true); logDataTable.getTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JTextField rowTextField = ((JTextField) logDataTable.getControlPanel().getComponent(3)); rowTextField.setPreferredSize(null); rowTextField.setColumns(5); GridBagConstraints gbc_logDataTable = new GridBagConstraints(); gbc_logDataTable.insets = insets0; gbc_logDataTable.anchor = GridBagConstraints.PAGE_START; gbc_logDataTable.fill = GridBagConstraints.BOTH; gbc_logDataTable.gridx = 0; gbc_logDataTable.gridy = 0; logViewPanel.add(logDataTable, gbc_logDataTable); listModel = new DefaultListModel<JLabel>(); selectionCombo.removeAllItems(); String name; JTableHeader tableHeader = logDataTable.getTableHeader(); for (int i = 0; i < logDataTable.getColumnCount(); ++i) { Column col = logDataTable.getColumn(i); col.setNullable(true); col.setHeaderRenderer(new CheckboxHeaderRenderer(i + 1, tableHeader)); name = col.getHeaderValue().toString(); selectionCombo.addItem(name); listModel.addElement(new JLabel(name, new CheckBoxIcon(), JLabel.LEFT)); } JList<JLabel> menuList = new JList<JLabel>(listModel); menuList.setOpaque(false); menuList.setCellRenderer(new ImageListCellRenderer()); menuList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); menuList.setLayoutOrientation(JList.VERTICAL); menuList.setFixedCellHeight(25); menuList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { try { if (e.getClickCount() == 1 && colors.size() > 0) { JList<?> list = (JList<?>) e.getSource(); int index = list.locationToIndex(e.getPoint()); if (index >= 0) { int colIdx = logDataTable.getCurrentIndexForOriginalColumn(index); Column col = logDataTable.getColumn(colIdx); if (col.getHeaderRenderer() instanceof CheckboxHeaderRenderer) { CheckboxHeaderRenderer renderer = (CheckboxHeaderRenderer) col .getHeaderRenderer(); JLabel label = (JLabel) list.getModel().getElementAt(index); CheckBoxIcon checkIcon = (CheckBoxIcon) label.getIcon(); checkIcon.setChecked(!checkIcon.isChecked()); if (checkIcon.isChecked()) { checkIcon.setColor(colors.pop()); JTable table = logDataTable.getTable(); TableModel model = table.getModel(); addXYSeries(model, index, col.getHeaderValue().toString(), checkIcon.getColor()); } else { colors.push(checkIcon.getColor()); checkIcon.setColor(renderer.getDefaultColor()); removeXYSeries(index); } list.repaint(); } } } } catch (Exception ex) { ex.printStackTrace(); } } }); headerScrollPane = new JScrollPane(menuList); GridBagConstraints gbc_headersTree = new GridBagConstraints(); gbc_headersTree.insets = insets0; gbc_headersTree.anchor = GridBagConstraints.PAGE_START; gbc_headersTree.fill = GridBagConstraints.BOTH; gbc_headersTree.gridx = 0; gbc_headersTree.gridy = 1; logViewPanel.add(headerScrollPane, gbc_headersTree); headerScrollPane.setVisible(false); } catch (Exception e) { e.printStackTrace(); logger.error(e); } }