I know that using null Layout
is not a good way to make a GUI
application but I think this is a case where I should use it.
I have a JPanel
managed by a LayoutManager
and in this JPanel there are severals JPanels. In particular, in a specific JPanel I've to draw lines and add at the end of these lines some JComponent
I've created.
In a nutshell, what I'm doing is something like this
JPanel p=new JPanel();
p.setLayout(null);
.....
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
......
g.drawLine(0,0,50,50);
JComponent s=new myJComponent();
s.setBounds(50,50,10,10);
this.add(s);
.......
}
My question, maybe a bit philosophical, is this: is using null layout correct in this specific context? I've not found any substitute for it because I add my component at the end of the line and this task must be done in paintComponent
method.
Thank you in advance for your tips.