Results 1 to 6 of 6

Thread: JTable help

  1. #1
    FFEJ is offline Member
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Default JTable help

    I am trying to make a JTable (It doesn't need to be a JTable but as far as I know it's the only thing I can use) My program is taking some inputs and it's suppose to make a output every time I click the add room button and all the previous output stay and aren't overwritten.


    Here is kind of how my programs works:

    Room Name: <--input
    length: <--input
    width <--input
    Room Price: <--input

    Total (room name + " " + length "x" + width + " " + room price); <--output
    Total (room name + " " + length "x" + width + " " + room price); <--output
    Total (room name + " " + length "x" + width + " " + room price); <--output

    This is also happening in a GUI and I have no idea to use JTable (this is suppose to be for a review assignment but our previous teacher never taught us this) so if someone could please tell me how to use JTable properly and how to use it in my code. Thanks and advance and let me know if you need more information.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    FFEJ is offline Member
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Default

    Thanks I actually was able to solve it by myself but I have a new problem >_>.

    I am trying to clear the JTable in a if statement

    (so if the user inputs something that is incorrect.)

  4. #4
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default

    I have no idea why you would want to clear a JTable if a user inputs something wrong. You can only edit one cell at a time.

    So I don't understand the context of your question.

    If you need more help then don't forget to post a SSCCE with your question.

  5. #5
    FFEJ is offline Member
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Default

    Well i'm suppose to make it so the user starts over, is there anyway to either clear the table completly or restart the program without actually running it up again?

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Sure, you could "clear" a JTable by giving it a new TableModel object, or by clearing out the rows of the current model. I think that one way to do this may even be to set the model's rowCount to 0 (though I'm guessing here), though I bow to camickr's expertise in Swing issues. Again, if you create and post an SSCCE (see the link above), we'll have a better idea of what you're trying to do.

Similar Threads

  1. Jtable
    By prashant in forum Java Applets
    Replies: 0
    Last Post: 07-19-2009, 07:04 PM
  2. Add a row in JTable
    By makpandian in forum AWT / Swing
    Replies: 4
    Last Post: 04-15-2009, 08:48 PM
  3. Regarding the JTable
    By suresh.uvce in forum AWT / Swing
    Replies: 5
    Last Post: 02-11-2009, 06:46 AM
  4. Replies: 2
    Last Post: 05-15-2008, 10:15 AM
  5. Help with JTable
    By fernando in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 06:57 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
  •