java.awt.event.MouseAdapter Java Examples
The following examples show how to use
java.awt.event.MouseAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ColorEditor.java From ghidra with Apache License 2.0 | 6 votes |
/** * The default constructor. * */ public ColorEditor() { previewLabel.setOpaque(true); previewLabel.setPreferredSize(new Dimension(100, 20)); previewLabel.setHorizontalAlignment(SwingConstants.CENTER); previewLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { // show the editor to get the user value showDialog(evt.getComponent()); ColorEditor.this.firePropertyChange(); // now set the new value updateColor(color); } }); }
Example #2
Source File: MultiGradientTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private GradientPanel() { startX = 20; startY = 20; endX = 100; endY = 100; ctrX = 100; ctrY = 100; focusX = 100; focusY = 100; radius = 100.0f; makeNewPaint(); MouseAdapter l = new MyMouseAdapter(); addMouseListener(l); addMouseMotionListener(l); }
Example #3
Source File: MissingEventsOnModalDialogTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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 #4
Source File: ConfigTable.java From knife with MIT License | 6 votes |
private void addClickSort() { TableRowSorter<ConfigTableModel> sorter = new TableRowSorter<ConfigTableModel>(ConfigTableModel); ConfigTable.this.setRowSorter(sorter); JTableHeader header = this.getTableHeader(); header.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { try { //ConfigTable.this.getRowSorter().getSortKeys().get(0).getColumn(); sorter.getSortKeys().get(0).getColumn(); ////当Jtable中无数据时,jtable.getRowSorter()是null } catch (Exception e1) { e1.printStackTrace(new PrintWriter(BurpExtender.callbacks.getStderr(), true));//working? } } }); }
Example #5
Source File: SizeAutoAdjustTextArea.java From xyTalk-pc with GNU Affero General Public License v3.0 | 6 votes |
private void setListeners() { this.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int position = getCaretPosition(); int urlIndex = 0; for (int[] range : urlRange) { if (position >= range[0] && position <= range[1]) { String url = urlList.get(urlIndex); openUrlWithDefaultBrowser(url); } urlIndex++; } } super.mouseClicked(e); } }); }
Example #6
Source File: View.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
/** * The default constructor sets all the visual settings for the JGraph, as well * as Initializing the view to be empty. It also adds appropriate listeners for * all of the actions we are concerned with. * * @param inFrame The view frame of the sketch * @param inSketch The sketch this view is on * @param inOverview The overview in which this */ public View(ViewFrame inFrame, Sketch inSketch, Overview inOverview) { super(inFrame, inOverview); _ourSketch = inSketch; _stateManager = new ModelStateManager<>(this); // Set up mouse listener to watch for double clicks // - Double clicks edit a query node this.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if ((_ourSketch.getFrame().getMode() == SketchFrame.Mode.EDIT) && (e.getClickCount() == 2)) { Object[] currSelection = getSelectionCells(); if ((currSelection.length == 1) && (currSelection[0] instanceof QueryNode)) { DefineQueryNodeAction.updateNode((QueryNode) currSelection[0]); } } } }); }
Example #7
Source File: TableSorter.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void addMouseListenerToHeaderInTable(JTable table) { final TableSorter sorter = this; final JTable tableView = table; tableView.setColumnSelectionAllowed(false); MouseAdapter listMouseListener = new MouseAdapter() { @Override 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); sorter.sortByColumn(column, ascending); } } }; JTableHeader th = tableView.getTableHeader(); th.addMouseListener(listMouseListener); }
Example #8
Source File: CheckRenderer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public CheckRenderer(final JList 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 #9
Source File: ModelTableView.java From arcusplatform with Apache License 2.0 | 6 votes |
private Component createToolbar() { JLabel toolbar = new JLabel(); toolbar.setBackground(Color.DARK_GRAY); toolbar.setIcon(UIManager.getIcon("Tree.expandedIcon")); toolbar.setText("Collapse All"); toolbar.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { // TODO check left key allCollapsed = !allCollapsed; setCollapsed(allCollapsed); if(allCollapsed) { toolbar.setIcon(UIManager.getIcon("Tree.collapsedIcon")); toolbar.setText("Expand All"); } else { toolbar.setIcon(UIManager.getIcon("Tree.expandedIcon")); toolbar.setText("Collapse All"); } } }); return toolbar; }
Example #10
Source File: RegisterValuesPanel.java From ghidra with Apache License 2.0 | 6 votes |
RegisterValuesPanel(PluginTool tool, RegisterManagerProvider provider) { this.tool = tool; this.provider = provider; setLayout(new BorderLayout()); table = createBasicTable(); add(new JScrollPane(table), BorderLayout.CENTER); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int row = table.rowAtPoint(e.getPoint()); int col = table.columnAtPoint(e.getPoint()); col = table.convertColumnIndexToModel(col); if (e.getClickCount() == 2 && row >= 0) { editRow(row); } } }); table.setDefaultRenderer(RegisterValueRange.class, new RegisterValueRenderer(table)); }
Example #11
Source File: GUIOptionCharSetDialog.java From PacketProxy with Apache License 2.0 | 6 votes |
private JScrollPane tableScrollPane(){ table_model = new CharSetsTableModel(getTableDataWithAvailableCharsets(), columns); JTable table = new JTable(table_model); TableColumn col = table.getColumnModel().getColumn(0); col.setMinWidth(50); col.setMaxWidth(50); table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { super.mousePressed(e); if(0==table.getSelectedColumn()){ return; } table.setValueAt(!(Boolean)table.getValueAt(table.getSelectedRow(), 0), table.getSelectedRow(),0); } }); sorter = new TableRowSorter<CharSetsTableModel>(table_model); table.setRowSorter(sorter); JScrollPane jscrollPane = new JScrollPane(table); return jscrollPane; }
Example #12
Source File: SpinnerMenu.java From amodeus with GNU General Public License v2.0 | 6 votes |
@Override protected void design(JPopupMenu jPopupMenu) { for (Type type : spinnerLabel.list) { JMenuItem jMenuItem = new JMenuItem(type.toString()); if (hover) jMenuItem.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent myMouseEvent) { setValue(type); } }); jMenuItem.addActionListener(myActionEvent -> { if (!type.equals(spinnerLabel.getValue())) // invoke only when different setValue(type); }); map.put(type, jMenuItem); jPopupMenu.add(jMenuItem); } }
Example #13
Source File: JCheckBoxList.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
public JCheckBoxList() { super(); setModel(new DefaultListModel()); setCellRenderer(new CheckboxCellRenderer()); addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { int index = locationToIndex(e.getPoint()); if (index != -1) { Object obj = getModel().getElementAt(index); if (obj instanceof JCheckBox) { JCheckBox checkbox = (JCheckBox) obj; if (e.getPoint().getX() < 20){ checkbox.setSelected(!checkbox.isSelected()); } repaint(); } } } }); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); }
Example #14
Source File: CheckRenderer.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public CheckRenderer(final JList 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 #15
Source File: OpList.java From Cafebabe with GNU General Public License v3.0 | 6 votes |
public OpList(OpcodeChooserDialog chooser, int... opcodes) { this.chooser = chooser; this.opcodes = opcodes; this.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)); LazyListModel<OpcodeNode> llm = new LazyListModel<OpcodeNode>(); for (int opcode : opcodes) { llm.addElement(new OpcodeNode(opcode)); } this.setModel(llm); for (MouseListener ml : this.getMouseListeners()) this.removeMouseListener(ml); this.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() >= 1) { int index = locationToIndex(evt.getPoint()); OpcodeNode on = llm.getElementAt(index); chooser.setOpcode(on.opcode); setSelectedIndex(index); chooser.refresh(); } } }); }
Example #16
Source File: GTableWidget.java From ghidra with Apache License 2.0 | 6 votes |
private void init(AnyObjectTableModel<T> model) { this.myModel = model; this.gFilterTable = new GFilterTable<>(model); this.table = gFilterTable.getTable(); table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (!e.isShiftDown()) { processMouseClicked(e); } } }); add(gFilterTable); }
Example #17
Source File: SettingList.java From Cafebabe with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("unchecked") public SettingList(Setting... settings) { this.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)); CheckBoxListModel clm = new CheckBoxListModel(); for (Setting setting : settings) { clm.addCheckBoxElement(new SettingNode(setting), setting.get()); } this.setModel(clm); this.repaint(); for (MouseListener ml : this.getMouseListeners()) this.removeMouseListener(ml); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { int index = locationToIndex(e.getPoint()); if (index != -1) { CheckBoxCellData checkbox = (CheckBoxCellData) getModel().getElementAt(index); SettingNode sn = (SettingNode) checkbox.getUserObject(); checkbox.invertSelection(); repaint(); sn.setUserSelected(checkbox.isSelected()); } } }); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); }
Example #18
Source File: TableSorter.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void addMouseListenerToHeaderInTable(JTable table) { final TableSorter sorter = this; final JTable tableView = table; tableView.setColumnSelectionAllowed(false); MouseAdapter listMouseListener = new MouseAdapter() { @Override 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); sorter.sortByColumn(column, ascending); } } }; JTableHeader th = tableView.getTableHeader(); th.addMouseListener(listMouseListener); }
Example #19
Source File: MultiGradientTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private GradientPanel() { startX = 20; startY = 20; endX = 100; endY = 100; ctrX = 100; ctrY = 100; focusX = 100; focusY = 100; radius = 100.0f; makeNewPaint(); MouseAdapter l = new MyMouseAdapter(); addMouseListener(l); addMouseMotionListener(l); }
Example #20
Source File: VariationTreePane.java From lizzie with GNU General Public License v3.0 | 6 votes |
/** Creates a window */ public VariationTreePane(LizzieMain owner) { super(owner); this.owner = owner; variationTree = new VariationTree(); setVisible(false); // createBufferStrategy(2); // bs = getBufferStrategy(); addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { // left click onClicked(e.getX(), e.getY()); } } }); }
Example #21
Source File: MissingEventsOnModalDialogTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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 #22
Source File: LizziePane.java From lizzie with GNU General Public License v3.0 | 6 votes |
/** Creates a window */ public LizziePane(LizzieMain owner) { // super(owner); // initCompotents(); // input = owner.input; // installInputListeners(); setOpaque(false); addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { Lizzie.frame.getFocus(); } }); }
Example #23
Source File: OuterClassExample.java From code with Apache License 2.0 | 6 votes |
OuterClassExample(){ super(); setTitle("QQ"); setBounds(100, 100, 380, 280); getContentPane().setLayout(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); textField = new JTextField("密码"); textField.setBounds(100, 155, 120, 21); getContentPane().add(textField); textField.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent e) { getContentPane().remove(textField); passwordField = new JPasswordField(); passwordField.setBounds(100, 155, 120, 21); getContentPane().add(passwordField); } }); }
Example #24
Source File: SubBoardPane.java From lizzie with GNU General Public License v3.0 | 6 votes |
/** Creates a window */ public SubBoardPane(LizzieMain owner) { super(owner); subBoardRenderer = new BoardRenderer(false); setVisible(false); // TODO BufferStrategy does not support transparent background? // createBufferStrategy(2); // bs = getBufferStrategy(); addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { // left click if (Lizzie.config.showSubBoard) { Lizzie.config.toggleLargeSubBoard(); owner.invalidLayout(); } } } }); }
Example #25
Source File: SlowPanelIteration.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void showUI() { frame = new JFrame(); frame.setSize(new Dimension(400, 400)); frame.setLocationRelativeTo(null); final Container content = frame.getContentPane(); content.setLayout(new BorderLayout(0, 0)); Container lastPanel = content; for (int i = 0; i < 500; i++) { final JPanel p = new JPanel(); p.setLayout(new BorderLayout(0, 0)); lastPanel.add(p); lastPanel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { System.out.println("click"); go.countDown(); } }); lastPanel = p; } lastPanel.setBackground(Color.GREEN); frame.setVisible(true); Point loc = frame.getLocationOnScreen(); center.x = loc.x + frame.getWidth() / 2; center.y = loc.y + frame.getHeight() / 2; }
Example #26
Source File: ProjectDataTablePanel.java From ghidra with Apache License 2.0 | 5 votes |
private void buildContent() { model = new ProjectDataTableModel(tool); model.addThreadedTableModelListener(new SelectPendingFilesListener()); table = new GFilterTable<>(model) { @Override protected GThreadedTablePanel<DomainFileInfo> createThreadedTablePanel( ThreadedTableModel<DomainFileInfo, ?> threadedModel) { return new GThreadedTablePanel<>(threadedModel) { @Override protected GTable createTable(ThreadedTableModel<DomainFileInfo, ?> m) { // the table's default actions aren't that useful in the Front End return new ProjectDataTable(m); } }; } }; setLayout(new BorderLayout()); add(table, BorderLayout.CENTER); gTable = table.getTable(); gTable.setActionsEnabled(true); gTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { checkOpen(e); } }); gTable.getSelectionModel() .addListSelectionListener( e -> plugin.getTool().contextChanged(null)); gTable.setDefaultRenderer(Date.class, new DateCellRenderer()); gTable.setDefaultRenderer(DomainFileType.class, new TypeCellRenderer()); new ProjectDataTableDnDHandler(gTable, model); }
Example #27
Source File: JModPanelCheckBoxList.java From ModTheSpire with MIT License | 5 votes |
public JModPanelCheckBoxList(ModSelectWindow parent) { this.parent = parent; // enable drag and drop setDragEnabled(true); setDropMode(DropMode.INSERT); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setTransferHandler(new ListItemTransferHandler()); setCellRenderer(new CellRenderer()); addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { int index = locationToIndex(e.getPoint()); if (index != -1) { ModPanel modPanel = getModel().getElementAt(index); parent.setModInfo(modPanel.info); if (e.getX() <= modPanel.checkBox.getWidth()) { if (modPanel.checkBox.isEnabled()) { modPanel.checkBox.setSelected(!modPanel.checkBox.isSelected()); repaint(); } } } } }); // force mods to calc their backgrounds publishBoxChecked(); }
Example #28
Source File: Page.java From xdm with GNU General Public License v2.0 | 5 votes |
private void init() { y = getScaledInt(25); h = getScaledInt(40); btnNav = new JLabel(ImageResource.getIcon("back.png",32,32)); btnNav.setFont(FontResource.getBiggerFont()); btnNav.setForeground(ColorResource.getSelectionColor()); btnNav.setBounds(getScaledInt(10), y, getScaledInt(35), h); add(btnNav); btnNav.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { close(); } }); titleLbl = new JLabel(title); titleLbl.setFont(FontResource.getBiggerFont()); titleLbl.setForeground(ColorResource.getSelectionColor()); titleLbl.setBounds(getScaledInt(50), y, getScaledInt(200), h); add(titleLbl); y += h; y += getScaledInt(10); h = getScaledInt(2); JLabel lineLbl = new JLabel(); lineLbl.setBackground(ColorResource.getSelectionColor()); lineLbl.setBounds(0, y, width, h); lineLbl.setOpaque(true); add(lineLbl); y += h; }
Example #29
Source File: DefaultOptionComponent.java From ghidra with Apache License 2.0 | 5 votes |
public DefaultOptionComponent(EditorState editorState) { super(editorState); setLayout(new PairLayout(0, 6, 40)); this.component = editorState.getEditorComponent(); label = new GDLabel(editorState.getTitle(), SwingConstants.RIGHT); if (component instanceof AbstractButton) { label.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { if (!component.isEnabled()) { return; } AbstractButton button = (AbstractButton) component; button.setSelected(!button.isSelected()); } }); } setSize(getPreferredSize()); String description = editorState.getDescription(); if (description != null) { String htmlDescription = HTMLUtilities.toWrappedHTML(description); label.setToolTipText(htmlDescription); if (component instanceof JComponent) { ((JComponent) component).setToolTipText(htmlDescription); } } add(label); add(component); }
Example #30
Source File: TableChooserDialog.java From ghidra with Apache License 2.0 | 5 votes |
private JComponent buildTable(boolean allowMultipleSelection) { gFilterTable = new GFilterTable<>(model); initializeTable(allowMultipleSelection); gFilterTable.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (!e.isShiftDown()) { processMouseClicked(e); } updateOkEnabled(); } }); setOkEnabled(false); return gFilterTable; }