Java Code Examples for java.awt.event.MouseAdapter

The following are top voted examples for showing how to use java.awt.event.MouseAdapter. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: routerapp   File: NavigationView.java   Source Code and License 7 votes vote down vote up
/**
 * 
 */
private void buildTree() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("user");
    tree = new JTree(root);
    tree.putClientProperty("JTree.lineStyle", "Angled");
    tree.setCellRenderer(new NavigationTreeCellRenderer());
    tree.setShowsRootHandles(true);
    
    DefaultTreeSelectionModel model = new DefaultTreeSelectionModel();
    model.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    
    graphsCategory = new DefaultMutableTreeNode("graphs");
    
    mouseAdapter = new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            itemSelected(e);
        }
    };
    tree.addMouseListener(mouseAdapter);
    
    root.add(graphsCategory);        
    loadGraphs();
}
 
Example 2
Project: owa-notifier   File: WindowNotification.java   Source Code and License 7 votes vote down vote up
public WindowNotification() {
	m_window = new JWindow();
	m_window.setAlwaysOnTop(true);

	m_listener = new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			fireListeners(CLICKED);
			if (m_closeOnClick)
				removeFromManager();
		}
	};

	setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
	setPanel(new JPanel());
}
 
Example 3
Project: openjdk-jdk10   File: JInternalFrameMoveOverlapping.java   Source Code and License 6 votes vote down vote up
@Override
protected void prepareControls() {


    JDesktopPane desktopPane = new JDesktopPane();

    JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);
    bottomFrame.setSize(220, 220);
    super.propagateAWTControls(bottomFrame);
    desktopPane.add(bottomFrame);
    bottomFrame.setVisible(true);

    JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);
    topFrame.setSize(200, 200);
    topFrame.add(new JButton("LW Button") {

        {
            addMouseListener(new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    lwClicked = true;
                }
            });
        }
    });
    desktopPane.add(topFrame);
    topFrame.setVisible(true);

    JFrame frame = new JFrame("Test Window");
    frame.setSize(300, 300);
    frame.setContentPane(desktopPane);
    frame.setVisible(true);

    locTopFrame = topFrame.getLocationOnScreen();
    locTarget = new Point(locTopFrame.x + bottomFrame.getWidth() / 2, locTopFrame.y + bottomFrame.getHeight()/2);
}
 
Example 4
Project: enigma-vk   File: ClassSelector.java   Source Code and License 6 votes vote down vote up
public ClassSelector(Comparator<ClassEntry> comparator) {
	m_comparator = comparator;
	
	// configure the tree control
	setRootVisible(false);
	setShowsRootHandles(false);
	setModel(null);
	
	// hook events
	addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent event) {
			if (m_listener != null && event.getClickCount() == 2) {
				// get the selected node
				TreePath path = getSelectionPath();
				if (path != null && path.getLastPathComponent() instanceof ClassSelectorClassNode) {
					ClassSelectorClassNode node = (ClassSelectorClassNode)path.getLastPathComponent();
					m_listener.onSelectClass(node.getClassEntry());
				}
			}
		}
	});
	
	// init defaults
	m_listener = null;
}
 
Example 5
Project: Neukoelln_SER316   File: TableSorter.java   Source Code and License 6 votes vote down vote up
public void addMouseListenerToHeaderInTable(JTable table) { 
    final TableSorter sorter = this; 
    final JTable tableView = table; 
    tableView.setColumnSelectionAllowed(false); 
    MouseAdapter listMouseListener = new MouseAdapter() {
        boolean ascending = false;
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = tableView.convertColumnIndexToModel(viewColumn); 
            if (e.getClickCount() == 1 && column != -1) {
                //System.out.println("Sorting ..."); 
                //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; 
                //boolean ascending = (shiftPressed == 0);
                if (column == sortBy)                    
                    ascending = !ascending;
                else
                    ascending = true; 
                sorter.sortByColumn(column, ascending);   
                tableView.getTableHeader().updateUI();                  
            }
        }
    };
    JTableHeader th = tableView.getTableHeader(); 
    th.addMouseListener(listMouseListener); 
}
 
Example 6
Project: QN-ACTR-Release   File: WhatIfPlot.java   Source Code and License 6 votes vote down vote up
public WhatIfPlot(double[] xAxis) {
	super();
	this.xAxis = xAxis;
	// Adds popup menu
	this.addMouseListener(new MouseAdapter() {
		/**
		 * Invoked when the mouse has been clicked on a component.
		 */
		@Override
		public void mouseClicked(MouseEvent e) {
			if (e.getButton() == MouseEvent.BUTTON3) {
				popup.show(WhatIfPlot.this, e.getX(), e.getY());
			}
		}
	});
}
 
Example 7
Project: Equella   File: AbstractChoiceDialog.java   Source Code and License 6 votes vote down vote up
public void addChoice(final String key, String displayText)
{
	final JRadioButton rb = new JRadioButton(displayText);
	if( doubleClickToSelect )
	{
		rb.addMouseListener(new MouseAdapter()
		{
			@Override
			public void mouseClicked(MouseEvent e)
			{
				if( e.getClickCount() >= 2 )
				{
					addClicked(key);
				}
			}
		});
	}

	choices.addButton(rb, key);

	// Add after the instructions label and any existing choices
	add(rb, choices.size());
}
 
Example 8
Project: Cognizant-Intelligent-Test-Scripter   File: AppMainFrame.java   Source Code and License 6 votes vote down vote up
private Box.Filler simpleFiller() {
    Box.Filler filler = new Box.Filler(
            new java.awt.Dimension(10, 0),
            new java.awt.Dimension(10, 0),
            new java.awt.Dimension(10, 32767));

    filler.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent me) {
            setGlassPane(docker);
            SwingUtilities.invokeLater(() -> {
                getGlassPane().setVisible(true);
            });
        }

    });
    return filler;
}
 
