当前位置: 首页>>代码示例>>Java>>正文


Java JButton.addMouseListener方法代码示例

本文整理汇总了Java中javax.swing.JButton.addMouseListener方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.addMouseListener方法的具体用法?Java JButton.addMouseListener怎么用?Java JButton.addMouseListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JButton的用法示例。


在下文中一共展示了JButton.addMouseListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Helper method used to create a button inside a JPanel
 * @param action action associated to that button
 * @return created component
 */
private JComponent createButton(AbstractAction action) {
	JPanel panel = new JPanel(); // Use gridbag as centers by default
	JButton button = new JButton(action);
	button.setHorizontalTextPosition(SwingConstants.CENTER);
	button.setVerticalTextPosition(SwingConstants.BOTTOM);
	button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
	button.addMouseListener(rollover);
	if (action == buttonAction[3]) {
		button.setVisible(false);
	}
	if (action == buttonAction[0]) {
		button.setEnabled(false);
	}
	//if (action == buttonAction[2]) button.setEnabled(false);
	//if (action == buttonAction[4]) button.setEnabled(false);
	panel.add(button);
	return panel;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:24,代码来源:JWatStartScreen.java

示例2: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Helper method used to create a button inside a JPanel
 * @param action action associated to that button
 * @return created component
 */
private JComponent createButton(AbstractAction action) {
	JPanel panel = new JPanel(); // Use gridbag as centers by default
	JButton button = new JButton(action);
	button.setHorizontalTextPosition(SwingConstants.CENTER);
	button.setVerticalTextPosition(SwingConstants.BOTTOM);
	button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
	button.addMouseListener(rollover);
	//if (action == buttonAction[4]) {
	//	button.setVisible(false);
	//}
	//if (action == buttonAction[0]) {
	//	button.setEnabled(false);
	//}
	//if (action == buttonAction[2]) button.setEnabled(false);
	//if (action == buttonAction[4]) button.setEnabled(false);
	panel.add(button);
	return panel;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:24,代码来源:JWatMainPanel.java

示例3: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Helper method used to create a button inside a JPanel
 * @param action action associated to that button
 * @return created component
 */
private JComponent createButton(AbstractAction action) {
	JPanel panel = new JPanel(); // Use gridbag as centers by default
	JButton button = new JButton(action);
	button.setHorizontalTextPosition(SwingConstants.CENTER);
	button.setVerticalTextPosition(SwingConstants.BOTTOM);
	button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
	button.addMouseListener(rollover);
	if (action == buttonAction[3]) {
		button.setVisible(false);
	}
	if (action == buttonAction[0]) {
		button.setEnabled(false);
	}
	//if(action == buttonAction[2]) button.setEnabled(false);
	//if(action == buttonAction[4]) button.setEnabled(false);
	panel.add(button);
	return panel;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:24,代码来源:JWatStartScreen.java

示例4: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Helper method used to create a button inside a JPanel
 * @param action action associated to that button
 * @return created component
 */
private JComponent createButton(AbstractAction action) {
	JPanel panel = new JPanel(); // Use gridbag as centers by default
	JButton button = new JButton(action);
	button.setHorizontalTextPosition(SwingConstants.CENTER);
	button.setVerticalTextPosition(SwingConstants.BOTTOM);
	button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
	button.addMouseListener(rollover);
	//if (action == buttonAction[4]) {
	//	button.setVisible(false);
	//}
	//if (action == buttonAction[0]) {
	//	button.setEnabled(false);
	//}
	//if(action == buttonAction[2]) button.setEnabled(false);
	//if(action == buttonAction[4]) button.setEnabled(false);
	panel.add(button);
	return panel;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:24,代码来源:JWatMainPanel.java

示例5: initialize

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	frame = new JFrame();
	frame.setBounds(100, 100, 800, 450);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().setLayout(null);

	final JButton btnNewButton = new JButton("\u62CD\u7167");
	btnNewButton.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent arg0) {
			flag = 1;// ��̬��������Ϊ1���Ӷ����°�ťʱ��ֹͣ����ͷ�ĵ���
		}
	});
	btnNewButton.setBounds(33, 13, 113, 27);
	frame.getContentPane().add(btnNewButton);

	label = new JLabel("");
	label.setBounds(0, 0, 800, 450);
	frame.getContentPane().add(label);
}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:24,代码来源:CameraShot.java

示例6: UserPanel

