mouselistener

at java.awt.AWTEventMulticaster.mouseExited(Unknown Source) occur after using the GUI for several times

牧云@^-^@ 提交于 2020-01-24 12:42:24
问题 Good Morning, i'm implementing the GUI for a game and when i play the game for sometime i get an endless number of this exception then the game freezes, any help on what is the problem or how to fix it is much appreciated here is the code: public class BoardFrame extends JFrame implements MouseListener { private void boardWithoutCheckers() { for(int i=0; i<8; i++) { for(int j=0; j< 8; j++) { if(((i + j) % 2) == 0){ boardFrame[i][j] = new LightGrayButton(); } else { boardFrame[i][j] = new

at java.awt.AWTEventMulticaster.mouseExited(Unknown Source) occur after using the GUI for several times

天大地大妈咪最大 提交于 2020-01-24 12:42:14
问题 Good Morning, i'm implementing the GUI for a game and when i play the game for sometime i get an endless number of this exception then the game freezes, any help on what is the problem or how to fix it is much appreciated here is the code: public class BoardFrame extends JFrame implements MouseListener { private void boardWithoutCheckers() { for(int i=0; i<8; i++) { for(int j=0; j< 8; j++) { if(((i + j) % 2) == 0){ boardFrame[i][j] = new LightGrayButton(); } else { boardFrame[i][j] = new

at java.awt.AWTEventMulticaster.mouseExited(Unknown Source) occur after using the GUI for several times

为君一笑 提交于 2020-01-24 12:42:08
问题 Good Morning, i'm implementing the GUI for a game and when i play the game for sometime i get an endless number of this exception then the game freezes, any help on what is the problem or how to fix it is much appreciated here is the code: public class BoardFrame extends JFrame implements MouseListener { private void boardWithoutCheckers() { for(int i=0; i<8; i++) { for(int j=0; j< 8; j++) { if(((i + j) % 2) == 0){ boardFrame[i][j] = new LightGrayButton(); } else { boardFrame[i][j] = new

JButton with both ActionListener / MouseListener

蹲街弑〆低调 提交于 2020-01-15 07:18:30
问题 Is it possible to create a Jbutton with both an ActionListener and MouseListener Meaning so i create a button and then when i press it ( throught actionListener) it changes the frame so that AFTER then button was pressed i can press anywhere on the frame and MouseListener would in use. JButton button = new JButton();//Creates Button button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //Insert MouseListener //Then do something with mouseListener } });

Why does it draw lines in the wrong place?

与世无争的帅哥 提交于 2020-01-15 06:29:53
问题 I have a problem with this... When I draw a line the character follows the line I drew but the computer paints a line somewhere else: So does anyone know what is going on? My code: @SuppressWarnings({"serial","rawtypes","unchecked"}) public class someGame extends JFrame implements MouseListener, KeyListener{ ArrayList lines = new ArrayList(); Point2D.Double start; final Color BROWN = new Color(156,93,82); Slider thread; Rectangle cow = null; boolean drawGuy = false; public someGame(){ super(

Why won't my JFrame respond to mouse and window changes?

我与影子孤独终老i 提交于 2020-01-14 06:36:47
问题 Here is my code: import java.awt.event.*; import java.awt.*; import javax.swing.*; public class wind extends JFrame implements ComponentListener, MouseListener { JButton button; JLabel label; public wind() { // initialise instance variables setTitle("My First Window!"); setSize(400, 200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); JPanel content = new JPanel(); content.setLayout(new FlowLayout()); content.addComponentListener(this); content.addMouseListener(this); label

MouseListener for JScrollBar arrow buttons

泄露秘密 提交于 2020-01-05 10:19:33
问题 http://s019.radikal.ru/i626/1203/ae/8420ef7757f7.png JScrollPane.getVerticalScrollBar().addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { System.out.println("mouseClicked"); } public void mousePressed(MouseEvent e) { System.out.println("mousePressed"); } public void mouseReleased(MouseEvent e) { System.out.println("mouseReleased"); } }); It works if I click on the strip, but does not work when I click on the buttons 回答1: The buttons are defined in the JScrollBar's

java swing associating JPanel with row col values for mouse listener

独自空忆成欢 提交于 2020-01-04 04:11:09
问题 I'm writing a board game with a GUI and basically I have a 10x10 GridLayout JPanel. Each grid cell is a square JPanel (I used BorderLayout for these JPanels so the borders are visible). Anyway I want it so that when one of these squares is clicked, it makes a change to the boardGameGrid which is a class imported to the GUI for the backend of the game. Say I want to use the method boardGameGrid.setCellCross(x,y) when the cell at position (x,y) is pressed. I can't figure out how to do this

How to get Mouse hover event in `Java Swing`

。_饼干妹妹 提交于 2020-01-03 18:42:22
问题 I have a JPanel with multiple components in it - like a few JLabels , JTextBoxes , JComboBoxes , JCheckBoxes etc. I want to display a pop up help window if the user hovers over these components for say 3 secs. So far I added a MouseListener to one of my Components and it does display the required pop up and help. However I can't achieve it after 3 sec delay. As soon as the user moves the mouse to through that area of the component the pop up displays. This is very annoying as the components

Smooth vertical scrolling on mouse wheel in vanilla javascript?

安稳与你 提交于 2019-12-31 10:47:21
问题 I am a huge fan for vanilla javascript, currently I am working on a project where I need to implement smooth scrolling on mouse wheel scroll. I want to implement this using vanilla JS. I found a jQuery snippet on doing some research which go like below. $(window).on('mousewheel DOMMouseScroll', function(e) { var dir, amt = 100; e.preventDefault(); if(e.type === 'mousewheel') { dir = e.originalEvent.wheelDelta > 0 ? '-=' : '+='; } else { dir = e.originalEvent.detail < 0 ? '-=' : '+='; } $(