當前位置: 首頁>>代碼示例>>Java>>正文


Java JComponent.addMouseListener方法代碼示例

本文整理匯總了Java中javax.swing.JComponent.addMouseListener方法的典型用法代碼示例。如果您正苦於以下問題:Java JComponent.addMouseListener方法的具體用法?Java JComponent.addMouseListener怎麽用?Java JComponent.addMouseListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JComponent的用法示例。


在下文中一共展示了JComponent.addMouseListener方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerComponent

import javax.swing.JComponent; //導入方法依賴的package包/類
/**
    * Registers a component for tooltip management.
    * <p>
    * This will register key bindings to show and hide the tooltip text
    * only if <code>component</code> has focus bindings. This is done
    * so that components that are not normally focus traversable, such
    * as <code>JLabel</code>, are not made focus traversable as a result
    * of invoking this method.
    *
    * @param component  a <code>JComponent</code> object to add
    * @see JComponent#isFocusTraversable
    */
   protected void registerComponent(JComponent component) {
       component.removeMouseListener(this);
       component.addMouseListener(this);
       component.removeMouseMotionListener(moveBeforeEnterListener);
component.addMouseMotionListener(moveBeforeEnterListener);

if (shouldRegisterBindings(component)) {
    // register our accessibility keybindings for this component
    // this will apply globally across L&F
    // Post Tip: Ctrl+F1
    // Unpost Tip: Esc and Ctrl+F1
    InputMap inputMap = component.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap actionMap = component.getActionMap();

    if (inputMap != null && actionMap != null) {
               //XXX remove
    }
}
   }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:ToolTipManagerEx.java

示例2: installUI

import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public synchronized void installUI(JComponent c)
{
	super.installUI(c);

	mBackgroundNormal = UIManager.getColor("RadioButton.background");
	mBackgroundPressed = UIManager.getColor("RadioButton.backgroundPressed");
	mBackgroundActive = UIManager.getColor("RadioButton.backgroundActive");
	mTextNormal = UIManager.getColor("RadioButton.textNormal");
	mTextPressed = UIManager.getColor("RadioButton.textPressed");
	mTextActive = UIManager.getColor("RadioButton.textActive");
	mTextDisabled = UIManager.getColor("RadioButton.textDisabled");
	mIconChecked = UIManager.getIcon("RadioButton.iconChecked");
	mIconUnchecked = UIManager.getIcon("RadioButton.iconUnchecked");
	mIconPressedChecked = UIManager.getIcon("RadioButton.iconPressedChecked");
	mIconPressedUnchecked = UIManager.getIcon("RadioButton.iconPressedUnchecked");

	c.setBackground(mBackgroundNormal);
	c.addMouseListener(this);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:21,代碼來源:FlatterRadioButtonUI.java

示例3: installUI

import javax.swing.JComponent; //導入方法依賴的package包/類
@Override
public synchronized void installUI(JComponent c)
{
	super.installUI(c);

	mBackgroundNormal = UIManager.getColor("CheckBox.background");
	mBackgroundPressed = UIManager.getColor("CheckBox.backgroundPressed");
	mBackgroundActive = UIManager.getColor("CheckBox.backgroundActive");
	mTextNormal = UIManager.getColor("CheckBox.textNormal");
	mTextPressed = UIManager.getColor("CheckBox.textPressed");
	mTextActive = UIManager.getColor("CheckBox.textActive");
	mTextDisabled = UIManager.getColor("CheckBox.textDisabled");
	mTextIconGap = UIManager.getInt("CheckBox.textIconGap");
	mIconChecked = UIManager.getIcon("CheckBox.iconChecked");
	mIconUnchecked = UIManager.getIcon("CheckBox.iconUnchecked");
	mIconPressedChecked = UIManager.getIcon("CheckBox.iconPressedChecked");
	mIconPressedUnchecked = UIManager.getIcon("CheckBox.iconPressedUnchecked");

	c.setBackground(mBackgroundNormal);
	c.addMouseListener(this);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:22,代碼來源:FlatterCheckBoxUI.java

示例4: addRightActivator

import javax.swing.JComponent; //導入方法依賴的package包/類
public static void addRightActivator(final JComponent component,
                                     final JPopupMenu popupMenu) {
    component.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(final MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        component.requestFocus();
                    }
                });

                popupMenu.show(component, e.getX(), e.getY());
            }
        }

    });
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:19,代碼來源:MainFrame.java

