JFrame と JPanel の使用に問題があります。私のコード全体を以下に示します。
class GUIExample
{
public static void main(String args[])
{
//Creating the frame
JFrame frame=new JFrame("Chat Frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,400);
frame.setLocationRelativeTo(null);
frame.setDefaultLookAndFeelDecorated(true);
frame.setLayout(new FlowLayout());
//Creating data panel and a label and a text box
JPanel dataPanel=new JPanel();
dataPanel.setLayout(new FlowLayout());
dataPanel.setLocation(0,0);
dataPanel.setOpaque(true);
dataPanel.setBackground(Color.WHITE);
dataPanel.setSize(200,200);
JLabel lblName=new JLabel("Enter Text: ");
lblName.setLayout(new FlowLayout());
lblName.setBounds(0, 10, 2, 2);
dataPanel.add(lblName);
frame.add(dataPanel);
frame.setVisible(true);
}
}
プログラムで何が起こっているのか助けてください