mouselistener

Is repaint executing too slow?

拜拜、爱过 提交于 2021-02-10 19:48:15
问题 I have the following: import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JLayeredPane; import javax.swing.JFrame; import javax.swing.BorderFactory; import java.awt.event.MouseListener; import java.awt.event.MouseEvent; import javax.swing.ImageIcon; import java.awt.GridLayout; import java.awt.Dimension; import java.awt.Color; import java.util.Random; class Cell extends JLayeredPane { private JLabel image1; private JLabel image2; private JLabel image3; private Random rand;

Is repaint executing too slow?

筅森魡賤 提交于 2021-02-10 19:47:58
问题 I have the following: import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JLayeredPane; import javax.swing.JFrame; import javax.swing.BorderFactory; import java.awt.event.MouseListener; import java.awt.event.MouseEvent; import javax.swing.ImageIcon; import java.awt.GridLayout; import java.awt.Dimension; import java.awt.Color; import java.util.Random; class Cell extends JLayeredPane { private JLabel image1; private JLabel image2; private JLabel image3; private Random rand;

Why does a JButton under a JPanel still react?

让人想犯罪 __ 提交于 2021-02-10 03:27:48
问题 I looked around for my problem, and i couldn't find an answer, so here I go: I have a JLayeredPane, and in there there are 2 JPanels. The deepest one ( furthest down ) has JButtons on there. The second one ( The one on top ) has a partially transparent background color ( although i don't think this should influence it ). Now when I hover over my JButtons ( which are behind the other JPanel ), they still fire events to the MouseListener I added to them. I don't know why... Why is this the case

Why does a JButton under a JPanel still react?

£可爱£侵袭症+ 提交于 2021-02-10 03:24:15
问题 I looked around for my problem, and i couldn't find an answer, so here I go: I have a JLayeredPane, and in there there are 2 JPanels. The deepest one ( furthest down ) has JButtons on there. The second one ( The one on top ) has a partially transparent background color ( although i don't think this should influence it ). Now when I hover over my JButtons ( which are behind the other JPanel ), they still fire events to the MouseListener I added to them. I don't know why... Why is this the case

java set delay to change imageicon

一曲冷凌霜 提交于 2021-02-05 12:18:57
问题 i'm trying to set a delay when a button is pressed to set an imageicon to a certain image then set another delay so that another image would be set, all of this by single click. in other word : click a button->set image->delay->set another image. what i get in my code is the last state only "set another image". also i don't want to use use timers, i want to use delays. and here the part in my code i'm concerned about. btnNewButton.addMouseListener(new MouseAdapter() { @Override public void

Click events on complex canvas shapes without recourse to external libraries

有些话、适合烂在心里 提交于 2021-02-05 11:25:49
问题 I'd like to implement click detection for multiple complex shapes on a single canvas element similar to that as realized by CanvasRenderingContext2D.isPointInPath() . Obligatory example code below. HTML: <canvas id="canvas"></canvas> <p>In path: <code id="result">false</code></p> JS: const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); const result = document.getElementById('result'); ctx.beginPath(); ctx.moveTo(25, 25); ctx.lineTo(105, 25); ctx.lineTo(25,

Java Swing: Making a growing circle by mouse click on JPanel

你说的曾经没有我的故事 提交于 2021-01-29 22:39:32
问题 I'm a beginner in Java and this time I'm trying to learn more by finding code examples and editing them, for example from this website. I have a JFrame and each time it (or more precise the JPanel in it) is clicked on, a circle is drawn which will grow/expand outwards like a water ripple. Each circle starts with a certain radius and will be removed or redrawn when reaching a bigger radius (I chose radius "r" from 10 to 200). I have two programs for this which almost work but are missing

Java Swing: Making a growing circle by mouse click on JPanel

我的未来我决定 提交于 2021-01-29 22:26:05
问题 I'm a beginner in Java and this time I'm trying to learn more by finding code examples and editing them, for example from this website. I have a JFrame and each time it (or more precise the JPanel in it) is clicked on, a circle is drawn which will grow/expand outwards like a water ripple. Each circle starts with a certain radius and will be removed or redrawn when reaching a bigger radius (I chose radius "r" from 10 to 200). I have two programs for this which almost work but are missing

How to display the contents in an array by using mouseListener?

那年仲夏 提交于 2021-01-28 13:31:33
问题 I'm doing a program in which there are 8 shapes contained in an array that will be displayed when you click the mouse. I am new to Java and not that familiar with event handlers and listeners. I am trying to make the shapes appear at the location the mouse is clicked at inside the frame yet I am having trouble since the constructor of each shape use 2 Points as its parameter. Here's an example from the code: import MyLibs.Circle; import MyLibs.Rectangle; import MyLibs.Shape; import java.awt

MouseListener without a gui

旧街凉风 提交于 2020-08-26 05:30:11
问题 got my first question and here it goes. I'm programming in java and making a litte program where I would like to track mouse event and make some statistics. For example number of right/left clicks, movements, time between doubleclicks, averages, etc. However I'm not able to make a little program and let in run in the background without any gui components in java. I'm not able to test my program and let it (for example) print lines in the console (in eclipse) for the events it gets from the