Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Craig Daniels   on Dec 29 In Java Category.

  
Question Answered By: Katrina Edwards   on Dec 29


For detecting clicks inside a JTextField instance, you would simply add a
mouse-listener or
mouse-adapter to your instance.

This might help:
----------------


package org.blahblah;

import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class ClickOnTextField {

public static void main(String[] args) {

JFrame frame = new JFrame();
JTextField field = new JTextField();

frame.add(field);

field.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.out.println("Mouse Clicked");
}
});

frame.pack();
frame.setVisible(true);
}

}

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on how should i detect mouse click on JTextField Or get search suggestion and latest updates.


Tagged: