Displaying JTable in JFrame

后端 未结 2 524
再見小時候
再見小時候 2021-01-14 19:00

What i want to do:

I want to list some records of a database. This list should be displayed in a JFrame popup.

Description:

2条回答
  •  被撕碎了的回忆
    2021-01-14 19:02

    You do not need to write so many lines of code to display a file. Just download the jar file rs2xml and add it to your project library.

    Note: This will be useful if you are using netbeans

    How to use it?

    • Create the table in backend
    • Download rs2xml jar file
    • Add it to the project library
    • Drag the JTable from the swing controls to your JFrame
    • Now write the following code as follows:

    Write your query:

        ps=con.prepareStatement("select * from register");       
        ResultSet r=ps.executeQuery();
        jTable1.setModel(DbUtils.resultSetToTableModel(r)); //display the register
    

提交回复
热议问题