Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2007

Tip: Looking for answers? Try searching our database.

Why doesn't my JTable display

Thread view: 
wooks - 06 Jan 2007 06:07 GMT
I would appreciate some urgent assistance with this simple code.

When it run it displays a blank frame. What do I need to do to get the
JTable to display?

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;

public class RunFileMatcher extends JFrame {

  RunFileMatcher() {
     JFrame frame = new JFrame("MatchTable");
     frame.setSize(600,400);

     String[] columnNames = {"File", "Size"};
     String dataValues[][] =   {
        { "A", "234" },
        { "B", "43" },
        { "C", "89.2" },
        { "D", "9033" }
     };

     JTable table = new JTable(dataValues,columnNames);
     getContentPane().add(new JScrollPane(table), "Center");

     frame.setVisible( true );
     frame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );

  }
}
Andrew Thompson - 06 Jan 2007 06:32 GMT
> I would appreciate some urgent assistance

..have you considered urgently paying a consultant?

(I was going to have a look over it, but now I have
decided to see if any others are willing to conform
to your schedule, first - just out of morbid curiousity..)

Andrew T.
Daniel Pitts - 06 Jan 2007 06:37 GMT
> > I would appreciate some urgent assistance
>
[quoted text clipped - 5 lines]
>
> Andrew T.

I replied only because I am bored and enjoy this sort of thing.

Also, I didn't notice the "urgency", or I might have requested money
first :-).
wooks - 06 Jan 2007 09:23 GMT
> > I would appreciate some urgent assistance
>
> ..have you considered urgently paying a consultant?

Assuming I had would you have made enough from my simple problem to buy
a burger?
Luc The Perverse - 06 Jan 2007 10:59 GMT
>> > I would appreciate some urgent assistance
>>
>> ..have you considered urgently paying a consultant?
>
> Assuming I had would you have made enough from my simple problem to buy
> a burger?

Gimme a job or gimme charity

A burger is currently out of my price range.

I have a sign, "Will Program For Pennies (and by pennies I mean 12$/hr)"

--
LTP

:)
Lew - 06 Jan 2007 17:05 GMT
wooks wrote:
>> I would appreciate some urgent assistance

Andrew Thompson wrote:
> ..have you considered urgently paying a consultant?

wooks wrote:
> Assuming I had would you have made enough from my simple problem to buy
> a burger?

That depends on the urgency, not the simplicity, and on the price you are
willing to pay.

I would gladly solve your urgent problem for $20K U.S., and that'll buy the
burger stand.

- Lew
Daniel Pitts - 06 Jan 2007 06:35 GMT
> I would appreciate some urgent assistance with this simple code.
>
[quoted text clipped - 28 lines]
>    }
> }

Ah, heres the problem....
Your class RunFileMatcher extends JFrame, and therefor IS-A JFrame, you
also create a *different* JFrame object (JFrame frame = new JFrame()).
You set up the table and the frame, but you add the table to your
RunFileMatcher object instead of the JFrame you initialized.

change the line:
public class RunFileMatcher extends JFrame {
to
public class RunFileMatcher {

and the line
      getContentPane().add(new JScrollPane(table), "Center");
to
      frame.getContentPane().add(new JScrollPane(table),
BorderLayer.CENTER);
wooks - 06 Jan 2007 09:25 GMT
> > I would appreciate some urgent assistance with this simple code.
> >
[quoted text clipped - 45 lines]
>        frame.getContentPane().add(new JScrollPane(table),
> BorderLayer.CENTER);

Thank you ... it works. I'm on the last leg of some coursework that is
due on Monday, so now I can get on with the other bits.
Lew - 06 Jan 2007 17:07 GMT
>>> I would appreciate some urgent assistance with this simple code.

Daniel Pitts wrote:
>> change the line:
>>  public class RunFileMatcher extends JFrame {
[quoted text clipped - 9 lines]
> Thank you ... it works. I'm on the last leg of some coursework that is
> due on Monday, so now I can get on with the other bits.

Damn! There goes my $20K!

- Lew


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.