Example 9
Project: litiengine   File: JCheckBoxList.java   Source Code and License 6 votes vote down vote up
public JCheckBoxList() {
  setCellRenderer(new CellRenderer());
  addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent e) {
      int index = locationToIndex(e.getPoint());
      if (index != -1) {
        JCheckBox checkbox = getModel().getElementAt(index);

        if (e.getPoint().x < checkbox.getHorizontalTextPosition()) {

          checkbox.setSelected(!checkbox.isSelected());
        }
        repaint();
      }
    }
  });
  setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
 
Example 10
Project: jdk8u-jdk   File: MissingEventsOnModalDialogTest.java   Source Code and License 6 votes vote down vote up
private static void showModalDialog(Frame targetFrame) {

        Dialog dialog = new Dialog(targetFrame, true);

        dialog.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                passed = true;
                dialog.dispose();
            }
        });

        dialog.setSize(400, 300);
        dialog.setTitle("Modal Dialog!");

        clickOnModalDialog(dialog);
        dialog.setVisible(true);
    }
 
Example 11
Project: SpotSpotter   File: CameraShot.java   Source Code and License 6 votes vote down vote up
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	frame = new JFrame();
	frame.setBounds(100, 100, 800, 450);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().setLayout(null);

	final JButton btnNewButton = new JButton("\u62CD\u7167");
	btnNewButton.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent arg0) {
			flag = 1;// ��̬��������Ϊ1���Ӷ����°�ťʱ��ֹͣ����ͷ�ĵ���
		}
	});
	btnNewButton.setBounds(33, 13, 113, 27);
	frame.getContentPane().add(btnNewButton);

	label = new JLabel("");
	label.setBounds(0, 0, 800, 450);
	frame.getContentPane().add(label);
}
 
Example 12
Project: VISNode   File: ProcessBrowser.java   Source Code and License 6 votes vote down vote up
/**
 * Creates the process list
 *
 * @return JComponent
 */
private JComponent buildList() {
    list = new JList<>();
    list.setCellRenderer(new CellRenderer(list.getCellRenderer()));
    list.setTransferHandler(new ProcessTransferHandler());
    list.setDragEnabled(true);
    list.setDropMode(DropMode.ON_OR_INSERT);
    list.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.getClickCount() % 2 == 0) {
                ProcessInformationPane.showDialog(list.getSelectedValue());
            }
        }
    });
    return ScrollFactory.pane(list).create();
}
 
Example 13
Project: Equella   File: BusyGlassPane.java   Source Code and License 6 votes vote down vote up
/**
 * GlassPane constructor comment.
 * 
 * @param Container a
 */
protected BusyGlassPane(Component activeComponent, boolean stopClosing)
{
	this.stopClosing = stopClosing;

	// add adapters that do nothing for keyboard and mouse actions
	addMouseListener(new MouseAdapter()
	{
		// We don't care about any events
	});

	addKeyListener(new KeyAdapter()
	{
		// We don't care about any events
	});

	setActiveComponent(activeComponent);
}
 
Example 14
Project: openjdk-jdk10   File: AltGraphModifierTest.java   Source Code and License 6 votes vote down vote up
public static void initTestWindow() {
    mainFrame = new Frame();
    mainFrame.setTitle("TestWindow");
    mainFrame.setBounds(700, 10, 300, 300);
    mainFrame.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            int ex = e.getModifiersEx();
            if ((ex & InputEvent.ALT_GRAPH_DOWN_MASK) == 0) {
                AltGraphModifierTest.fail("Alt-Gr Modifier bit is not set.");
            } else {
                AltGraphModifierTest.pass();
            }
        }
    });
    mainFrame.setVisible(true);
}
 
Example 15
Project: openvisualtraceroute   File: HyperlinkLabel.java   Source Code and License 6 votes vote down vote up
/**
 * Constructor
 */
public HyperlinkLabel() {
	super();
	setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

	setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
	addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(final MouseEvent evt) {
			if (_url != null) {
				Util.browse(_url, getText());
			}
		}
	});
	setForeground(Color.BLUE);
}
 
Example 16
Project: incubator-netbeans   File: CategoryDescriptor.java   Source Code and License 6 votes vote down vote up
private MouseListener createMouseListener() {
    return new MouseAdapter() {
        public void mouseClicked(MouseEvent event) {
            if (SwingUtilities.isRightMouseButton(event)) {
                JComponent comp = (JComponent)event.getSource();
                Item item = null;
                if (comp instanceof JList) {
                    JList list = (JList)comp;
                    Point p = event.getPoint();
                    int index = list.locationToIndex(p);
                    if (index >= 0 && !list.getCellBounds(index, index).contains(p)) {
                        index = -1;
                    }
                    if (index >= 0) {
                        item = (Item)list.getModel().getElementAt(index);
                    }
                }
                Action[] actions = null == item ? category.getActions() : item.getActions();
                JPopupMenu popup = Utilities.actionsToPopup( actions, getComponent() );
                Utils.addCustomizationMenuItems( popup, getPalettePanel().getController(), getPalettePanel().getSettings() );
                popup.show(comp, event.getX(), event.getY());
            }
        }
    };
}
 
Example 17
Project: incubator-netbeans   File: TaskListTable.java   Source Code and License 6 votes vote down vote up
public MyTableHeader( TableColumnModel model ) {
    super( model );
    addMouseListener( new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if( e.getClickCount() != 1 )
                return;
            int column = columnAtPoint( e.getPoint() );
            if( column > 0 && getModel() instanceof TaskListModel ) {
                ((TaskListModel)getModel()).toggleSort( column );
                repaint();
            }
        }
    });
    this.setReorderingAllowed( false );
}
 
Example 18
Project: WePush   File: TabListener.java   Source Code and License 6 votes vote down vote up
public static void addListeners() {
    // 暂时停止使用,仅留作demo,日后需要时再使用
    MainWindow.mainWindow.getTabbedPane().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            int index = MainWindow.mainWindow.getTabbedPane().getSelectedIndex();
            switch (index) {
                case 6:
                    break;
                default:
                    break;
            }
        }
    });
}
 
