I'm trying to add Container A with lead component into another Container B (with its own lead component). However, I cannot figure out how to let Container A act separately to pointer events from Container B.
The following code is what I've done so far (and failed). To summarize, calling setBlockLead(true) on Lead component A can cause Lead component A to call its own action listener, but will not affect the rest of Container A.
Container conB = new Container();
Button leadB = new Button("b");
leadB.addActionListener((evt) -> {
System.out.println("Lead B");
});
conB.setLeadComponent(leadB);
Container conA = new Container(BoxLayout.y());
Button leadA = new Button("a");
leadA.addActionListener((evt) -> {
System.out.println("Lead A");
});
conA.add(leadA);
conA.add("Another label");
conB.add(leadB).add(conA);
conA.setBlockLead(true); //This has no effect
conA.setLeadComponent(leadA); //Apparently no effect either
leadA.setBlockLead(true);
//Clicking on leadA (and only leadA) will print "Lead A", but
//Clicking on Label will not
The major reason for this is to show a Button with Images both above and below the words, which should act differently from clicking on the rest of the container.
Please advice.