public class myClock extends JFrame implements Runnable {
static myClock cl = new myClock();
static Thread thrd = new Thread(cl);
public static void main(String[] args) {
cl.setVisible(true);
thrd.start();
}
public void run() {
while(true) {
repaint();
try {
thrd.sleep(1000);
} catch(InterruptedException e) {
e.printStackTrace();
}
}
}
class GPanel extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawString("test", 80, 40);
}
}
myClock() {
setSize(240, 70);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
add(new GPanel(), BorderLayout.CENTER);
}
}
Java入門・初心者質問スレ Part.8
■ このスレッドは過去ログ倉庫に格納されています
481デフォルトの名無しさん (ワッチョイ e3b3-+ow7 [219.210.104.7])
2018/09/19(水) 07:32:22.29ID:9j05f62H0■ このスレッドは過去ログ倉庫に格納されています
