/** * ************************************ Constructs a BorderButton * * @param borderOwner */ public BorderButtonD(Component borderOwner) { this.borderOwner = borderOwner; // register our mouseListener, making sure it is the first one added MouseListener[] ml = borderOwner.getMouseListeners(); for (int i = 0; i < ml.length; i++) borderOwner.removeMouseListener(ml[i]); borderOwner.addMouseListener(this); for (int i = 0; i < ml.length; i++) borderOwner.addMouseListener(ml[i]); // register mouseMotionListener borderOwner.addMouseMotionListener(this); icon = new ImageIcon[maxIconCount]; isVisibleIcon = new boolean[maxIconCount]; isMouseOverIcon = new boolean[maxIconCount]; iconRect = new Rectangle[maxIconCount]; al = new ActionListener[maxIconCount]; for (int i = 0; i < maxIconCount; i++) { icon[i] = new ImageIcon(); iconRect[i] = new Rectangle(); isMouseOverIcon[i] = false; // need default visibility = false so that focus lost/gained // visibility works isVisibleIcon[i] = false; } }
@Override protected void addImpl(final Component comp, Object constraints, int index) { super.addImpl(comp, constraints, index); comp.addMouseMotionListener( new MouseAdapter() { @Override public void mouseMoved(MouseEvent e) { lastScreen = componentToImage(comp, new Rectangle(0, 0, comp.getWidth(), comp.getHeight())); } }); comp.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { setBorder(new ResizableBorder(6)); } @Override public void mousePressed(MouseEvent e) { mouse = true; } @Override public void mouseReleased(MouseEvent e) { mouse = false; } }); }
/** Auto-generated method for setting the popup menu for a component */ private void setComponentPopupMenu( final java.awt.Component parent, final javax.swing.JPopupMenu menu) { parent.addMouseListener( new java.awt.event.MouseAdapter() { @Override public void mousePressed(final java.awt.event.MouseEvent e) { // if(e.isPopupTrigger()) menu.show(parent, e.getX(), e.getY()); final JTable table = (JTable) e.getSource(); table.clearSelection(); final Point p = e.getPoint(); row = table.rowAtPoint(p); } @Override public void mouseReleased(final java.awt.event.MouseEvent e) { // if(e.isPopupTrigger()) menu.show(parent, e.getX(), e.getY()); final JTable table = (JTable) e.getSource(); table.clearSelection(); final Point p = e.getPoint(); row = table.rowAtPoint(p); } }); }
/** * Descripción de Método * * @param gc * @return */ public boolean includeTab(GridController gc) { MTab imcludedMTab = gc.getMTab(); if (m_mTab.getIncluded_Tab_ID() != imcludedMTab.getAD_Tab_ID()) { return false; } // vIncludedGC = gc; vIncludedGC.switchMultiRow(); vIncludedGC.setRowSelectionAllowed(false); // Dimension size = getPreferredSize(); srPane.setResizeWeight(.75); // top part gets 75% srPane.add(vIncludedGC, JSplitPane.BOTTOM); srPane.setBottomComponent(vIncludedGC); srPane.setDividerSize(5); // int height = 150; vIncludedGC.setPreferredSize(new Dimension(600, height)); setPreferredSize(new Dimension(size.width, size.height + height)); srPane.setDividerLocation(size.height); // imcludedMTab.setIncluded(true); imcludedMTab.query(false, 0); // JRootPane rt = SwingUtilities.getRootPane(this); if (rt == null) { System.out.println("Root pane null"); } else { // System.out.println( "Root=" + rt ); rt.addMouseListener(vIncludedGC); Component gp = rt.getGlassPane(); if (gp == null) { System.out.println("No Glass Pane"); } else { // System.out.println( "Glass=" + gp ); gp.addMouseListener(vIncludedGC); } } vIncludedGC.addMouseListener(vIncludedGC); vIncludedGC.enableEvents(AWTEvent.HIERARCHY_EVENT_MASK + AWTEvent.MOUSE_EVENT_MASK); return true; } // IncludeTab
public void install(Component container) { if (this.container != null) { throw new IllegalStateException("already initialized"); } this.container = container; container.addMouseListener(this); container.addMouseMotionListener(this); }
// TODO 1.5: Remove in 1.5 protected void installPreviousButtonListenersFromSuper(Component c) { AbstractButton sc = (AbstractButton) super.createPreviousButton(); ActionListener[] als = sc.getActionListeners(); MouseListener[] mls = sc.getMouseListeners(); if (c instanceof AbstractButton) { ((AbstractButton) c).addActionListener(als[0]); } c.addMouseListener(mls[0]); }
private void addToAllKidComponents(MouseListener mouseListener) { for (Component component : getComponents()) { if (component instanceof QueryColumnPanel) { ((QueryColumnPanel) component).addColumnMouseListener(mouseListener); } else { component.addMouseListener(mouseListener); } } }
public InputManager(Component component) { this.component = component; mouseLocation = new Point(); centerLocation = new Point(); component.addKeyListener(this); component.addMouseListener(this); component.addMouseMotionListener(this); component.addMouseWheelListener(this); component.setFocusTraversalKeysEnabled(false); }
private void addMouseListenerToAnyButtonsIn(java.awt.Component comp) { int children = (comp instanceof Container) ? ((Container) comp).getComponentCount() : -1; for (int i = 0; i < children; i++) { Component kid = ((Container) comp).getComponent(i); if (kid instanceof javax.swing.AbstractButton) { kid.addMouseListener(this); } addMouseListenerToAnyButtonsIn(kid); } }
public void addPseudoclassListener( DefaultStyleable styleable, String pseudoclass, final PseudoclassListener listener) throws StylesheetException { final PseudoclassEvent event = new PseudoclassEvent(styleable, pseudoclass); Component component = (Component) styleable.getBaseObject(); if (pseudoclass.equals("focused") || pseudoclass.equals("unfocused")) { boolean inverse = pseudoclass.equals("unfocused"); if (component.hasFocus() != inverse) listener.pseudoclassAdded(event); component.addFocusListener(getFocusListener(listener, event, inverse)); } else if (pseudoclass.equals("mouseover") || pseudoclass.equals("mouseout")) { boolean inverse = pseudoclass.equals("mouseout"); if (inverse) listener.pseudoclassAdded(event); component.addMouseListener(getMouseOverListener(listener, event, inverse)); } else if (pseudoclass.equals("mousedown") || pseudoclass.equals("mouseup")) { boolean inverse = pseudoclass.equals("mouseup"); if (inverse) listener.pseudoclassAdded(event); component.addMouseListener(getMouseDownListener(listener, event, inverse)); } else super.addPseudoclassListener(styleable, pseudoclass, listener); }
public void install(Component container) { if (this.container != null) { throw new IllegalStateException("already initialized"); } this.container = container; container.addMouseListener(this); container.addMouseMotionListener(this); station.addDockHierarchyListener(this); setController(station.getController()); }
void addRClickListener(Component comp, ItemAdapter itemAdapter) { String txt = "Restore to <" + itemAdapter.getB4ImageValue() + ">"; RClickListener l = new RClickListener(itemAdapter); JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(txt); menuItem.addActionListener(l); popup.add(menuItem); MouseListener popupListener = new PopupListener(popup); comp.addMouseListener(popupListener); }
public static void install( Component tracked, Component component, Boolean focusedVisible, Boolean mouseoverVisible) { ConditionalVisibilityListener cvl = new ConditionalVisibilityListener(component, focusedVisible, mouseoverVisible); if (focusedVisible != null) { tracked.addFocusListener(cvl); } if (mouseoverVisible != null) { tracked.addMouseListener(cvl); } }
public InputManager(Component comp) { this.comp = comp; mousePosition = new Point(); centerLocation = new Point(); // register Listeners comp.addKeyListener(this); comp.addMouseListener(this); comp.addMouseMotionListener(this); comp.addMouseWheelListener(this); // tell focus traversal to take a hike! comp.setFocusTraversalKeysEnabled(false); }
void installListeners(Component component) { for (ComponentListener listener : componentListeners) component.addComponentListener(listener); for (KeyListener listener : keyListeners) component.addKeyListener(listener); for (MouseListener listener : mouseListeners) component.addMouseListener(listener); for (MouseMotionListener listener : mouseMotionListeners) component.addMouseMotionListener(listener); if (component instanceof Container) { Container container = (Container) component; container.addContainerListener(containerListener); for (int iComp = container.getComponentCount(); iComp-- != 0; ) { installListeners(container.getComponent(iComp)); } } }
/** * Add Component and add Mouse Listener * * @param comp component * @param rw read/write * @return component */ public Component add(Component comp, boolean rw) { // Line if (comp instanceof WFLine) { m_lines.add((WFLine) comp); return comp; } // Node if (comp instanceof WFNode) { m_nodes.add((WFNode) comp); comp.addMouseListener(this); if (m_readWrite && rw) // can be moved comp.addMouseMotionListener(this); } return super.add(comp); } // add
/** Creates a new InputManager that listens to input from the specified component. */ public InputManager(Component comp) { this.comp = comp; mouseLocation = new Point(); centerLocation = new Point(); // register key and mouse listeners comp.addKeyListener(this); comp.addMouseListener(this); comp.addMouseMotionListener(this); comp.addMouseWheelListener(this); // allow input of the TAB key and other keys normally // used for focus traversal comp.setFocusTraversalKeysEnabled(false); }
/** * Adds default interactions to the specified component. * * @param comp component * @param win parent window */ public static void addInteraction(final Component comp, final Window win) { comp.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(final MouseEvent e) { focus(comp); } }); if (win instanceof BaseXDialog) { // add default keys final BaseXDialog d = (BaseXDialog) win; comp.addKeyListener( new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { final Object s = e.getSource(); if (s instanceof BaseXCombo && ((BaseXCombo) s).isPopupVisible()) return; // do not key close dialog if button or editor is focused if (ENTER.is(e) && !(s instanceof BaseXButton || s instanceof TextPanel)) { d.close(); } else if (ESCAPE.is(e)) { // do not cancel dialog if search bar is opened boolean close = true; if (s instanceof TextPanel) { final SearchBar bar = ((TextPanel) s).getSearch(); close = bar == null || !bar.deactivate(true); } if (close) d.cancel(); } } }); return; } if (win instanceof GUI) { comp.addKeyListener(globalShortcuts((GUI) win)); } else { throw Util.notExpected("Reference to main window expected."); } }
public ClickDragThreshold(final Component component) { component.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { pressedPoint = e.getLocationOnScreen(); } @Override public void mouseReleased(MouseEvent e) { Point releasedPoint = e.getLocationOnScreen(); int xDiff = releasedPoint.x - pressedPoint.x; int yDiff = releasedPoint.y - pressedPoint.y; if (xDiff == 0 && yDiff == 0) { return; } if (xDiff > -dragThreshold && xDiff < dragThreshold && yDiff > -dragThreshold && yDiff < dragThreshold) { mouseClicked(e); MouseEvent clickEvent = new MouseEvent( e.getComponent(), MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton()); component.dispatchEvent(clickEvent); } } }); }
private static void addPopup(Component component, final JPopupMenu popup) { component.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showMenu(e); } } public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { showMenu(e); } } private void showMenu(MouseEvent e) { popup.show(e.getComponent(), e.getX(), e.getY()); } }); }
protected void generateGUI() { setOpaque(false); plus = new javax.swing.ImageIcon(CompositeElementPanel.class.getResource("images/plus.gif")); minus = new javax.swing.ImageIcon(CompositeElementPanel.class.getResource("images/minus.gif")); expandButton = new javax.swing.JButton(); expandButton.setContentAreaFilled(false); expandButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); expandButton.setFocusPainted(false); expandButton.setBorderPainted(false); expandButton.setBorder(null); expandButton.addActionListener(actionListener); glue = javax.swing.Box.createHorizontalGlue(); addDragSourceComponent(glue); glue.addMouseListener(elementMouseListener); addMouseListener(elementMouseListener); grip.addMouseListener(elementMouseListener); if (headerLabel == null) { headerLabel = new javax.swing.JLabel(); setHeaderLabel(); headerLabel.setOpaque(false); headerLabel.addMouseListener(elementMouseListener); addDragSourceComponent(headerLabel); } if (containingPanel == null) { containingPanel = new javax.swing.JPanel(); containingPanel.setLayout(new java.awt.BorderLayout()); containingPanel.addMouseListener(elementMouseListener); containingPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); containingPanel.setOpaque(false); addDragSourceComponent(containingPanel); } if (headerPanel == null) { headerPanel = new javax.swing.JPanel(); headerPanel.setLayout(new java.awt.GridBagLayout()); headerPanel.addMouseListener(elementMouseListener); headerPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); headerPanel.setOpaque(false); addDragSourceComponent(headerPanel); } }
public NavigationPanel createNavigationPanel(FileSystem fileSystem) { DriveComboBox driveComboBox = new DriveComboBox(context, fileSystem); VirtualFile currentFile = ((Drive) driveComboBox.getSelectedItem()).getFile(); final FileTablePane fileTablePane = new FileTablePane(context); JTextField currentPathTextField = new JTextField(); currentPathTextField.setText(currentFile.getPath().toString()); FileTableStatusLabel statusLabel = new FileTableStatusLabel(fileTablePane.getTable()); for (Component component : new Component[] {currentPathTextField, statusLabel}) { component.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { context.invokeAction(SelectNavigationPanelAction.class, e); } }); } fileTablePane.getTable().setPath(currentFile); return new NavigationPanel(fileTablePane, driveComboBox, currentPathTextField, statusLabel); }
/** * Constructor. * * @param eventSource source of the mouse and key events which will be translated into scripting * language commands. Such a typical source is e.g. the VNC viewer panel. */ public RecordingModule( MainFrame frame, Component eventSource, ScriptManager scriptManager, UserConfiguration cfg) { this.cfg = cfg; this.scriptManager = scriptManager; readOnly = cfg.getBoolean("rfb.readOnly").booleanValue(); fb = (DesktopViewer) eventSource; fb.removeMouseListener(fb); eventSource.addMouseListener(this); fb.addMouseListener(fb); eventSource.addMouseMotionListener(this); eventSource.addMouseWheelListener(this); eventSource.addKeyListener(this); client = scriptManager.getClient(); if (client != null) { client.addServerListener(this); } // scriptManager.addMouseInputListener(this); // scriptManager.addKeyListener(this); // Number of archived events // events.setSize(EVENT_VECTOR_SIZE); // Populate the reversed keycode->keyname Map Map t = Utils.getKeyCodeTable(); Iterator e = t.keySet().iterator(); Object o; while (e.hasNext()) { o = e.next(); keyCodes.put(t.get(o), o); } cfg.addConfigurationListener(this); scriptManager.addScriptListener(this); configurationChanged(null); }
private void initMouseListeners(Component component) { component.addMouseMotionListener( new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { if (dragstart != null) { switch (dragmode) { case DRAG_ROTATE: rotx += e.getY() - dragstart.getY(); roty += e.getX() - dragstart.getX(); break; case DRAG_ZOOM: z += (e.getY() - dragstart.getY()) / 5.0f; break; } } dragstart = e.getPoint(); } }); component.addMouseWheelListener( new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent e) { z += e.getWheelRotation() * 5; } }); component.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { switch (e.getButton()) { case (MouseEvent.BUTTON1): dragmode = MOUSE_MODE.DRAG_ROTATE; break; case (MouseEvent.BUTTON2): dragmode = MOUSE_MODE.DRAG_ZOOM; break; case (MouseEvent.BUTTON3): dragmode = MOUSE_MODE.DRAG_ZOOM; break; } } @Override public void mouseReleased(MouseEvent e) { switch (e.getButton()) { case (MouseEvent.BUTTON1): dragmode = MOUSE_MODE.DRAG_ZOOM; break; case (MouseEvent.BUTTON2): dragmode = MOUSE_MODE.DRAG_ROTATE; break; case (MouseEvent.BUTTON3): dragmode = MOUSE_MODE.DRAG_ROTATE; break; } dragstart = null; } }); }
@Override public void addMouseInputListener(MouseInputListener listener) { component.addMouseListener(listener); component.addMouseMotionListener(listener); }
/** * Add the required listeners to the specified component * * @param component the component the listeners are added to */ public void registerComponent(Component... components) { for (Component component : components) { component.addMouseListener(this); component.addMouseMotionListener(this); } }
public GenericPictureFileChooser(Component c) { mouseWorker = new MouseWorker(); c.addMouseListener(mouseWorker); }
// public void updateOld(Listenable model, Object arg) // { // try { // //System.out.println ("Listenable " + model + " arg " + arg); // //System.out.println("update called"); // RemoteShape shapeModel = null; // if (arg != null && arg instanceof Boolean && (Boolean) arg) // slModel.sort(); // else if ((arg != null) && (arg instanceof SLPutCommand)) { // // //System.out.println("Update called on view " + this); // //RemoteShape shapeModel = ((SLPutCommand) arg).getShapeModel(); // shapeModel = ((SLPutCommand) arg).getShapeModel(); // // System.out.println("Shape model:" + shapeModel); // //shapeModel.addObserver(this); // shapeModel.addListener(this); // if (shapeModel instanceof ComponentModel) { // ComponentModel componentModel = (ComponentModel) shapeModel; // Rectangle b = componentModel.getBounds(); // Component component = componentModel.getComponent(); // //System.out.println("comp model" + componentModel + "comp" + component); // //System.out.println ("model bounds" + b + "comp bounds" + component.getBounds()); // component.setBounds(b.x, b.y, b.width, b.height); // } // } // // null means delete // if (model instanceof SLModel && ((shapeModel == null ) || shapeModel instanceof // ComponentModel)) // updateComponents(shapeModel); // //System.out.println("calling repaint"); // container.repaint(); // } catch (Exception e) { // System.out.println(e); // e.printStackTrace(); // } // } public void update(Listenable model, Object arg) { try { // System.out.println ("Listenable " + model + " arg " + arg); // System.out.println("update called"); RemoteShape shapeModel = null; if (arg != null && arg instanceof Boolean && (Boolean) arg) slModel.sort(); else if ((arg != null) && (arg instanceof SLPutCommand)) { // System.out.println("Update called on view " + this); // RemoteShape shapeModel = ((SLPutCommand) // arg).getShapeModel(); shapeModel = ((SLPutCommand) arg).getShapeModel(); // System.out.println("Shape model:" + shapeModel); // shapeModel.addObserver(this); shapeModel.addListener(this); if (shapeModel instanceof ComponentModel) { ComponentModel componentModel = (ComponentModel) shapeModel; Rectangle b = componentModel.getBounds(); Component component = componentModel.getComponent(); // System.out.println("comp model" + componentModel + "comp" // + component); // System.out.println ("model bounds" + b + "comp bounds" + // component.getBounds()); component.setBounds(b.x, b.y, b.width, b.height); List sortedComponents = slModel.getSortedComponentList(); int insertPos = sortedComponents.indexOf(shapeModel); if (insertPos >= 0 && insertPos <= container.getComponentCount()) container.add(component, insertPos); else { Tracer.error( "Illegal position:" + insertPos + " Same object:" + shapeModel + " at coordinates(" + shapeModel.getX() + ", " + shapeModel.getY() + ") probably displayed twice in graphics window and its stacking order will be ignored"); container.add(component); } component.addMouseListener(shapeEventNotifier); } } else if ((arg instanceof SLRemoveCommand)) { shapeModel = ((SLRemoveCommand) arg).getOriginalShapeModel(); if (shapeModel instanceof ComponentModel) { ComponentModel componentModel = (ComponentModel) shapeModel; container.remove(componentModel.getComponent()); } } // null means delete // if (model instanceof SLModel // && shapeModel instanceof ComponentModel) // updateComponents(shapeModel); // System.out.println("calling repaint"); if (!slModel.locked()) container.repaint(); } catch (Exception e) { System.out.println(e); e.printStackTrace(); } }
public static void allowUserToMove(Component component) { component.addMouseListener(getMoveabilityListener()); component.addMouseMotionListener(getMoveabilityListener()); }
public void makeDraggable(Component component) { component.addMouseListener(this); component.addMouseMotionListener(this); }