英文:
Insertion of a JLabel in a container
问题
import java.awt.*;
import javax.swing.*;
public class Esercizio7 {
public static void main(String[] v){
JFrame f = new JFrame("Prenota il tuo biglietto!");
Container c = f.getContentPane();
JPanel panel = new JPanel();
c.add(panel);
f.setSize(new Dimension(500,350));
f.show();
}
}
public class Testo extends JPanel {
public Testo(){
super();
JLabel l = new JLabel("srgsgsrg");
add(l);
}
}
英文:
I have to create a window with a graphical interface in Java using Swing. Here I have tried to maximize and rename the window and this works. The problem is that then I tried to insert a JLabel but nothing is seen, why?
package esercizio7;
import java.awt.*;
import javax.swing.*;
public class Esercizio7 {
public static void main(String[] v){
JFrame f = new JFrame("Prenota il tuo biglietto!");
Container c = f.getContentPane();
JPanel panel = new JPanel();
c.add(panel);
f.setSize(new Dimension(500,350));
f.show();
}}
public class testo extends JPanel {
public testo(){
super();
JLabel l = new JLabel("srgsgsrg");
add(l);}}
专注分享java语言的经验与见解,让所有开发者获益!
评论