本文整理汇总了Java中javax.swing.event.MouseInputAdapter类的典型用法代码示例。如果您正苦于以下问题:Java MouseInputAdapter类的具体用法?Java MouseInputAdapter怎么用?Java MouseInputAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MouseInputAdapter类属于javax.swing.event包,在下文中一共展示了MouseInputAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: impostaJModificaPrenotazione
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
public void impostaJModificaPrenotazione() throws SQLException{
jModificaPrenotazione.addMouseListener(new MouseInputAdapter() {
@Override
public void mousePressed(MouseEvent me) {
GuiModificaPrenotazione mp;
try {
mp = new GuiModificaPrenotazione();
mp.setDataField(id);
mp.setVisible(true);
} catch (SQLException ex) {
Logger.getLogger(GuiPrincipale.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
示例2: impostaRimuovi
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
public void impostaRimuovi(){
jRimuovi.addMouseListener(new MouseInputAdapter() {
@Override
public void mousePressed(MouseEvent me) {
for(int j=0;j<agri.getPrenotazione().size(); j++){
if(agri.getPrenotazione().get(j).getId()==id){
int choose = JOptionPane.showConfirmDialog(rootPane, "Sei sicuro di voler "
+ "eliminare la prenotazione a nome di '"+nomePrenotazione+"' ?");
if(choose==JOptionPane.YES_OPTION){
try {
createDb.deletePrenotazione(id, nomePrenotazione);
agri.getPrenotazione().remove(j);
} catch (SQLException ex) {
Logger.getLogger(GuiPrincipale.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
}
});
}
示例3: ThisWiggleMeGraphic
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
/**
* Sole constructor.
*
* @param component
* @param model
*/
public ThisWiggleMeGraphic( Component component, IClock clock ) {
super( component, clock );
setText( FourierResources.getString( "DiscreteModule.wiggleMe" ), WIGGLE_ME_COLOR );
addArrow( WiggleMeGraphic.TOP_CENTER, new MutableVector2D( 0, -30 ), WIGGLE_ME_COLOR );
setRange( 0, 10 );
setCycleDuration( 5 );
setEnabled( true );
_mouseListener = new MouseInputAdapter() {
// Disable the wiggle me when the mouse is pressed in the apparatus panel.
public void mousePressed( MouseEvent event ) {
// Disable
setEnabled( false );
// Unwire
getComponent().removeMouseListener( this );
}
};
component.addMouseListener( _mouseListener );
}
示例4: createLogoPanel
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
private JPanel createLogoPanel() {
BufferedImage image = PhetCommonResources.getInstance().getImage( PhetLookAndFeel.PHET_LOGO_120x50 );
JLabel logoLabel = new JLabel( new ImageIcon( image ) );
logoLabel.setCursor( Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) );
logoLabel.setToolTipText( LOGO_TOOLTIP );
logoLabel.addMouseListener( new MouseInputAdapter() {
public void mouseReleased( MouseEvent e ) {
PhetServiceManager.showPhetPage();
}
} );
String html = HTMLUtils.createStyledHTMLFromFragment( COPYRIGHT_HTML_FRAGMENT );
InteractiveHTMLPane pane = new InteractiveHTMLPane( html );
pane.setBackground( new JPanel().getBackground() );//see #1275
HorizontalLayoutPanel logoPanel = new HorizontalLayoutPanel();
logoPanel.setInsets( new Insets( 10, 10, 10, 10 ) ); // top,left,bottom,right
logoPanel.add( logoLabel );
logoPanel.add( pane );
return logoPanel;
}
示例5: PageView
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
public PageView(Printable printable, PageFormat pageFormat) {
super();
this.printable = printable;
this.pageFormat = pageFormat;
this.scale = 100;
pages = new Vector<Page>();
setLayout(null);
setBackground(Color.LIGHT_GRAY);
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
MouseInputAdapter dragScroll = new DragScroll(this);
addMouseMotionListener(dragScroll);
addMouseListener(dragScroll);
}
示例6: Menu
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
public Menu(final HarmonicMoon harmonicMoon) {
this.harmonicMoon = harmonicMoon;
addMouseListener(new MouseInputAdapter() {
@Override
public void mouseClicked(MouseEvent event) {
Font font = harmonicMoon.getTitleFont().deriveFont(16.0F);
if (SwingUtilities.isLeftMouseButton(event)) {
int x = (getWidth() - MENU_ITEM_WIDTH) / 2;
int y = 128;
for (MenuItem menuItem : getMenuItems()) {
Point mouse = MouseInfo.getPointerInfo().getLocation();
if (mouse.getX() - getLocationOnScreen().getX() >= x && mouse.getY() - getLocationOnScreen().getY() >= y && mouse.getX() - getLocationOnScreen().getX() <= getWidth() - x && mouse.getY() - getLocationOnScreen().getY() <= y + 32 + getFontMetrics(font).getMaxAscent()) {
MenuSelectEvent menuSelectEvent = new MenuSelectEvent(Menu.this, menuItem);
harmonicMoon.getEventManager().dispatchEvent(menuSelectEvent);
if (!menuSelectEvent.isCancelled()) {
menuSelectEvent.getMenuItem().doSelect();
}
return;
}
y += 1.5 * (32 + getFontMetrics(font).getMaxAscent());
}
}
}
});
}
示例7: buildChooser
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
protected void buildChooser() {
mnemonic = Integer.parseInt(UIManager.getString("ColorChooser.swatchesMnemonic"));
displayedMnemonicIndex = Integer.parseInt(UIManager.getString("ColorChooser.swatchesDisplayedMnemonicIndex"));
swatchSize = UIManager.getDimension("ColorChooser.swatchesSwatchSize");
recentSwatchSize = UIManager.getDimension("ColorChooser.swatchesRecentSwatchSize");
JPanel right = new JPanel(new BorderLayout());
recentPanel = new SwatchPanel(createRecentColors(), null, recentSwatchSize);
MouseInputAdapter swatchMouseAdapter = new SwatchPanelMouseInputAdapter(recentPanel);
recentPanel.addMouseListener(swatchMouseAdapter);
recentPanel.addMouseMotionListener(swatchMouseAdapter);
right.add(BorderLayout.CENTER, new JLabel(UIManager.getString("ColorChooser.swatchesRecentText")));
right.add(BorderLayout.SOUTH, recentPanel);
swatchPanel = new SwatchPanel(MAIN_SWATCH_COLORS, recentPanel, swatchSize);
swatchMouseAdapter = new SwatchPanelMouseInputAdapter(swatchPanel);
swatchPanel.addMouseListener(swatchMouseAdapter);
swatchPanel.addMouseMotionListener(swatchMouseAdapter);
JPanel fullPanel = new JPanel();
fullPanel.add(swatchPanel);
fullPanel.add(right);
this.add(fullPanel);
}
示例8: init
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
private void init() {
FormLayout layout = new FormLayout(
"fill:pref:grow, pref, 3dlu",
"3dlu, pref, fill:pref:grow");
CellConstraints cc = new CellConstraints();
this.setLayout(layout);
messageLabel = new JLabel();
messageLabel.setBackground(backColor);
messageLabel.setForeground(foreColor);
messageLabel.setOpaque(true);
messageLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
messageLabel.setToolTipText("Click to hide");
messageLabel.addMouseListener(new MouseInputAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
hideStatusComponent();
}
});
messageLabel.setHorizontalAlignment(SwingConstants.RIGHT);
add(messageLabel, cc.xy(2, 2));
}
示例9: DiagramCanvas
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
public DiagramCanvas() {
setName("diagram");
diagramChangeHandler = new DiagramChangeHandler();
addComponentListener(new ComponentAdapter() {
/**
* Invoked when the component's size changes.
*/
@Override
public void componentResized(ComponentEvent e) {
if (diagram != null) {
diagram.invalidate();
}
}
});
MouseInputAdapter mouseHandler = new IndicatorHandler();
addMouseListener(mouseHandler);
addMouseMotionListener(mouseHandler);
setPreferredSize(new Dimension(320, 200));
}
示例10: TransitionView
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
/**
* Constructor
*
* @param model underlying transition model
* @param controller Petri net controller of the Petri net the transition is housed in
* @param parent parent of the view
* @param transitionHandler mouse listener actions for the transition when in edit mode
* @param animationHandler mouse listener actions for the transition when in animation mode
*/
public TransitionView(Transition model, PetriNetController controller, Container parent,
MouseInputAdapter transitionHandler, MouseListener animationHandler) {
super(model.getId(), model, controller, controller.getTransitionController(model), parent,
new Rectangle2D.Double(-model.getWidth()/2, -model.getHeight()/2, model.getWidth(), model.getHeight()));
unrotated = new Rectangle2D.Double(-model.getWidth()/2, -model.getHeight()/2, model.getWidth(), model.getHeight());
setChangeListener();
highlighted = false;
rotate(model.getAngle());
//TODO: DEBUG WHY CANT CALL THIS IN CONSTRUCTOR
// changeToolTipText();
setMouseListener(transitionHandler, animationHandler);
}
示例11: DisplayPane
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
public DisplayPane(GUIWorld w) {
world = w;
this.addMouseListener(new MouseInputAdapter() {
@Override
public void mouseReleased(final MouseEvent me) {
// Select or deselect a Plane
Location l = world.screenToWorld(new Point2D.Double(me.getX(), me.getY()));
Plane p = world.getPlaneAt(l);
world.togglePlaneSelection(p);
// If no plane is selected, try to find a task to give its information
if (p == null) {
Task t = world.getTaskAt(l);
if (t != null) {
System.err.println(t);
}
}
} // End of 'mouseReleased(MouseEvent)' method
});
}
示例12: init
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
private void init()
{
// set up the terminal data
this.data = new TerminalData(
prefs.bufferWidthChars, prefs.bufferHeightChars);
this.lineOffset = 0;
this.setFont(prefs.font);
this.setBackground(prefs.bgColor);
this.setForeground(prefs.fgColor);
this.setFocusable(true);
this.addKeyListener(this);
this.addMouseListener(new MouseInputAdapter(){
@Override
public void mouseClicked(MouseEvent e)
{
requestFocusInWindow();
}
});
firstPaint = true;
}
示例13: createListener
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
@Override
public MouseInputAdapter createListener(String... parameters) {
switch(parameters.length) {
case 3:
return new AnnotationMouseListener(parameters[1]);
case 5:
return new AnnotationMouseListener(parameters[1], parameters[2],
parameters[3]);
default:
return null;
}
}
示例14: modificaPortata
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
public void modificaPortata(){
jModificaPortata.addMouseListener(new MouseInputAdapter() {
@Override
public void mousePressed(MouseEvent me) {
try {
GuiModificaPortata gmp = new GuiModificaPortata();
gmp.setVisible(true);
} catch (SQLException ex) {
Logger.getLogger(GuiPrincipale.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
示例15: WWMapTools
import javax.swing.event.MouseInputAdapter; //导入依赖的package包/类
public WWMapTools(MapApp app, XMap map, WorldWindowGLCanvas wwCanvas) {
super(app, map);
this.wwCanvas = wwCanvas;
wwCanvas.getInputHandler().addMouseMotionListener(
new MouseInputAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
lastPoint = e.getPoint();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
updateInfo();
}
});
}
});
wwCanvas.addRenderingListener(new RenderingListener() {
public void stageChanged(RenderingEvent event) {
if (event.getStage().equals(RenderingEvent.AFTER_BUFFER_SWAP)) {
alt = WWMapTools.this.wwCanvas.getView().getEyePosition().getElevation()/1000;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
updateInfo();
}
});
}
}
});
}