add component to jpanel on runtime
问题 I have a JPanel and JButton on the JFrame . on runtime add JLabel to JPanel When click JButton . I use of the following code: panel.setLayout(null); jLabel _lbl=new jLabel(); _lbl.setText("Label"); panel.add(_lbl); panel.validate(); but no display any JLabel in JPanel . 回答1: I see you create a JLabel called _lbl : JLabel _lbl=new JLabel(); but you never add it to your panel. Instead you add a new JLabel with no text to your panel: panel.add(new JLabel()); This would ofcourse construct an