示例5: MaterialUITimer

import javax.swing.JComponent; //導入方法依賴的package包/類
MaterialUITimer (List <Color> colors, JComponent component, int interval) {
  this.colors = colors;
  this.component = component;
  
  component.addMouseListener (this);
  timer = new Timer (interval, this);
}
 
開發者ID:Plasmoxy,項目名稱:AquamarineLake,代碼行數:8,代碼來源:MaterialUIMovement.java

示例6: addAsFrame

import javax.swing.JComponent; //導入方法依賴的package包/類
/**
 * Adds a component on this Canvas inside a frame.
 *
 * @param comp The component to add to the canvas.
 * @param toolBox Should be set to true if the resulting frame is
 *     used as a toolbox (that is: it should not be counted as a
 *     frame).
 * @param popupPosition A preferred {@code PopupPosition}.
 * @param resizable Whether this component can be resized.
 * @return The {@code JInternalFrame} that was created and added.
 */
private JInternalFrame addAsFrame(JComponent comp, boolean toolBox,
                                  PopupPosition popupPosition,
                                  boolean resizable) {
    final int FRAME_EMPTY_SPACE = 60;

    final JInternalFrame f = (toolBox) ? new ToolBoxFrame()
        : new JInternalFrame();
    if (f.getContentPane() instanceof JComponent) {
        JComponent c = (JComponent) f.getContentPane();
        c.setOpaque(false);
        c.setBorder(null);
    }

    if (comp.getBorder() != null) {
        if (comp.getBorder() instanceof EmptyBorder) {
            f.setBorder(Utility.blankBorder(10, 10, 10, 10));
        } else {
            f.setBorder(comp.getBorder());
            comp.setBorder(Utility.blankBorder(5, 5, 5, 5));
        }
    } else {
        f.setBorder(null);
    }

    final FrameMotionListener fml = new FrameMotionListener(f);
    comp.addMouseMotionListener(fml);
    comp.addMouseListener(fml);
    if (f.getUI() instanceof BasicInternalFrameUI) {
        BasicInternalFrameUI biu = (BasicInternalFrameUI) f.getUI();
        biu.setNorthPane(null);
        biu.setSouthPane(null);
        biu.setWestPane(null);
        biu.setEastPane(null);
    }

    f.getContentPane().add(comp);
    f.setOpaque(false);
    f.pack();
    int width = f.getWidth();
    int height = f.getHeight();
    if (width > getWidth() - FRAME_EMPTY_SPACE) {
        width = Math.min(width, getWidth());
    }
    if (height > getHeight() - FRAME_EMPTY_SPACE) {
        height = Math.min(height, getHeight());
    }
    f.setSize(width, height);
    Point p = chooseLocation(comp, width, height, popupPosition);
    f.setLocation(p);
    this.add(f, MODAL_LAYER);
    f.setName(comp.getClass().getSimpleName());

    f.setFrameIcon(null);
    f.setVisible(true);
    f.setResizable(resizable);
    try {
        f.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {}

    return f;
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:73,代碼來源:Canvas.java

示例7: installToComponent

import javax.swing.JComponent; //導入方法依賴的package包/類
public static void installToComponent(JComponent c) {
	if (c instanceof JTextField && !(c instanceof JPasswordField)) {
		c.addMouseListener(TextComponentPopupMenu.getSharedInstance());
	}
}
 
開發者ID:jonasxiao,項目名稱:FinalSpeed,代碼行數:6,代碼來源:TextComponentPopupMenu.java


注:本文中的javax.swing.JComponent.addMouseListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。