你好我試圖讓我在哪裏試圖使JButton的左下方我沒有下面的代碼我不知道我錯了,我的代碼備註工作如何設置流量佈局?
這裏Java桌面應用程序是我的代碼
import java.awt.*;
import java.awt.event.*;
import javax.imageio.ImageIO;
import javax.swing.*;
new complete code
public class ApplicationCloseExample
{
private JButton[] buttons;
private void displayGUI()
{
final JFrame frame = new JFrame("Application Close Example");
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
for (int i = 5; i < 8; i++) {
buttons[i] = new JButton(Integer.toString(i));
bottomPanel.add(buttons[i]);
}
// JButton button = new JButton("Comment");
// bottomPanel.add(button);
// frame.getContentPane().add(contentPane, BorderLayout.CENTER);
frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true);
}
public static void main(String... args)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new ApplicationCloseExample().displayGUI();
}
});
}
}
我該如何做到這一點
究竟是不是你的代碼工作?我唯一能猜到的是按鈕數組沒有正確初始化。 – Jack
拋出異常空指針 – user3456343
和我initilised數組像這個私人jButton []按鈕; – user3456343