Example 19
Project: incubator-netbeans   File: QueryPanel.java   Source Code and License 6 votes vote down vote up
public ExpandablePanel(JLabel l, JPanel p, final Icon ei, final Icon ci) {
    this.panel = p;
    this.label = l;
    this.ci = ci;
    this.ei = ei;
    this.label.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if(panel.isVisible()) {
                colapse();
            } else {
                expand();
            }
        }
    });
}
 
Example 20
Project: Tarski   File: mxGraphComponent.java   Source Code and License 6 votes vote down vote up
/**
 * Adds handling of edit and stop-edit events after all other handlers have been installed.
 */
protected void installDoubleClickHandler() {
  graphControl.addMouseListener(new MouseAdapter() {
    public void mouseReleased(MouseEvent e) {
      if (isEnabled()) {
        if (!e.isConsumed() && isEditEvent(e)) {
          Object cell = getCellAt(e.getX(), e.getY(), false);

          if (cell != null && getGraph().isCellEditable(cell)) {
            startEditingAtCell(cell, e);
          }
        } else {
          // Other languages use focus traversal here, in Java
          // we explicitely stop editing after a click elsewhere
          stopEditing(!invokesStopCellEditing);
        }
      }
    }

  });
}
 
Example 21
Project: Reinickendorf_SER316   File: TableSorter.java   Source Code and License 6 votes vote down vote up
public void addMouseListenerToHeaderInTable(JTable table) { 
    final TableSorter sorter = this; 
    final JTable tableView = table; 
    tableView.setColumnSelectionAllowed(false); 
    MouseAdapter listMouseListener = new MouseAdapter() {
        boolean ascending = false;
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = tableView.convertColumnIndexToModel(viewColumn); 
            if (e.getClickCount() == 1 && column != -1) {
                //System.out.println("Sorting ..."); 
                //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; 
                //boolean ascending = (shiftPressed == 0);
                if (column == sortBy)                    
                    ascending = !ascending;
                else
                    ascending = true; 
                sorter.sortByColumn(column, ascending);   
                tableView.getTableHeader().updateUI();                  
            }
        }
    };
    JTableHeader th = tableView.getTableHeader(); 
    th.addMouseListener(listMouseListener); 
}
 
Example 22
Project: JavaGraph   File: GraphEditorTab.java   Source Code and License 6 votes vote down vote up
/** Post-processes an already constructed toolbar.
 */
private void processToolBar(JToolBar toolBar) {
    for (int i = 0; i < toolBar.getComponentCount(); i++) {
        Component element = toolBar.getComponent(i);
        if (element instanceof JButton) {
            JButton button = (JButton) element;
            Action action = button.getAction();
            if (action != null) {
                getJGraph().addAccelerator(action);
            }
        }
    }
    // ensure the JGraph gets focus as soon as the graph panel
    // is clicked anywhere
    // for reasons not clear to me, mouse listeners do not work on
    // the level of the JGraphPanel
    toolBar.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            getJGraph().requestFocus();
        }
    });
}
 
Example 23
Project: jmt   File: ClassesPanel.java   Source Code and License 6 votes vote down vote up
private void enableDeletes() {
	//deleteOneClass.setEnabled(classes>1);
	//todo zanzottera inserito controllo inizialmente non si possono cancellare le 2 classi
	deleteOneClass.setEnabled(classes > MINCLASSES);
	/*It seems the only way to implement row deletion...*/
	this.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			if (classes > MINCLASSES && (columnAtPoint(e.getPoint()) == getColumnCount() - 1) && getRowCount() > 1) {
				setRowSelectionInterval(rowAtPoint(e.getPoint()), rowAtPoint(e.getPoint()));
				deleteSelectedClasses();
			}
		}
	});
	getColumnModel().getColumn(getColumnCount() - 1).setMinWidth(20);
	getColumnModel().getColumn(getColumnCount() - 1).setMaxWidth(20);
}
 
Example 24
Project: jmt   File: WhatIfPlot.java   Source Code and License 6 votes vote down vote up
public WhatIfPlot(double[] xAxis) {
	super();
	this.xAxis = xAxis;
	// Adds popup menu
	this.addMouseListener(new MouseAdapter() {
		/**
		 * Invoked when the mouse has been clicked on a component.
		 */
		@Override
		public void mouseClicked(MouseEvent e) {
			if (e.getButton() == MouseEvent.BUTTON3) {
				popup.show(WhatIfPlot.this, e.getX(), e.getY());
			}
		}
	});
}
 
Example 25
Project: TransparentDiscord   File: UITitleBar.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a title bar with the given text and ability to close the parent jframe
 * @param titleText the text to display as the title, can be HTML formatted
 * @param parent the jframe to close when the X is clicked
 */
public UITitleBar(String titleText, JFrame parent) {
    setBackground(Color.decode("#7289DA"));
    setLayout(new BorderLayout());

    JLabel title = new JLabel(titleText);
    title.setFont(TransparentDiscord.boldFont.deriveFont(Font.PLAIN, 16));
    title.setBorder(new EmptyBorder(20,20,20,20));
    add(title, BorderLayout.WEST);

    JLabel closeButton = new JLabel("X");
    closeButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent mouseEvent) {
            parent.setVisible(false);
        }
    });
    closeButton.setBorder(new EmptyBorder(20,20,20,20));
    closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    add(closeButton, BorderLayout.EAST);
}
 
Example 26
Project: TransparentDiscord   File: UIChannelListItem.java   Source Code and License 6 votes vote down vote up
/**
 * Constructs a list item around a text channel
 * @param channel
 */
public UIChannelListItem(TextChannel channel) {
    this(channel.getId());

    displayName = new JLabel(channel.getName());
    displayName.setFont(TransparentDiscord.defaultFont.deriveFont(Font.PLAIN, 16));
    displayName.setBorder(new EmptyBorder(10,10,10,10));

    add(displayName, BorderLayout.CENTER);

    //When clicked, open the chat
    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent mouseEvent) {
            TransparentDiscord.openChat(channel);
        }
    });
}
 
