java jtable 添加表头_求教 jtable添加表头的语句位置

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

package java1_1;

import java.awt.BorderLayout;

import java.awt.EventQueue;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.border.EmptyBorder;

import javax.swing.JLabel;

import javax.swing.JTable;

import javax.swing.table.JTableHeader;

import javax.swing.JScrollPane;

import javax.swing.table.DefaultTableModel;

import javax.swing.JTextPane;

import java.awt.SystemColor;

import javax.swing.JButton;

import java.awt.event.ActionListener;

import java.awt.event.ActionEvent;

public class UI3 extends JFrame {

private JPanel contentPane;

private JTable table;

/**

* Launch the application.

*/

public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {

public void run() {

try {

UI3 frame = new UI3();

frame.setVisible(true);

} catch (Exception e) {

e.printStackTrace();

}

}

});

}

/**

* Create the frame.

*/

public UI3() {

setTitle("\u5B66\u751F\u8BFE\u8868\u67E5\u8BE2");

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setBounds(100, 100, 504, 408);

contentPane = new JPanel();

contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

// contentPane.setLayout(new BorderLayout(0, 0));

contentPane.setLayout(null);

setContentPane(contentPane);

table = new JTable();

JFrame content = new JFrame();

table.setColumnSelectionAllowed(true);

table.setCellSelectionEnabled(true);

table.setModel(new DefaultTableModel(new Object[][] {}, new String[] {

"New column", "New column", "New column", "New column",

"New column" }));

table.setBounds(10, 92, 474, 240);

contentPane.add(table);

JLabel label = new JLabel("\u59D3\u540D\uFF1A\u67D0\u67D0");

label.setBounds(11, 25, 121, 15);

contentPane.add(label);

JLabel label_1 = new JLabel("\u5E74\u7EA7\uFF1A2016\u7EA7");

label_1.setBounds(11, 67, 102, 15);

contentPane.add(label_1);

JLabel label_2 = new JLabel(

"\u5B66\u9662\uFF1A\u56FD\u9645\u4EA4\u6D41\u5B66\u9662");

label_2.setBounds(239, 21, 125, 15);

contentPane.add(label_2);

JLabel label_3 = new JLabel(

"\u4E13\u4E1A\uFF1A\u8BA1\u7B97\u673A\u79D1\u5B66\u4E0E\u6280\u672F");

label_3.setBounds(239, 67, 147, 15);

contentPane.add(label_3);

JButton button = new JButton("\u9000\u51FA");

button.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

System.exit(0);

}

});

button.setBounds(372, 342, 93, 23);

contentPane.add(button);

JButton button_1 = new JButton("\u8FD4\u56DE");

button_1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

UI2 mf = new UI2();

mf.setVisible(true);

contentPane.setVisible(false);

}

});

button_1.setBounds(259, 342, 93, 23);

contentPane.add(button_1);

}

}收起求教大神JScrollPane这个语句在哪个位置添加呢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值