java panel.add_java panel.add 类外函数为啥失效?

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

public class DataM extends JFrame{

public DataM() {

getContentPane().setLayout(new BorderLayout(0, 0));

Panel panel = new Panel();

getContentPane().add(panel, BorderLayout.NORTH);

JLabel label = new JLabel("\u5FAE\u535A\u7C89\u4E1D\u5206\u6790");

label.setFont(new Font("宋体", Font.BOLD, 18));

panel.add(label);

Panel panel_1 = new Panel();

getContentPane().add(panel_1, BorderLayout.WEST);

JLabel lblNewLabel = new JLabel("");

lblNewLabel.setIcon(new ImageIcon("C:\\Users\\Administrator\\Desktop\\230.jpg"));

panel_1.add(lblNewLabel);

Panel panel_2 = new Panel();

getContentPane().add(panel_2, BorderLayout.EAST);

JLabel lblNewLabel_1 = new JLabel("");

lblNewLabel_1.setIcon(new ImageIcon("C:\\Users\\Administrator\\Desktop\\gp=0.jpg"));

panel_2.add(lblNewLabel_1);

JPanel panel_3 = new JPanel();

getContentPane().add(panel_3, BorderLayout.CENTER);

panel_3.setLayout(new GridLayout(1, 0, 0, 0));

ShowFont s1 = new ShowFont("Shopping");

Panel panel_4 = new Panel();

panel_4.add("center",s1);

panel_3.add(panel_4);

ShowFont s2 = new ShowFont("Shopping");

Panel panel_5 = new Panel();

panel_5.add("center",s2);

panel_3.add(panel_5);

}

如题ShowFont是类外的函数,但在同一工程里。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值