Powiel możliwe:
Java GUI repaint() problem?repaint() w Javie
napisać kod Java, ale mam problemy z problemem GUI. Kiedy dodaję komponent do obiektu JFrame, wówczas wywoływam metodę repaint() w celu aktualizacji GUI, ale to nie działa. Ale kiedy minimalizuję lub zmieniam rozmiar tej ramki, GUI jest aktualizowany.
Oto mój kod:
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setSize(460, 500);
frame.setTitle("Circles generator");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
String input = JOptionPane.showInputDialog("Enter n:");
int n = Integer.parseInt(input);
CircleComponent component = new CircleComponent(n);
frame.add(component);
component.repaint();
}
spróbuj 'frame.repaint();'? – Sheriff