Java:
public class TimeLimit extends JFrame {
private JPanel contentPane;
private JPasswordField passwordField;
private JTextPane txtpnPasswort;
private JPasswordField passwordField_1;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
TimeLimit frame = new TimeLimit();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public TimeLimit() {
JPanel contentPane;
setTitle("Time Limit");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setForeground(Color.RED);
contentPane.setBackground(Color.LIGHT_GRAY);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JTextPane txtpnBenutzername = new JTextPane();
txtpnBenutzername.setEditable(false);
txtpnBenutzername.setBackground(Color.LIGHT_GRAY);
txtpnBenutzername.setForeground(Color.BLACK);
txtpnBenutzername.setText("Benutzername:");
txtpnBenutzername.setBounds(79, 99, 93, 20);
contentPane.add(txtpnBenutzername);
passwordField = new JPasswordField();
passwordField.setBounds(182, 99, 118, 20);
contentPane.add(passwordField);
txtpnPasswort = new JTextPane();
txtpnPasswort.setForeground(Color.BLACK);
txtpnPasswort.setBackground(Color.LIGHT_GRAY);
txtpnPasswort.setText("Passwort:");
txtpnPasswort.setBounds(111, 130, 61, 20);
contentPane.add(txtpnPasswort);
passwordField_1 = new JPasswordField();
passwordField_1.setBounds(182, 130, 118, 20);
contentPane.add(passwordField_1);
JTextPane textPane = new JTextPane();
textPane.setEditable(false);
textPane.setBackground(Color.LIGHT_GRAY);
textPane.setForeground(Color.GRAY);
textPane.setBounds(0, 0, 79, 20);
contentPane.add(textPane);
}
public static void TimeDisplay(){
int count = 60;
while(count != 0){
try {
textPane.setText(String.valueOf(count));
count--;
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Fehlermeldung : Cannot resolve textPane
Wie behebe ich das?
Zuletzt bearbeitet von einem Moderator: