Click « JPanel « Java Swing Q&A





1. Getting the colour of where you have clicked on a JPanel?    stackoverflow.com

I only want a method to activate if the pixel that is clicked is white. How would I implement this? Trying to look for a method that returns the colour at ...

2. Need Multiple JPanel's to respond its own mouse click events    stackoverflow.com

I have multiple JPanels on my application, however I cannot figure out how to detect which exactly which one was clicked. In my MouseListener, I have the argument ...

3. clicking a JPanel inside a JFrame    stackoverflow.com

So I have a JFrame, in which it has a bunch of JPanel which is called venPanel. When I click on a venPanel I want the JFrame to add a new ...

4. How to count clicks on the whole jPanel?    stackoverflow.com

I'm looking for answer this question: how to count clicks on whole jPanel? Code below counts clicks only on the one pixel.

public class NewJFrame extends javax.swing.JFrame {


    public ...

5. Determine clicked JPanel component in the MouseListener. Event handling    stackoverflow.com

I have a class whitch extends JPanel:

public class ButtonPanel extends JPanel {

    private label;

    public ButtonPanel() {
        label=new ...

6. Java finding which image i clicked?    stackoverflow.com

Scenario: i have one JFrame and JPanel added to that JFrame. on this panel i have drawn 3 images using

       public ...

7. changing panel color on right click    coderanch.com

Hi, I got some panels with imageicons in each of them, when I right click on each of these panels I want to let the user know its selected, so that means I got to draw some border around the panel or change the panel color, how do i do it on right click?..do i have to add mouselisteners or is ...

8. how to detect click on panel    coderanch.com

9. JPanel actionListener to determine click on diagonal drawLine    coderanch.com

I have a bunch of rectangles on a JPanel, and lines that connect some of the rectangles together. It represents a network map. I wrote the actionListener that handles the clicks on the rectangles. I simply map the x-y coordinates along with the height and width, then grab the points where the click occurred. Now I need a way to figure ...





10. Panel collapses when space bar is clicked    coderanch.com

We have a page in which there are 2 JPanels - searchPanel and resultsPanel. The searchPanel has some combo boxes for the search criteria and a button named 'retrieve'. When the search criteria are selected and the retrieve button is clicked, the result is displayed in the resultsPanel. In such a design, what is being observed is that when a space ...

11. Line delete problem in jpanel on mouse clicked    coderanch.com

hi,i am able to delete line in code where there is only single line displayed. But for multiple lines it does not repaint.even if line is deleted,it shows deleted line on panel.It prints "clicked" as coordinates match in console.Jpanel refreshes when i minimize or maximize the window and then it shows the lines without the deleted lines i.e it repaints. Please ...

13. JPanel that needs to show another "window" when I click a component    coderanch.com

Hi, im trying to do something in my application but dont know how to do it, so im going to explain it what i want to do and hope you can assist me. Sorry for the subject, i didnt even know how to put this simple so you know what im talking about reading the subject. I have a JPanel and ...

14. Mouse Clicks not registering correctly on JPanel    coderanch.com

Hi all, I've just had my first dab in Java 2d graphics and have created a quick and rather crude program which draws a line between two points. The problem I am experiencing is that a lot of the mouse clicks just do not register on the JPanel. Any idea how to fix this? My code is below: import javax.swing.*; import ...

15. Hide Panel when clicking outside of it    java-forums.org

I have a Swing application that is composed of a 30x30 grid of objects extending JLabels, call it ExtendedJLabel. When you click an ExtendedJLabel a panel appears which lets you edit the properties of the ExtendedJLabel. I have a save and cancel button which work well enough to close the panel, but I wanted to include the functionality so that if ...