java的JTextArea里怎么能把文字方向改变

2024-12-30 23:34:04
推荐回答(2个)
回答1:

如果输出多行,建议不要用JTextArea和JTextArea,你可以用JTable试试,我做的个图书管理就用的这个来显示查询出来的书籍,感觉比较好排,而且还可以接收鼠标消息,如响应右键等。

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JTable;

class Test extends JFrame{
public static String[][] bookTableData = new String[3][6];
{
for (int i = 0; i < bookTableData.length; i++) {
bookTableData[i] = new String[]{"1","JAVA","雷名","25.6","张三","2008/12/11"};
}
}

private static String[] bookTableName = new String[] { "图书编号", "图书名", "图书作者",
"图书价格", "借书人", "借出日期" };

private static JTable bookTable = new JTable(bookTableData, bookTableName);

Test(){
this.setLayout(new BorderLayout());
this.add(bookTable,BorderLayout.NORTH);

this.setBounds(0,0,500,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}

public static void main(String[] args) {
new Test();
}

}

回答2:

差不多就是这样