package hayashi.yuu.register; import javax.swing.ImageIcon; import javax.swing.JLabel; import java.awt.Font; import java.awt.GridLayout; public class StartModePanel extends MainPanel { /** * コンストラクタ * @param touchScreen 親フレーム */ public StartModePanel(TouchScreen touchScreen) { super(); this.parent = touchScreen; setParentFrame(touchScreen); this.setSize(800, 300); this.setLayout(new GridLayout(2, 1)); img = true; imageon = new JLabel(new ImageIcon("lib/card.gif")); imageoff = new JLabel(); imageLabel = imageon; this.add(imageLabel); text = new JLabel("IDカードをかざしてください。", JLabel.CENTER); text.setFont(new Font("MS PGothic", Font.BOLD, 18)); this.add(text); } public void run() { while(true) { if (img) { //this.remove(imageon); imageLabel = imageoff; //this.remove(text); parent.repaint(); this.setVisible(true); img = false; try { Thread.sleep(300); } catch (InterruptedException e) {} } else { // this.add(imageon); imageLabel = imageon; //this.add(text); parent.repaint(); imageon.setVisible(true); img = true; try { Thread.sleep(1000); } catch (InterruptedException e) {} } } } TouchScreen parent; JLabel imageLabel; JLabel imageon; JLabel imageoff; JLabel text; boolean img = false; }