Example 27
Project: marathonv5   File: RMenuItemTest.java   Source Code and License 6 votes vote down vote up
public void selectMenuItem() {
    final LoggingRecorder lr = new LoggingRecorder();
    final List<JMenuItem> items = new ArrayList<JMenuItem>();
    siw(new Runnable() {
        @Override public void run() {
            JMenu AMenu = (JMenu) menus.get(0);
            AMenu.doClick();
            items.addAll(getMenuComponents(AMenu));
        }
    });
    items.get(1).addMouseListener(new MouseAdapter() {
        @Override public void mousePressed(MouseEvent e) {
            RMenuItem rMenuItem = new RMenuItem(items.get(1), null, null, lr);
            rMenuItem.mouseButton1Pressed(e);
        }
    });
    IDevice d = Device.getDevice();
    d.click(items.get(1), Buttons.LEFT, 1, 5, 5);
    Call call = lr.getCall();
    AssertJUnit.assertEquals("select_menu", call.getFunction());
    AssertJUnit.assertEquals("A Menu>>Both text and icon", call.getState());
}
 
Example 28
Project: SER316-Ingolstadt   File: TableSorter.java   Source Code and License 6 votes vote down vote up
public void addMouseListenerToHeaderInTable(JTable table) { 
    final TableSorter sorter = this; 
    final JTable tableView = table; 
    tableView.setColumnSelectionAllowed(false); 
    MouseAdapter listMouseListener = new MouseAdapter() {
        boolean ascending = false;
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = tableView.convertColumnIndexToModel(viewColumn); 
            if (e.getClickCount() == 1 && column != -1) {
                //System.out.println("Sorting ..."); 
                //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; 
                //boolean ascending = (shiftPressed == 0);
                if (column == sortBy)                    
                    ascending = !ascending;
                else
                    ascending = true; 
                sorter.sortByColumn(column, ascending);   
                tableView.getTableHeader().updateUI();                  
            }
        }
    };
    JTableHeader th = tableView.getTableHeader(); 
    th.addMouseListener(listMouseListener); 
}
 
Example 29
Project: Progetto-C   File: Hiero.java   Source Code and License 6 votes vote down vote up
public void close () {
	final long endTime = System.currentTimeMillis();
	new Thread(new Runnable() {
		public void run () {
			if (endTime - startTime < minMillis) {
				addMouseListener(new MouseAdapter() {
					public void mousePressed (MouseEvent evt) {
						dispose();
					}
				});
				try {
					Thread.sleep(minMillis - (endTime - startTime));
				} catch (InterruptedException ignored) {
				}
			}
			EventQueue.invokeLater(new Runnable() {
				public void run () {
					dispose();
				}
			});
		}
	}, "Splash").start();
}
 
Example 30
Project: onprom   File: CustomTree.java   Source Code and License 6 votes vote down vote up
public void setPopMenu(JPopupMenu _menu) {
  menu = _menu;
  if (menu != null) {
    addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        if (SwingUtilities.isRightMouseButton(e)) {
          setSelectionRow(getClosestRowForLocation(e.getX(), e.getY()));
          if (getSelectionCount() > 0 && isRootNotSelected()) {
            menu.show(CustomTree.this, e.getX(), e.getY());
          }
        } else if (e.getClickCount() == 2) {
          try {
            if (action != null)
              action.call();
          } catch (Exception ex) {
            logger.warn(ex.getMessage(), ex);
          }
        }
      }
    });
  }
}
 
Example 31
Project: PTEAssistant   File: UserTableHeaderCellRenderer.java   Source Code and License 6 votes vote down vote up
public UserTableHeaderCellRenderer(JTable table) {
    this.tableModel = (UserTableModel) table.getModel();
    this.tableHeader = table.getTableHeader();
    selectBox = new JCheckBox(tableModel.getColumnName(0));
    selectBox.setSelected(false);
    tableHeader.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 0) {
                int selectColumn = tableHeader.columnAtPoint(e.getPoint());
                if (selectColumn == 0) {
                    boolean value = !selectBox.isSelected();
                    selectBox.setSelected(value);
                    tableModel.selectAll(value);
                    tableHeader.repaint();
                }
            }
        }
    });
}
 
Example 32
Project: SER316-Munich   File: TableSorter.java   Source Code and License 6 votes vote down vote up
public void addMouseListenerToHeaderInTable(JTable table) { 
    final TableSorter sorter = this; 
    final JTable tableView = table; 
    tableView.setColumnSelectionAllowed(false); 
    MouseAdapter listMouseListener = new MouseAdapter() {
        boolean ascending = false;
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = tableView.convertColumnIndexToModel(viewColumn); 
            if (e.getClickCount() == 1 && column != -1) {
                //System.out.println("Sorting ..."); 
                //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; 
                //boolean ascending = (shiftPressed == 0);
                if (column == sortBy)                    
                    ascending = !ascending;
                else
                    ascending = true; 
                sorter.sortByColumn(column, ascending);   
                tableView.getTableHeader().updateUI();                  
            }
        }
    };
    JTableHeader th = tableView.getTableHeader(); 
    th.addMouseListener(listMouseListener); 
}
 
Example 33
Project: JavaGraph   File: ResourceDisplay.java   Source Code and License 6 votes vote down vote up
/**
 * Initialises all listening activity on the display, and
 * calls {@link #activateListening()}.
 */
@Override
protected void installListeners() {
    getSimulatorModel().addListener(this, Change.GRAMMAR, Change.toChange(getResourceKind()));
    // adds a mouse listener that offers a popup menu with a detach action
    getTabPane().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                int index = getTabPane().indexAtLocation(e.getX(), e.getY());
                if (index >= 0) {
                    ResourceTab tab = (ResourceTab) getTabPane().getComponentAt(index);
                    if (tab != getMainTab()) {
                        createDetachMenu(tab).show(ResourceDisplay.this, e.getX(), e.getY());
                    }
                }
            }
        }
    });
    activateListening();
}
 
