Mouse « JLabel « Java Swing Q&A





1. Java Disabled JLabel Reports Mouse Clicked    stackoverflow.com

colLabels[i].addMouseListener(new MyAdapter());

private class MyAdapter extends MouseAdapter {
@Override
public void mouseClicked(MouseEvent event) {

     ColJLabel colJLabel = (ColJLabel)event.getComponent();

     System.out.println(colJLabel.ColID);

     setColumnHeader(false);
   ...

2. MouseEvents for a JTabbedPane Tab component are not bleeding through    stackoverflow.com

I have a JTabbedPane with a custom tab component. That component contains a JLabel (To display the tab title) and a JButton (A close button). When I change the text in ...

3. Problem with MouseListener on multiple JLabels    stackoverflow.com

I have 5 JLabels inside a JPanel which is inside a JFrame. I am adding the JLabels using a for loop which iterates through an array of Colors:

private JLabel target;

// This ...

4. Changing JLabel ICON from Component    stackoverflow.com

So I have a grid of JLabels that are randomly assigned background colours and ICONs to match (Bubbles for a Bubble Breaker game), the issue comes when I'm using findComponentAt(getX(), getY()) ...

5. How to tell which item fired a mouse listener    stackoverflow.com

HI all, I'm trying to write a simple star rating component. I'm fairly new to the Java language and I'm not sure if what i want to accomplish can even be done ...

6. How to immediately change text of jLabel inside MouseEvent handler?    stackoverflow.com

I have problem with refreshing swing components inside Mouse action event handler. Problem is that all jLabels which are changed in this function that their changes are visible after jButton1MouseClicked() is ...

7. remove and add new JLable in mouseListener    stackoverflow.com

I have 2 JLabels, and I add MouseListener to one of them,which can remove other JLabel and draw it again(when I click on one of them,the Image of other one change) this ...

8. Java mouselistener    stackoverflow.com

How do I go about writing a mouse listener that will react to pressing on any object in a JFrame, or on one particular object? Here's my mouse listener -

class mouse extends ...

9. Dynamically change JLabel icons based on x,y of mouse click    stackoverflow.com

I am using NETBEANS and have several JLabels that need to display a specific icon/image based on a decision/boolean. I do not want to have to add a mouse listener for ...





10. Jython mouse listener on JLabel results in TypeError    stackoverflow.com

I'm making an application in Jython where I try to capture mouse events on a JLabel. I have a JFrame that contains a JLabel, but when I try to add a ...

11. MouseListeners only being detected on last JLabel created in a loop    stackoverflow.com

I'm having a problem with adding MouseListeners to a set number of Jlabels that are created inside a loop. The program I'm creating needs to change the icon of a JLabel ...

12. MouseListener active for Disabled JLabel    coderanch.com

The JLabel is behaving correctly. I think you are confusing the two different types of event handling: low-level and semantic. low-level: Component, Container, Focus, Key, Mouse, Paint, Window semantic: Action, Adjustment, Item, Text Only semantic events are affected by disabling any component. That is because they are directly handled by the component itself which is aware that it is enabled or ...

13. Mouse click on label    coderanch.com

15. GUI Issues. Ghosting when moving JLabel via Mouse    coderanch.com

import java.awt.*; import java.awt.event.*; import javax.accessibility.*; import javax.swing.*; import javax.swing.event.*; public class GUIRx extends JFrame { private JLayeredPane layeredPane = new JLayeredPane(); private JPanel pContentPane = (JPanel)getContentPane(); private static int screenHeight; private static int screenWidth; public GUIRx() { // Cheat the taskbar problem by getting the current screen height/width. screenHeight = (Toolkit.getDefaultToolkit().getScreenSize().height) - 30; screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width; // pContentPane.setLayout(new FlowLayout()); pContentPane.add(layeredPane); ...

16. problem w/ MouseListener and JLabel    coderanch.com

Ok, I knew as soon as I posted the question I'd figure it out. Turns out that when I was creating my GridLayout upon which the JLabels sit, I was passing in a zero for the "hgap" (horizontal gap) which probably meant that my JLablel's were butting up against each other. (even though the card images were not, still not sure ...





17. Weird phenomenon: buzzing when mouse points to a JLabel with image    coderanch.com

That's probably going to win me "weirdest post of the month", but I swear it's not some April's Fools joke... I'd really appreciate it if anyone could offer any hint to what's going on: I have a JFrame that shows some crude image animation: There are some JLables. Each JLabel is assigned a thread that continuously changes the label's image (Using ...

18. how do i access the text on the label for mouseClicked..??    coderanch.com

Guys, I wanted to compare the text on the label and proceed furthur...can you please tell me how to do it...? my code fragment is public void mouseClicked(MouseEvent evt){ String text=""; Font f1=new Font("Jokerman",Font.BOLD,22); Font f2=new Font("Old English Text MT",Font.BOLD,22); Scanner input=new Scanner(System.in); System.out.println("Select the player 1 or 2 "); player=input.nextInt(); while(player==1 || player==2){ if(player==1){ for(i=0;i<6;i++){ for(j=0;j<6;j++){ if (text.equals(" label "+i+ ...

19. MouseListener on a JLabel    forums.oracle.com

I have a mouslistener on a JLabel and when it's clicked I need to somehow allow my mouselistener to "see" the text thats on the label - is that possible? As of now I'm wimping out and using an actionListener on a button, meaning I can use get and setActionCommand to pass the text from the button, but I'd really like ...

20. Adding JLabel with MouseListener to JFrame    forums.oracle.com

This is s program that allows a user to draw shapes by inputting the specifications(size, location, color etc). The user can select a shape and edit or delete it after creating it. I created JLabels and added MouseListeners to them. These JLabels are created when the main program runs but they are not shown yet. When a user creates/draws a shape, ...