java JTable 表头无法显示
importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.util.*;publicc...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Test4 extends JFrame{
private JPanel panA;
private ScrollPane panB;
private JLabel lab;
private JTextField day;
private JButton button;
private JTable table;
//
Test4 (){
panA=new JPanel();
panA.setLayout(null);
panA.setSize(800,100);
lab=new JLabel("输入日期");
lab.setBounds(200,40,100,20);
day=new JTextField(20);
day.setBounds(250,40,200,20);
button=new JButton("搜索");
button.setBounds(470,40,50,20);
panA.add(lab);
panA.add(day);
panA.add(button);
//
panB=new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
panB.setSize(800,500);
table = new JTable(new String[][]{{"01","《JAVA编程思想》","**出版社"},{"02","《精通NetBeans》","**出版社"}},new String[]{"图书编号","图书名称","出版社名"});
table.setRowHeight(20);
table.setBounds(0,0,800,350);
panB.add(table);
//
add(panA);
panA.setBounds(0,0,800,100);
add(panB);
panB.setBounds(0,100,800,700);
setBounds(100,100,800,600);
setLayout(null);
setVisible(true);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
validate();
}
public static void main(String args[]){
new Test4();
}
} 展开
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Test4 extends JFrame{
private JPanel panA;
private ScrollPane panB;
private JLabel lab;
private JTextField day;
private JButton button;
private JTable table;
//
Test4 (){
panA=new JPanel();
panA.setLayout(null);
panA.setSize(800,100);
lab=new JLabel("输入日期");
lab.setBounds(200,40,100,20);
day=new JTextField(20);
day.setBounds(250,40,200,20);
button=new JButton("搜索");
button.setBounds(470,40,50,20);
panA.add(lab);
panA.add(day);
panA.add(button);
//
panB=new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
panB.setSize(800,500);
table = new JTable(new String[][]{{"01","《JAVA编程思想》","**出版社"},{"02","《精通NetBeans》","**出版社"}},new String[]{"图书编号","图书名称","出版社名"});
table.setRowHeight(20);
table.setBounds(0,0,800,350);
panB.add(table);
//
add(panA);
panA.setBounds(0,0,800,100);
add(panB);
panB.setBounds(0,100,800,700);
setBounds(100,100,800,600);
setLayout(null);
setVisible(true);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
validate();
}
public static void main(String args[]){
new Test4();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询