import javax.swing.JButton; //导入方法依赖的package包/类
public UserPanel()
{
	resultsModel = new GenericListModel<Object>();
	results = new JList(resultsModel);
	results.addListSelectionListener(this);

	query = new JTextField();
	query.addActionListener(this);
	search = new JButton(CurrentLocale.get("searching.userGroupRole.executeQuery"));
	search.addActionListener(this);
	JPanel panel = new JPanel();
	panel.setLayout(new BorderLayout(5, 5));
	panel.add(new JLabel(CurrentLocale.get("com.tle.admin.recipients.browserfinder.users")), BorderLayout.WEST);
	panel.add(query, BorderLayout.CENTER);
	panel.add(search, BorderLayout.EAST);

	query.addMouseListener(mouse);
	search.addMouseListener(mouse);
	results.addMouseListener(mouse);

	setLayout(new BorderLayout(5, 5));

	add(panel, BorderLayout.NORTH);
	add(new JScrollPane(results), BorderLayout.CENTER);
	setBorder(new EmptyBorder(5, 5, 5, 5));
}
 
开发者ID:equella,项目名称:Equella,代码行数:27,代码来源:BrowseFinder.java

示例7: createArrowButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * adame: only changed method.
 * 
 * @param direction
 * @param handler
 * @return
 */
private Component createArrowButton(int direction, ArrowButtonHandler handler)
{
	JButton b = new FlatterIcons.ArrowButton(direction);
	b.addActionListener(handler);
	b.addMouseListener(handler);
	// Border buttonBorder =
	// UIManager.getBorder("Spinner.arrowButtonBorder");
	// if (buttonBorder instanceof UIResource) {
	// Wrap the border to avoid having the UIResource be replaced by
	// the ButtonUI. This is the opposite of using BorderUIResource.
	// b.setBorder(new CompoundBorder(buttonBorder, null));
	// } else {
	// b.setBorder(buttonBorder);
	// }
	return b;
}
 
开发者ID:equella,项目名称:Equella,代码行数:24,代码来源:FlatterSpinnerUI.java

示例8: main

import javax.swing.JButton; //导入方法依赖的package包/类
public static void main(String[] args) {
	JFrame frame = new JFrame();

	frame.setVisible(true);
	frame.setSize(new Dimension(1280, 720));
	// this kills the process on exit
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setTitle("Hello");

	JLabel label = new JLabel("Hello world");
	frame.add(label);

	JButton button = new JButton("Set zum as your homepage");
	button.addMouseListener(new CustomListener());
	frame.add(button);

	frame.setLayout(new FlowLayout());
}
 
开发者ID:BedrockDev,项目名称:Sunrin2017,代码行数:19,代码来源:Swing01.java

示例9: MBTracks

import javax.swing.JButton; //导入方法依赖的package包/类
public MBTracks( XMap map, int size ) {
		this.map = map;
		control = null;
	//	tracks = new MBTrack[size];
		cruises = new Vector();
		this.size = 0;
		plot = false;
		selectedCruise = -1;
		selectedTrack = -1;
		mbSel = new MBSelection(this);
		enabled = false;
		loaded = false;
		display = new JTextArea("none selected");
		display.setForeground(Color.black);

//		***** GMA 1.6.0: Add button to bring up selected ping file in datalink
		retrievePingFile = new JButton("Download selected ping file");
		retrievePingFile.addMouseListener(this);
		trackInfoAndButton = new JPanel(new BorderLayout());
		trackInfoAndButton.add(display, BorderLayout.NORTH);
		trackInfoAndButton.add(retrievePingFile, BorderLayout.EAST);
//		***** GMA 1.6.0
	}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:24,代码来源:MBTracks.java

示例10: createPreviousButton

