所以,我正在使用Java和JFrame,我希望最终用户能够点击“登录”按钮,它应该显示另一个说“编辑”。由于某些奇怪的原因,当最终用户点击“登录”时,它没有显示“编辑”框,但它显示“System.out.println”
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main extends JFrame{
public void fixtureList()
{
JButton editButton;
editButton = new JButton("Edit");
editButton.setBounds(100, 200, 100, 100);
add(editButton);
}
public void loginPanel()
{
setLayout(null);
JButton loginButton;
loginButton = new JButton("Login");
loginButton.setBounds(10, 10, 100, 100);
add(loginButton);
loginButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//Execute when button is pressed
fixtureList();
System.out.println("Loading the fixtures screen");
}
});
}
public static void main(String[] args)
{
Main window = new Main();
window.setTitle("PE Fixtures v1.0");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setSize(250, 430);
window.loginPanel();
window.getContentPane().setBackground(new Color(53, 56, 64));
window.setVisible(true);
}
}
答案 0 :(得分:0)
在repaint
ActionListener
public void actionPerformed(ActionEvent e)
{
//Execute when button is pressed
fixtureList();
System.out.println("Loading the fixtures screen");
repaint();
}