Example 34
Project: chiefproject   File: CreatorPlayerPanelButton.java   Source Code and License 6 votes vote down vote up
public JButton changePlayerGenderRight(){
    JButton changePlayerGender = new JButton(
            readXML.readXML(1,"currency",2));
    changePlayerGender.setForeground(setColor.getColor(setColor.button,1));
    changePlayerGender.setBackground(null);
    changePlayerGender.setBorder(null);
    changePlayerGender.setFont(setFont.getFont(setFont.buttonFontI));
    changePlayerGender.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent mouseEvent) {
            int genderId = Integer.parseInt(cacheHandle.readCache(cacheHandle.player,"gender"));
            switch (genderId){
                case 0:
                    genderId ++;
                    cacheHandle.setCache(cacheHandle.player,"gender",Integer.toString(genderId));
                    loadPanel.loadPanel(loadPanel.creatorPlayerPanelId);
                    break;
                case 1:
                    break;
            }
        }
    });
    return changePlayerGender;
}
 
Example 35
Project: SER316-Dresden   File: TableSorter.java   Source Code and License 6 votes vote down vote up
public void addMouseListenerToHeaderInTable(JTable table) { 
    final TableSorter sorter = this; 
    final JTable tableView = table; 
    tableView.setColumnSelectionAllowed(false); 
    MouseAdapter listMouseListener = new MouseAdapter() {
        boolean ascending = false;
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = tableView.convertColumnIndexToModel(viewColumn); 
            if (e.getClickCount() == 1 && column != -1) {
                //Util.debug("Sorting ...");
                //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; 
                //boolean ascending = (shiftPressed == 0);
                if (column == sortBy)                    
                    ascending = !ascending;
                else
                    ascending = true; 
                sorter.sortByColumn(column, ascending);   
                tableView.getTableHeader().updateUI();                  
            }
        }
    };
    JTableHeader th = tableView.getTableHeader(); 
    th.addMouseListener(listMouseListener); 
}
 
Example 36
Project: MaxSim   File: CheckRenderer.java   Source Code and License 6 votes vote down vote up
public CheckRenderer(final JList<Object> list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
Example 37
Project: gate-core   File: Splash.java   Source Code and License 6 votes vote down vote up
/**
 * Constructor from owner, GraphicsConfiguration and content.
 */
public Splash(Window owner, GraphicsConfiguration gc, final JComponent content) {
  super(owner, gc);
  getContentPane().setLayout(new BorderLayout());
  content.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  getContentPane().add(content, BorderLayout.CENTER);
  content.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      // when the content pane is clicked, hide it
      setVisible(false);
    }
  });
  validate();
  pack();
}
 
Example 38
Project: jmonet   File: TextTool.java   Source Code and License 6 votes vote down vote up
private void addTextArea(int x, int y) {
    int left = getCanvas().getBounds().x + x;
    int top = getCanvas().getBounds().y + y;

    textArea.setVisible(true);
    textArea.setBorder(new EmptyBorder(0, 0, 0, 0));
    textArea.setText("");
    textArea.setBounds(left, top, (int)(getCanvas().getBounds().getWidth() * getCanvas().getScale()) - left, (int)(getCanvas().getBounds().getHeight() * getCanvas().getScale()) - top);
    textArea.setFont(getScaledFont());
    textArea.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            TextTool.this.mousePressed(e, new Point(0, 0));
        }
    });

    getCanvas().addComponent(textArea);
    textArea.requestFocus();
}
 
Example 39
Project: Cognizant-Intelligent-Test-Scripter   File: TestDataComponent.java   Source Code and License 6 votes vote down vote up
private MouseAdapter onAddNewTDTab() {
    return new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent me) {
            JTabbedPane tabbedPane = (JTabbedPane) me.getSource();
            if (tabbedPane.getSelectedIndex() != -1 && getSelectedData() == null) {
                Rectangle rect = tabbedPane.getUI().
                        getTabBounds(tabbedPane, tabbedPane.getSelectedIndex());
                if (rect.contains(me.getPoint())) {
                    tabbedPane.setSelectedIndex(tabbedPane.getSelectedIndex() - 1);
                    addNewTestData(tabbedPane);
                }
            }
        }
    };
}
 
Example 40
Project: Open-DM   File: AboutDialog.java   Source Code and License 6 votes vote down vote up
public AboutDialog(Window owner, String version) {
    super(owner);

    addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            AboutDialog.this.dispose();
        }
    });

    addKeyListener(this);

    setTitle("Open Data Migrator for Hitachi Content Platform");

    ClassLoader cl = this.getClass().getClassLoader();
    SplashPanel panel = new SplashPanel(
            new ImageIcon(cl.getResource("images/HCPDataMigratorSplashBackground.png"))
                    .getImage());

    getContentPane().add(panel);
    setModal(true);
    pack();

    setLocationRelativeTo(owner);
    setResizable(false);
    setVisible(true);
}
 
Example 41
Project: ramus   File: AttributeEditorDialog.java   Source Code and License 5 votes vote down vote up
private void setEditsAction(final Container con) {
      if (con instanceof JSpinner)
          return;

/*
       * if(con instanceof JSplitPane){
 * setEditsAction(((JSplitPane)con).getLeftComponent());
 * setEditsAction(((JSplitPane)con).getRightComponent()); return; }
 */

      for (int i = 0; i < con.getComponentCount(); i++) {
          if (con.getComponent(i) instanceof Container)
              setEditsAction((Container) con.getComponent(i));
          final Component container = con.getComponent(i);
          if (container instanceof JTextField) {
              ((JTextField) container).addActionListener(listener);
          } else if (container instanceof JPasswordField) {
              ((JPasswordField) container).addActionListener(listener);
          }

          if (container instanceof JList
                  && !(container instanceof JTableHeader)) {
              ((JList) container).addMouseListener(new MouseAdapter() {

                  @Override
                  public void mouseClicked(final MouseEvent e) {
                      if (e.getButton() == MouseEvent.BUTTON1
                              && e.getClickCount() > 1)
                          panel.ok();
                  }

              });
          }
      }
  }
 
Example 42
Project: VISNode   File: JNode.java   Source Code and License 5 votes vote down vote up
/**
 * Initializes the interface
 */
private void initGui() {
    setBorder(new JNodeBorder(this, title));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setFocusable(true);
    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            requestFocusInWindow();
        }
    });
}
 
Example 43
Project: Hotel-Properties-Management-System   File: RoomWindow.java   Source Code and License 5 votes vote down vote up
private MouseListener openCustomerListener() {
	final MouseAdapter adapter = new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {

			if (e.getClickCount() == 2) {

				final int rowIndex = customerTable.getSelectedRow();
				final String name = customerTable.getValueAt(rowIndex, 1).toString();
				final String lastname = customerTable.getValueAt(rowIndex, 2).toString();

				theCustomer = customerDaoImpl.findCustomerByName(name, lastname);

				custWindow.setId(theCustomer.getCustomerId() + "");
				custWindow.setName(theCustomer.getFirstName());
				custWindow.setSurname(theCustomer.getLastName());
				custWindow.setDocument(theCustomer.getDocument());
				custWindow.setDocNo(theCustomer.getDocumentNo());
				custWindow.setCountry(theCustomer.getCountry());
				custWindow.setDateOfBirth(theCustomer.getDateOfBirth());
				custWindow.setEmail(theCustomer.getEmail());
				custWindow.setFatherName(theCustomer.getFatherName());
				custWindow.setMotherName(theCustomer.getMotherName());
				custWindow.setGender(theCustomer.getGender());
				custWindow.setPhone(theCustomer.getPhone());
				custWindow.setMariaggeStaus(theCustomer.getMaritalStatus());
				custWindow.setReservationId(theCustomer.getReservationId() + "");
				custWindow.setInfoMessage(" ");
				
				custWindow.setVisible(true);
				
				loggingEngine.setMessage("Displaying customer...");
				loggingEngine.setMessage("Displayed customer details : " + theCustomer.toString());
			}

			super.mousePressed(e);
		}
	};
	return adapter;
}
 
Example 44
Project: incubator-netbeans   File: TreeList.java   Source Code and License 5 votes vote down vote up
public TreeList(TreeListModel model) {
    super(model);
    setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    setFixedCellHeight(ROW_HEIGHT + INSETS_TOP + INSETS_BOTTOM + 2);
    setCellRenderer(renderer);
    setBackground(ColorManager.getDefault().getDefaultBackground());
    ToolTipManager.sharedInstance().registerComponent(this);
    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() != 2 || e.isPopupTrigger() || e.isConsumed()) {
                return;
            }
            int index = locationToIndex(e.getPoint());
            if (index < 0 || index >= getModel().getSize()) {
                return;
            }
            Object value = getModel().getElementAt(index);
            if (value instanceof TreeListNode) {
                TreeListNode node = (TreeListNode) value;

                if (null != node && !node.isExpandable()) {
                    ActionListener al = node.getDefaultAction();
                    if (null != al) {
                        al.actionPerformed(new ActionEvent(e.getSource(), e.getID(), e.paramString()));
                    }
                } else if (null != node && node.isExpandable()) {
                    if (!node.isLoaded()) {
                        return;
                    }
                    node.setExpanded(!node.isExpanded());
                }
            }
        }
    });
}
 
Example 45
Project: Hotel-Properties-Management-System   File: Main_CustomersFrame.java   Source Code and License 5 votes vote down vote up
private MouseListener openCustomerListener() {
	final MouseAdapter adapter = new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {

			if (e.getClickCount() == 2) {

				final int rowIndex = customerTable.getSelectedRow();
				final String name = customerTable.getValueAt(rowIndex, 2).toString();
				final String lastname = customerTable.getValueAt(rowIndex, 3).toString();

				theCustomer = customerDaoImpl.findCustomerByName(name, lastname);

				custWindow.setId(theCustomer.getCustomerId() + "");
				custWindow.setName(theCustomer.getFirstName());
				custWindow.setSurname(theCustomer.getLastName());
				custWindow.setDocument(theCustomer.getDocument());
				custWindow.setDocNo(theCustomer.getDocumentNo());
				custWindow.setCountry(theCustomer.getCountry());
				custWindow.setDateOfBirth(theCustomer.getDateOfBirth());
				custWindow.setEmail(theCustomer.getEmail());
				custWindow.setFatherName(theCustomer.getFatherName());
				custWindow.setMotherName(theCustomer.getMotherName());
				custWindow.setGender(theCustomer.getGender());
				custWindow.setPhone(theCustomer.getPhone());
				custWindow.setMariaggeStaus(theCustomer.getMaritalStatus());
				custWindow.setReservationId(theCustomer.getReservationId() + "");
				custWindow.setInfoMessage(" ");
				
				custWindow.setVisible(true);
				
				loggingEngine.setMessage("Displaying customer...");
				loggingEngine.setMessage("Displayed customer details : " + theCustomer.toString());
			}

			super.mousePressed(e);
		}
	};
	return adapter;
}
 
Example 46
Project: powertext   File: ParameterizedCompletionChoicesWindow.java   Source Code and License 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param parent The parent window (hosting the text component).
 * @param ac The auto-completion instance.
 * @param context The completion context.
 */
public ParameterizedCompletionChoicesWindow(Window parent,
					AutoCompletion ac,
					final ParameterizedCompletionContext context) {

	super(parent);
	this.ac = ac;
	ComponentOrientation o = ac.getTextComponentOrientation();

	model = new DefaultListModel();
	list = new JList(model);
	if (ac.getParamChoicesRenderer()!=null) {
		list.setCellRenderer(ac.getParamChoicesRenderer());
	}
	list.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			if (e.getClickCount()==2) {
				context.insertSelectedChoice();
			}
		}
	});
	sp = new JScrollPane(list);

	setContentPane(sp);
	applyComponentOrientation(o);
	setFocusableWindowState(false);

	// Give apps a chance to decorate us with drop shadows, etc.
	PopupWindowDecorator decorator = PopupWindowDecorator.get();
	if (decorator!=null) {
		decorator.decorate(this);
	}

}
 