import javax.swing.JButton; //导入方法依赖的package包/类
@Override
protected Component createPreviousButton() {
	AbstractButton ab = (AbstractButton) super.createPreviousButton();
	JButton b = new SpinnerButton("down");
	b.addActionListener((ActionListener) getUIResource(ab.getActionListeners()));
	b.addMouseListener((MouseListener) getUIResource(ab.getMouseListeners()));
	return b;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:9,代码来源:SpinnerUI.java

示例11: createNextButton

import javax.swing.JButton; //导入方法依赖的package包/类
@Override
protected Component createNextButton() {
	AbstractButton ab = (AbstractButton) super.createNextButton();
	JButton b = new SpinnerButton("up");
	b.setRequestFocusEnabled(false);
	b.addActionListener((ActionListener) getUIResource(ab.getActionListeners()));
	b.addMouseListener((MouseListener) getUIResource(ab.getMouseListeners()));
	return b;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:10,代码来源:SpinnerUI.java

示例12: IOObjectCacheEntryPanel

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Creates a new {@link IOObjectCacheEntryPanel}.
 *
 * @param icon
 *            The {@link Icon} associated with the entry's type.
 * @param entryType
 *            Human readable representation of the entry's type (e.g., 'Data Table').
 * @param openAction
 *            The action to be performed when clicking in the entry.
 * @param removeAction
 *            An action triggering the removal of the entry.
 */
public IOObjectCacheEntryPanel(Icon icon, String entryType, Action openAction, Action removeAction) {
	super(ENTRY_LAYOUT);

	this.openAction = openAction;

	// add icon label
	JLabel iconLabel = new JLabel(icon);
	add(iconLabel, ICON_CONSTRAINTS);

	// add object type label
	JLabel typeLabel = new JLabel(entryType);
	typeLabel.setMaximumSize(new Dimension(MAX_TYPE_WIDTH, 24));
	typeLabel.setPreferredSize(typeLabel.getMaximumSize());
	typeLabel.setToolTipText(entryType);
	add(typeLabel, TYPE_CONSTRAINTS);

	// add link button performing the specified action, the label displays the entry's key name
	LinkLocalButton openButton = new LinkLocalButton(openAction);
	openButton.setMargin(new Insets(0, 0, 0, 0));
	add(openButton, KEY_CONSTRAINTS);

	// add removal button
	JButton removeButton = new JButton(removeAction);
	removeButton.setBorderPainted(false);
	removeButton.setOpaque(false);
	removeButton.setMinimumSize(buttonSize);
	removeButton.setPreferredSize(buttonSize);
	removeButton.setContentAreaFilled(false);
	removeButton.setText(null);
	add(removeButton, REMOVE_BUTTON_CONSTRAINTS);

	// register mouse listeners
	addMouseListener(hoverMouseListener);
	iconLabel.addMouseListener(dispatchMouseListener);
	typeLabel.addMouseListener(dispatchMouseListener);
	openButton.addMouseListener(dispatchMouseListener);
	removeButton.addMouseListener(dispatchMouseListener);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:51,代码来源:IOObjectCacheEntryPanel.java

示例13: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Helper method used to create a button inside a JPanel
 * @param action action associated to that button
 * @return created component
 */
private JComponent createButton(AbstractAction action) {
	JPanel panel = new JPanel(); // Use gridbag as centers by default
	JButton button = new JButton(action);
	button.setHorizontalTextPosition(SwingConstants.CENTER);
	button.setVerticalTextPosition(SwingConstants.BOTTOM);
	button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
	button.addMouseListener(rollover);
	panel.add(button);
	return panel;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:16,代码来源:GraphStartScreen.java

示例14: init

import javax.swing.JButton; //导入方法依赖的package包/类
private void init(){
     
    setLayout(new BorderLayout()); //tipo de distribucion de los elementos en el frame
    
    //genero las instancias de los botones
    JButton boton1 = new JButton("boton 1");
    JButton boton2 = new JButton("boton 2");
    JButton boton3 = new JButton("boton 3");
   
    //agrego los escuchadores del Mouse
    boton1.addMouseListener(this);
    
    //agrego el evento de Action al boton2
    boton2.addActionListener(this);
    
    //agrego el escuchador del teclado del boton1
    boton3.addKeyListener(this);
    
    //agrego los botones al Frame
    add(boton1, BorderLayout.CENTER);
    add(boton2, BorderLayout.WEST);
    add(boton3, BorderLayout.EAST);
    
    //configuro la venta, en dimesion, boton de salir y lo pongo visible
    setSize(300, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
    
}
 
开发者ID:jalmx89,项目名称:sota-sxt,代码行数:30,代码来源:Ventana.java

示例15: init

import javax.swing.JButton; //导入方法依赖的package包/类
private void init(){
    setTitle("Mi ventana");
    //setLayout(new FlowLayout());
    setLayout(new GridLayout(3, 4));
    
    JButton boton1 = new JButton("boton 1");
    JButton boton2 = new JButton("boton 2");
    JButton boton3 = new JButton("boton 3");
 
    boton1.addActionListener(new EventoAccion());
    boton2.addMouseListener(new EventoRaton());
    boton3.addKeyListener(new EventoTeclado());
    
    for(int x =0 ; x < 5; x++){
        add(new JLabel("etiqueta "+ (x+1)));
    }      
    
    add(new JTextField("campo de texto", 20));
    
    add(new JTextArea(5,30));
    
    add(boton1);
    add(boton2);
    add(boton3);
    
    setSize(300, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
}
 
开发者ID:jalmx89,项目名称:sota-sxt,代码行数:30,代码来源:Frame.java


注:本文中的javax.swing.JButton.addMouseListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。