| |

VerySource

 Forgot password?
 Register
Search
View: 1359|Reply: 10

How to make the buttons on the title bar of JTable clickable

[Copy link]

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-2-23 01:30:02
| Show all posts |Read mode
As the title
Reply

Use magic Report

0

Threads

11

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-5-5 12:30:01
| Show all posts
You did n’t describe your problem clearly, so the fairy ca n’t help you
Reply

Use magic Report

0

Threads

14

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Invalid IP Address

Post time: 2020-5-7 10:15:01
| Show all posts
Check out Java Swing Tutorial. There is an example about sorting table data rows by clicking table column headers.
Reply

Use magic Report

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-5-8 16:30:02
| Show all posts
This is the case, there is a column in the JTable is JCheckBox, I placed two buttons in the title bar of this column, their role is to select all and not select, OK, or is there an alternative method
Reply

Use magic Report

0

Threads

11

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-5-14 10:30:01
| Show all posts
Not a master, but I like to delve into problems. I ’m sure I can do it in Swing learning today. I ’ll also take a look at SwingSet2 as an example.
Reply

Use magic Report

0

Threads

11

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-5-19 11:15:01
| Show all posts
There is a way to monitor the mouse time and determine that the contain is in the title. If it is, change the data and fire the corresponding method, it should be able to do it.
Reply

Use magic Report

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-5-20 18:00:02
| Show all posts
Judge the contain in the title? What solution?
Reply

Use magic Report

0

Threads

11

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-5-29 07:45:02
| Show all posts
private Container c;
private JTable table;
private JTableHeader h;
public TestTable () {
super ("TestTable");
c = getContentPane ();
table = new JTable (new String [] [] {{"1", "chenliang", "no"}, {"2", "guoguo", "no"}}, new String [] {"No." , "Name", "Dead"});
h = table.getTableHeader ();
h.addMouseListener (this);
c.add (new JScrollPane (table));
setDefaultCloseOperation (EXIT_ON_CLOSE);
setSize (700, 400);
setVisible (true);
}
public void mouseClicked (MouseEvent e) {
for (int i = 0; i <table.getColumnCount (); i ++) {
if (h.columnAtPoint (e.getPoint ()) == i) {
// The mouse clicks the corresponding head of a column
}
}
}
Let ’s discuss again
Reply

Use magic Report

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-5-31 20:45:02
| Show all posts
The problem is that there are two buttons on it
Reply

Use magic Report

0

Threads

11

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-6-1 14:45:01
| Show all posts
You can capture the event of clicking the button, the rest is the same
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list