Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Custom Component in JTable with Customer Renderer and Cell Editor Help.

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Custom Component in JTable with Customer Renderer and Cell Editor Help.

    Hello, I am trying to create an inventory type program in which I have a JTable that lists all of the stock. The last column in the table will have 2 buttons and a textfield that will be used to either add or take stock away from the list. All of the data is being filled via a database.

    2014-07-22_0736.jpg

    The problem that I am having is that when I add or subtract using the buttons, the correct numbers show up in the textfield but when I go to the next row or another row, the previous textfield reverts back to 0(default) and the count that I had in the first textfield is carried over to the next row etc. I need to be able to add values to each row, and have the table remember those particular numbers.

    I have spent 2 days on this and still cannot figure it out, so I am just wondering if anybody has any ideas or can help me solve this issue. Basically the way I have my code setup is I have a custom component class which creates the 2 buttons and text field and adds them to a panel.

    I then have a custom cell editor and renderer...unfortunately I cannot post my code it says its denied and won't let me post it.

    Any help or advice would be greatly appreciated.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Custom Component in JTable with Customer Renderer and Cell Editor Help.

    If you want help, you'll have to provide an MCVE that demonstrates the problem. Note that this shouldn't be your whole project, just enough code that we can copy and paste to run ourselves.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Jul 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Custom Component in JTable with Customer Renderer and Cell Editor Help.

    Alright sure makes sense, I have attached my whole project that has been simplified.

    Thanks

    Nate
    Attached Files Attached Files

Similar Threads

  1. How to make a custom swing component
    By GoodbyeWorld in forum AWT / Java Swing
    Replies: 3
    Last Post: May 21st, 2014, 12:55 PM
  2. How to make a custom swing component
    By GoodbyeWorld in forum What's Wrong With My Code?
    Replies: 0
    Last Post: May 19th, 2014, 10:24 PM
  3. [SOLVED] Apply a renderer on a cell of a JTable
    By Ben03 in forum AWT / Java Swing
    Replies: 5
    Last Post: May 9th, 2014, 07:15 AM
  4. How to create a custom Swing Component?
    By Pahulja7 in forum AWT / Java Swing
    Replies: 1
    Last Post: November 25th, 2011, 10:55 AM
  5. Table cell renderer
    By dibyayan in forum AWT / Java Swing
    Replies: 1
    Last Post: October 17th, 2011, 07:34 AM

Tags for this Thread