Results 1 to 3 of 3

Thread: Java Tables

  1. #1
    Join Date
    Mar 2010
    Posts
    23
    Rep Power
    0

    Post Java Tables

    :confused: I have searched a lot over jtable but didnt found any thing easy, please can you explain how can i make tables in java having column name defined and row have no data at all, and it has scroll when the size exceeds then given , also the row have no borders.

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by greatmajestics View Post
    :confused: I have searched a lot over jtable but didnt found any thing easy

    probably because this topic isn't easy. i don't know what your connotation of "easy" is but i got a easy example from here www.javabuch.de - Das Handbuch der Java-Programmierung

    save this code as Listing3804.java
    Java Code:
    /* Listing3804.java */
    
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class Listing3804
    extends JFrame
    implements TableData
    {
      public Listing3804()
      {
        super("JTable 1");
        setDefaultCloseOperation(EXIT_ON_CLOSE); // not originally
        JTable table = new JTable(DATA, COLHEADS);
        Container cp = getContentPane();
        cp.add(new JLabel("Alte c\'t-Ausgaben:"), BorderLayout.NORTH);
        cp.add(new JScrollPane(table), BorderLayout.CENTER);
      }
    
      public static void main(String[] args)
      {
        Listing3804 frame = new Listing3804();
        frame.setLocation(100, 100);
        frame.setSize(300, 200);
        frame.setVisible(true);
      }
    }
    save this code as TableData.java
    Java Code:
    /* TableData.java */
    
    public interface TableData
    {
      public static final String[][] DATA = {
        {" 1/1987", "195", "Vergleichstest EGA-Karten"},
        {" 2/1987", "171", "Schneider PC: Bewährungsprobe"},
        {" 3/1987", "235", "Luxus-Textsyteme im Vergleich"},
        {" 4/1987", "195", "Turbo BASIC"},
        {" 5/1987", "211", "640-K-Grenze durchbrochen"},
        {" 6/1987", "211", "Expertensysteme"},
        {" 7/1987", "199", "IBM Model 30 im Detail"},
        {" 8/1987", "211", "PAK-68: Tuning für 68000er"},
        {" 9/1987", "215", "Desktop Publishing"},
        {"10/1987", "279", "2,5 MByte im ST"},
        {"11/1987", "279", "Transputer-Praxis"},
        {"12/1987", "271", "Preiswert mit 24 Nadeln"},
        {" 1/1988", "247", "Schnelle 386er"},
        {" 2/1988", "231", "Hayes-kompatible Modems"},
        {" 3/1988", "295", "TOS/GEM auf 68020"},
        {" 4/1988", "263", "Projekt Super-EGA"},
        {" 5/1988", "263", "Neuheiten auf der CeBIT 88"},
        {" 6/1988", "231", "9600-Baud-Modem am Postnetz"}
      };
    
      public static final String[] COLHEADS = {
        "Ausgabe", "Seiten", "Titelthema"
      };
    }

    compile and run. the code above is very basically. the first file a jtable is instantiate and the second file defines the DATA and COLHEADS. very simple. feel free to ask.

  3. #3
    Join Date
    Mar 2010
    Posts
    23
    Rep Power
    0

Similar Threads

  1. Replies: 2
    Last Post: 01-27-2010, 09:28 AM
  2. Java classes representing DB tables
    By aa74 in forum Advanced Java
    Replies: 1
    Last Post: 06-20-2008, 10:06 PM
  3. Help Printing Tables
    By ogidantunde in forum Advanced Java
    Replies: 0
    Last Post: 06-14-2008, 07:34 PM
  4. caching the tables
    By jayashree in forum JDBC
    Replies: 0
    Last Post: 01-30-2008, 07:43 AM
  5. Updating into 2 tables in the DB
    By yuchuang in forum New To Java
    Replies: 2
    Last Post: 05-12-2007, 07:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •