Reputation: 495
Hi everyone.. I need some help again. :)
How to do this? When I click the column t1, another form must pop-up explaining what happens to column t1, say, at time 1, Instruction 1 is in fetch stage. Then, when I click naman t2 column, Instruction 2 is in fetch stage and Instruction 1 is in Decode stage., so on and so forth.
Thank you in advance. I really need your help.. Regards.. :)
Upvotes: 0
Views: 5967
Reputation: 2762
You need to add following chunk of code,
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
// This is for double click event on anywhere on JTable
if (e.getClickCount() == 2) {
JTable target = (JTable) e.getSource();
int row = target.getSelectedRow();
int column = target.getSelectedColumn();
// you can play more here to get that cell value and all
new DialogYouWantToOpen(row, Column);
}
}
});
A Dialog which will be opened on double click.
class DialogYouWantToOpen extends JDialog{
JLabel testLabel = new JLable();
public DialogYouWantToOpen(int row, int column){
setSize(200,200)
setLayout(new FlowLayout());
testLabel.setText("User double clicked at row "+row+" and column "+ column);
add(testLabel);
}
}
Upvotes: 2
Reputation: 9775
Generaly it should go something like this
Listener listener = new Listener() {
public void handleEvent(Event e) {
TableColumn column = (TableColumn) e.widget;
System.out.println(column);
}
};
you get the column out of event and then do what you want with it.
Upvotes: -1