Example 47
Project: myqq   File: FaceFrame.java   Source Code and License 5 votes vote down vote up
private void jbInit() throws Exception
{
	getContentPane().setLayout(gridLayout1);
	gridLayout1.setColumns(15);
	gridLayout1.setHgap(1);
	gridLayout1.setRows(6);
	gridLayout1.setVgap(1);
	String fileName = " ";
	for (int i = 0; i < ico.length; i++)
	{
		if(i<10)
       	{
       		fileName= "/client/img/face/f00"+i+".png";//修改图片路径 
       	}
       	else
       	{
       		fileName= "/client/img/face/f0"+i+".png";
		}
		ico[i]=new   JLabel(new   ImageIcon(FaceFrame.class.getResource(fileName)));
		ico[i].setToolTipText("点此添加QQ表情哟^_^");
		new MyLabel(ico[i],Color.black).addEvent();
		final Icon img = ico[i].getIcon();
		final int count=i;
		ico[i].addMouseListener(new MouseAdapter()
		{
			public void mouseClicked(MouseEvent e)
			{
				chat.jTextPane发送框.insertIcon(img);
				chat.faceIdx=count;
				getObj().dispose();// 这里最好用单例模式
			}
		});
		this.getContentPane().add(ico[i]);
	}
	this.getContentPane().setBackground(SystemColor.text);
}
 
Example 48
Project: incubator-netbeans   File: ButtonPopupSwitcherTestHid.java   Source Code and License 5 votes vote down vote up
private JFrame createFrame() {
    JFrame frame = new JFrame(getClass().getName());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new FlowLayout());
    JButton pBut = new JButton("Popup");
    pBut.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            pButAction(e);
        }
    });
    frame.getContentPane().add(pBut);
    frame.pack();
    frame.setLocationRelativeTo(null);
    return frame;
}
 
Example 49
Project: Progetto-N   File: GuiPrincipale.java   Source Code and License 5 votes vote down vote up
public void impostaAggiungiPortata(){
    jItemAddPortata.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent me) {
            try {
                GuiAddPortata gap = new GuiAddPortata();
                gap.setVisible(true);
            } catch (SQLException ex) {
                Logger.getLogger(GuiPrincipale.class.getName()).log(Level.SEVERE, null, ex);
            }
            
        }  
    });
}
 
Example 50
Project: incubator-netbeans   File: BreadCrumbComponent.java   Source Code and License 5 votes vote down vote up
public BreadCrumbComponent() {
    setPreferredSize(new Dimension(0, COMPONENT_HEIGHT));
    addMouseListener(new MouseAdapter() {
        @Override public void mouseClicked(MouseEvent e) {
            expand(e);
        }
    });
}
 
Example 51
Project: COE1186   File: TrainControllerGUI.java   Source Code and License 5 votes vote down vote up
public void add(TrnControllerGUI g) {
	guiList.add(g);
	
	JLabel L = new JLabel(g.getId());
	stylizeInfoLabel_Bold(L);
	idList.add(L);
	L.setBounds(30, yCount + 8, 100, 24);
	contentPane.add(L);
	
	JButton B = new JButton("VIEW");
	stylizeButton(B);
	buttonList.add(B);
	B.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {	//finds the index of the button and sets the same index controller gui to visible
			int i = buttonList.indexOf(B);
			TrnControllerGUI I = guiList.get(i);
			I.setVisible(true);
		}
	});
	B.setBounds(150, yCount, 70, 37);
	B.setVisible(true);
	B.setEnabled(true);
	contentPane.add(B);
	
	yCount = yCount + 50;
	if (yCount >= (height - 50)) {	//increases size of frame if the buttons need more space
		height = height + 50;
		logoHeight = logoHeight + 50;
		frame.setBounds(100, 500, 450, height);
		icon_logo.setBounds(330, logoHeight, 100, 100);
	}
	frame.repaint();
}
 
Example 52
Project: openjdk-jdk10   File: SetShapeAndClick.java   Source Code and License 5 votes vote down vote up
@Override
public void initBackgroundFrame() {
    super.initBackgroundFrame();
    background.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            clicked |= 1 << 0;
        }
    });
}
 
Example 53
Project: geomapapp   File: CoreDescriptionsDisplay.java   Source Code and License 5 votes vote down vote up
public CoreDescriptionsDisplay(DSDPHole hole, JTextField text) {
		setToolTipText("Click for Core Descriptions");
		zScale = 2.;
		addMouseListener(this);
		this.hole = hole;
		this.text = text;
		mouse = new MouseAdapter() {
			public void mouseEntered(MouseEvent e) {
				e.getComponent().requestFocus();
			}
		};
		cores = hole.cores;
		readCoreDescriptionList();
}
 
Example 54
Project: incubator-netbeans   File: ProfilerXYChart.java   Source Code and License 5 votes vote down vote up
public ToggleViewAction() {
    super();
    updateAction();
    addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isMiddleMouseButton(e))
                actionPerformed(null);
        }
    });
}
 
Example 55
Project: Tarski   File: OurTabbedSyntaxWidget.java   Source Code and License 5 votes vote down vote up
/** Create a new tab with the given filename (if filename==null, we'll create a blank tab instead)
 * <p> If a text buffer with that filename already exists, we will just switch to it; else we'll read that file into a new tab.
 * @return false iff an error occurred
 */
