Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法在打印语句中打印选项卡_Java_Swing - Fatal编程技术网

Java 无法在打印语句中打印选项卡

Java 无法在打印语句中打印选项卡,java,swing,Java,Swing,我正在开发一个Java项目,需要在对话框中打印字符串。下面是代码片段 String businfo = "Busno" + "\t" + "Source" + "\t" + "Destination" + "\t" + "Date" + "\t" + "Fare" + "\n"; int n = TicketBooking.dis.readInt(); for(int i = 0 ; i < n; i++) { Bus b = (Bus)TicketBooking.ois.rea

我正在开发一个Java项目,需要在对话框中打印字符串。下面是代码片段

String businfo = "Busno" + "\t" + "Source" + "\t" + "Destination" + "\t" +  "Date" + "\t" + "Fare" + "\n";
int n = TicketBooking.dis.readInt();
for(int i = 0 ; i < n; i++) {
    Bus b = (Bus)TicketBooking.ois.readObject();
    businfo += b.busno + "\t" + b.source + "\t" + b.destination + "\t" + b.date + "\t" + b.fare + "\n";
}
JOptionPane.showMessageDialog(null,businfo);
String businfo=“Busno”+“\t”+“源”+“\t”+“目的地”+“\t”+“日期”+“\t”+“票价”+“\n”;
int n=TicketBooking.dis.readInt();
对于(int i=0;i


我打印的字符串没有选项卡。“\t”有什么问题?

JOptionPane.showMessageDialog(null,businfo)
更改为

JOptionPane.showMessageDialog(空,新JTextArea(businfo))


JOptionPane是一个GUI组件,因此您应该在其中放置另一个更适合处理文本的GUI组件,而不是原始字符串,这样格式就不会混乱。

我希望
System.out.println()
在读取
不在print语句中打印之后。