I am working on a big Gui project. Lots off complex stuff has been done and I cannot change the structure of the code. And as it is a complex project it is difficult to explain or give an SSE but I will try my best.
In our project some people have implemented their own Table. All the cells int the table are a class called CellPanel which extends JPanel
class. So all table cells are JPanels
actually. And these crazy guys have implemented their own mouseClicked function which is about 400 lines. So I am not pasting it here for the good of everyone :) But that mouseClicked
method only works if it is a right click. SO I have the chance of doing something like this:
public void mouseClicked(MouseEvent e) {
DropTable.selectedColorMng(rowInTable);
if(e.getButton()==MouseEvent.BUTTON1) {
System.out.println("left click");
}
else{
// 400 lines of code here
}
}
Now what I want to do is that these CellPanels are designed to contain a label and an icon. It has always been used like this. No dynamic content inside. But now we have a requirement and I have modified these CellPanels to contain JList
in a ScrollPane
. But these JLists
are not clickable. I want to scroll them make multiple selections, but they do not respond to my left clicks. So I think I have to fill inside the if statement of the above code.
But how?
I'm not sure if I understood your question completely. I understood, that your CellPanel
catches the click events so that they doesn't reach the JList
which is contained in the CellPanel
.
If it is like that you can simply delegate that event in the mouseClick
of the CellPanel
to the JList
there must be a reference to it as it is shown in there.