[求助]预览选中的颜色为什么必须要实现paintComponent(Graphics g)方法?
请教~调用JColorChooser.setPreviewPanel(new PrePanel());方法class PrePanel extends JPanel
{
PrePanel()
{
this.setPreferredSize(new Dimension(300,100));
this.setBorder(BorderFactory.createRaisedBevelBorder());
}
public void paintComponent(Graphics g) //为什么要必须实现这个方法才能显示出选中的颜色?这方法是被谁调用的?
{
Dimension size = getSize();
g.setColor(getForeground());
g.fillRect(0,0,size.width,size.height);
}
}
---------------------