我正在做我的第一个项目。当我试图转到新行时,string.format它以某种方式失败了(要么根本不打印,要么在同一行打印)。
这是代码:
String reciept = String.format("Recipt number #16424 +" + "%n" + "Beef Burgers :" + ab1 +"%n" + "Cheese Burgers :" + ab2 + "%n" + "Fish and Chips :" + ab3 + "%n" + "French Fries :" + ab5 + "%n" + "Steak :" + ab4 + "%n" + "Sprite Drinks : " + ab + "%n" + "Soda Drinks : " + ab8 + "%n" + "Fuzetea Drinks : " + ab7 + "%n" + "Coke Drinks :" + ab6 + "%n" , ab,ab1,ab2,ab3,ab4,ab5,ab6,ab7,ab8);
recieptText.setText(reciept);
还有 1 个问题。我正在尝试创建JButton出口。我试图打开一条消息,说如果我确定退出然后退出,但我失败了,所以我尝试了注册,如果他按下退出,它将退出,我也失败了。
JButton btnExit = new JButton("Exit");
btnExit.setFont(new Font("Tahoma", Font.PLAIN, 19));
btnExit.setBounds(766, 484, 127, 39);
if (btnExit.isSelected()==true) {
System.exit(0);
}
frame.getContentPane().add(btnExit);
跃然一笑
相关分类