ksidhmm
2022-06-24 11:22
采纳率: 100%
浏览 6

想创建一个音乐的表格,但是显示不出来,求解答,如何解决?

想创建一个音乐的数据库表格,但是表格显示不出来,求解答
package music;
import java.awt.;
import java.awt.event.
;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
public class music_manage extends JFrame implements ActionListener{
private JTable table = null;
private JButton btnAdd = new JButton("增加");
private JButton btnDelete = new JButton("删除");
private JButton btnSource = new JButton("查找");
private JButton btnRevise = new JButton("修改");
private JButton btnMusic = new JButton("歌曲信息");
private MusicDao cDao=new MusicDao();
private JTextField txtName=new JTextField(10);
private JTextField txtLanguage=new JTextField(10);
private JTextField txtCategory=new JTextField(10);
private JTextField txtSinger=new JTextField(10);
private JTextField txtId=new JTextField(10);
private JTextField txtWord=new JTextField(20);
private JLabel lblWord=new JLabel("关键字");
private JLabel lblSource=new JLabel("查询");
private JLabel lblName=new JLabel("歌名");
private JLabel lblLanguage=new JLabel("语言");
private JLabel lblCategory=new JLabel("种类");
private JLabel lblSinger=new JLabel("歌手");
private JLabel lblId=new JLabel("id");
private JRadioButton RadioButtonName = new JRadioButton("歌名");
private JRadioButton RadioButtonLanguage = new JRadioButton("语言");
private JRadioButton RadioButtonCategory = new JRadioButton("种类");
private JRadioButton RadioButtonSinger = new JRadioButton("歌手");
private String[] cols = { "id", "歌名", "语言","类别","歌手"};

private void initTable() {
    
    String[][] rows = new String[30][5];
    table = new JTable(rows, cols);
}

public music_manage() {
    JPanel panel = (JPanel) this.getContentPane();
    initTable();
    JScrollPane jspTable = new JScrollPane(table);
    panel.add(jspTable);
    JPanel jpTop = new JPanel();
    JPanel jpCenter = new JPanel();
    JPanel jpunder=new JPanel();
    jpTop.add(btnMusic);
    jpTop.add(lblWord);
    jpTop.add(txtWord);
    jpTop.add(btnSource);
    jpCenter.add(lblSource);
    jpCenter.add(RadioButtonName);
    jpCenter.add(RadioButtonLanguage);
    jpCenter.add(RadioButtonCategory);
    jpCenter.add(RadioButtonSinger);
    jpunder.add(lblId);
    jpunder.add(txtId);
    jpunder.add(lblName);
    jpunder.add(txtName);
    jpunder.add(lblLanguage);
    jpunder.add(txtLanguage);
    jpunder.add(lblCategory);
    jpunder.add(txtCategory);
    jpunder.add(lblSinger);
    jpunder.add(txtSinger);
    jpunder.add(btnAdd);
    jpunder.add(btnRevise);
    jpunder.add(btnDelete);
    panel.add(jpTop, BorderLayout.NORTH);
    panel.add(jpCenter, BorderLayout.CENTER);
    panel.add(jpunder, BorderLayout.SOUTH);
    btnSource.addActionListener(this);
    btnAdd.addActionListener(this);
    btnRevise.addActionListener(this);
    btnDelete.addActionListener(this);
    btnMusic.addActionListener(this);
    this.setTitle("歌曲管理");
    this.setSize(1000, 500);
    this.setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    
}

public static void main(String[] args) {
    JFrame.setDefaultLookAndFeelDecorated(true);
    new music_manage();
}

img

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

相关推荐 更多相似问题