Code:
Wie schreibe ich einen visuellen Countdown von 30 sekunden und lasse ihn oben in der linken
Ecke erscheinen ?
Java:
@SuppressWarnings({ "serial", "unused" })
public class TextProgramm extends JFrame {
private final Action action = new SwingAction();
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
TextProgramm frame = new TextProgramm();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public TextProgramm() {
getContentPane().setBackground(UIManager.getColor("controlHighlight"));
getContentPane().setForeground(Color.BLACK);
getContentPane().setLayout(null);
JTextPane txtpnAsdasd = new JTextPane();
txtpnAsdasd.setBackground(UIManager.getColor("control"));
txtpnAsdasd.setFont(new Font("Arial", Font.BOLD, 18));
txtpnAsdasd.setBounds(0, 0, 484, 441);
getContentPane().add(txtpnAsdasd);
setTitle("Text Editor");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500, 500);
setLocationRelativeTo(null);
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
JMenu mnDatei = new JMenu("Datei ");
menuBar.add(mnDatei);
JMenu mnSave = new JMenu("Save");
mnDatei.add(mnSave);
JMenu mnColor = new JMenu("Color");
menuBar.add(mnColor);
JMenu mnRed = new JMenu("Red");
mnRed.setAction(action);
mnColor.add(mnRed);
JMenu mnBlue = new JMenu("Blue");
mnColor.add(mnBlue);
JMenu mnGreen = new JMenu("Green");
mnColor.add(mnGreen);
}
private class SwingAction extends AbstractAction {
public SwingAction() {
putValue(NAME, "SwingAction");
putValue(SHORT_DESCRIPTION, "Some short description");
}
public void actionPerformed(ActionEvent e) {
setForeground(getBackground());
}
}
}
Wie schreibe ich einen visuellen Countdown von 30 sekunden und lasse ihn oben in der linken
Ecke erscheinen ?
Zuletzt bearbeitet von einem Moderator: