本文整理汇总了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
}
}
}
示例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);
}
示例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);
}
示例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());
}
}
});
}
示例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);
}
示例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;
}
示例7: installToComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
public static void installToComponent(JComponent c) {
if (c instanceof JTextField && !(c instanceof JPasswordField)) {
c.addMouseListener(TextComponentPopupMenu.getSharedInstance());
}
}