本文整理匯總了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();
}
});
}
}
});
}