L
Leo Smith
Dear All,
I am writing a subclass of JPanel(subclass name: JPanelClickagble). This
new class has a linkedlist, which contains objects of class Rectangle.
Suppose right now, the linkedlist containes two objects of Rectangle and
the panel displays the two rectangles(flowlayout manager). If I made
each rectangle 10 times higher, 10 times wider in a method:
public void enLarge() {
while (i.hasNext()) {
i.next().height *= 10; //rectangle’s height increase by 10
i.next().width *= 10; //width increases by 10 times
} //end of while loop
????
}
How can I make my panel display the enlarged two rectangles? Should I
remove all the old two rectangles first? I know how to add an object to
a panel, I don't know how to remove an object from a panel. Or something
repaint() method will update its size?
Thank you.
I am writing a subclass of JPanel(subclass name: JPanelClickagble). This
new class has a linkedlist, which contains objects of class Rectangle.
Suppose right now, the linkedlist containes two objects of Rectangle and
the panel displays the two rectangles(flowlayout manager). If I made
each rectangle 10 times higher, 10 times wider in a method:
public void enLarge() {
while (i.hasNext()) {
i.next().height *= 10; //rectangle’s height increase by 10
i.next().width *= 10; //width increases by 10 times
} //end of while loop
????
}
How can I make my panel display the enlarged two rectangles? Should I
remove all the old two rectangles first? I know how to add an object to
a panel, I don't know how to remove an object from a panel. Or something
repaint() method will update its size?
Thank you.