public boolean newtab(String filename) {
   if (filename!=null) {
      filename = Util.canon(filename);
      for(int i=0; i<tabs.size(); i++) if (tabs.get(i).getFilename().equals(filename)) { if (i!=me) select(i); return true; }
   }
   final JLabel lb = OurUtil.label("", OurUtil.getVizFont().deriveFont(Font.BOLD), Color.BLACK, Color.WHITE);
   lb.setBorder(new OurBorder(BORDER, BORDER, Color.WHITE, BORDER));
   lb.addMouseListener(new MouseAdapter() {
      @Override public void mousePressed(MouseEvent e) { for(int i=0; i<tabs.size(); i++) if (tabs.get(i).obj1 == lb) select(i); }
   });
   JPanel h1 = OurUtil.makeH(4); h1.setBorder(new OurBorder(null, null, BORDER, null));
   JPanel h2 = OurUtil.makeH(3); h2.setBorder(new OurBorder(null, null, BORDER, null));
   JPanel pan = Util.onMac() ? OurUtil.makeVL(null, 2, OurUtil.makeHB(h1, lb, h2))
                             : OurUtil.makeVL(null, 2, OurUtil.makeHB(h1, lb, h2, GRAY), GRAY);
   pan.setAlignmentX(0.0f);
   pan.setAlignmentY(1.0f);
   OurSyntaxWidget text = new OurSyntaxWidget(syntaxHighlighting, "", fontName, fontSize, tabSize, lb, pan);
   tabBar.add(pan, tabs.size());
   tabs.add(text);
   text.listeners.add(listener); // add listener AFTER we've updated this.tabs and this.tabBar
   if (filename==null) {
      text.discard(false, getFilenames()); // forces the tab to re-derive a suitable fresh name
   } else {
      if (!text.load(filename)) return false;
      for(int i=tabs.size()-1; i>=0; i--) if (!tabs.get(i).isFile() && tabs.get(i).getText().length()==0) {
         tabs.get(i).discard(false, getFilenames()); close(i); break; // Remove the rightmost untitled empty tab
      }
   }
   select(tabs.size() - 1); // Must call this to switch to the new tab; and it will fire STATUS_CHANGE message which is important
   return true;
}
 
Example 56
Project: AgentWorkbench   File: BaseAgents.java   Source Code and License 5 votes vote down vote up
/**
 * This method initializes jListReferences	
 * @return javax.swing.JList	
 */
private JList<AgentStartArgument> getJListReferences() {
	if (jListReferences == null) {
		jListReferences = new JList<AgentStartArgument>();
		jListReferences.addMouseListener( new MouseAdapter() {
			public void mouseClicked(MouseEvent me) {
				if (me.getClickCount() == 2 ) {
					jButtonRename.doClick();	
				}
			}
		});
	}
	return jListReferences;
}
 
Example 57
Project: AgentWorkbench   File: AgentSelector.java   Source Code and License 5 votes vote down vote up
/**
 * This method initializes jListAgents.
 * @return javax.swing.JList
 */
private JListClassSearcher getJListAgents() {
	if (jListAgents == null) {
		jListAgents = new JListClassSearcher(Agent.class);
		jListAgents.jListLoading.addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent me) {
				if (me.getClickCount()==2) {
					jButtonOk.doClick();	
				}
			}
		});
	}
	return jListAgents;
}
 
Example 58
Project: ramus   File: BaseDialog.java   Source Code and License 5 votes vote down vote up
private void setEditsAction(final Container con) {
      if (con instanceof JSpinner)
          return;

/*
       * if(con instanceof JSplitPane){
 * setEditsAction(((JSplitPane)con).getLeftComponent());
 * setEditsAction(((JSplitPane)con).getRightComponent()); return; }
 */

      for (int i = 0; i < con.getComponentCount(); i++) {
          if (con.getComponent(i) instanceof Container)
              setEditsAction((Container) con.getComponent(i));
          final Component container = con.getComponent(i);
          if (container instanceof JTextField) {
              processTextField((JTextField) container);
          } else if (container instanceof JPasswordField) {
              ((JPasswordField) container).addActionListener(listener);
          }
          if (container instanceof JTextComponent) {
              addUndoFunctions((JTextComponent) container);
          }
          if (container instanceof JList
                  && !(container instanceof JTableHeader)) {
              ((JList) container).addMouseListener(new MouseAdapter() {

                  @Override
                  public void mouseClicked(final MouseEvent e) {
                      if (e.getButton() == MouseEvent.BUTTON1
                              && e.getClickCount() > 1)
                          onOk();
                  }

              });
          }
      }
  }
 
Example 59
Project: rapidminer   File: ConfigureDataTableHeader.java   Source Code and License 5 votes vote down vote up
/**
 * Adds to the table header a {@link MouseListener} which manages the
 * {@link #configureColumnButton} action.
 */
private void setupMouseListener() {
	table.getTableHeader().addMouseListener(new MouseAdapter() {

		@Override
		public void mouseClicked(MouseEvent e) {
			JTableHeader header = ConfigureDataTableHeader.this.table.getTableHeader();

			// this call is very expensive for many columns, because the
			// default model iterates over every column and computes the corresponding width
			int currentIndex = header.getColumnModel().getColumnIndexAtX(e.getPoint().x);

			if (currentIndex != columnIndex || currentIndex == -1) {
				return;
			}

			Rectangle headerRec = header.getHeaderRect(currentIndex);
			setBounds(headerRec);
			header.add(ConfigureDataTableHeader.this);
			validate();

			Rectangle buttonRec = configureColumnButton.getBounds(null);
			buttonRec.x += headerRec.x;
			buttonRec.y += headerRec.y;

			Rectangle nameRec = nameLabel.getBounds(null);
			nameRec.x += headerRec.x;
			nameRec.y += headerRec.y;

			if (buttonRec.contains(e.getPoint())) {
				configureColumnButton.doClick();
			} else if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() >= 2 && nameRec.contains(e.getPoint())) {
				renameAction.actionPerformed(null);
			}

			header.remove(ConfigureDataTableHeader.this);
			header.repaint();
		}
	});
}
 
Example 60
Project: PengueeBot   File: JLabelToggle.java   Source Code and License 5 votes vote down vote up
public JLabelToggle() {
	// TODO Auto-generated constructor stub
	addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			state = !state;
			updateIcon();
		}
	});
}