Reputation: 141
I have a JFrame
, inside which I have two JPanel
instances.
I have used repaint()
to paint the frame. But the problem is I want two different repaint()
for the two different panels.
Jpanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(image1); //image1 and image2 is of its own class type.
panel.add(image2);
frame.add(panel,BorderLayout.CENTER);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize((int)width*2, (int)height);
frame.setVisible(true);
frame.repaint();
I know, I haven't used repaint()
on the JPanel
,... help in this also.. I got minimal working using this.
Can we, just repaint()
on a particular JPanel
?
Upvotes: 0
Views: 539
Reputation: 347332
JFrame#repaint
will repaint the entire frame and it's contents.
JPanel#repaint
will repaint the instance of the panel and it's children.
This will work for all components as they inherit the repaint
from Component
Upvotes: 3