Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JTable, JButton, Renderer, Editor... how to use all of this at once?

Status
Not open for further replies.

frag

Programmer
Dec 7, 2000
321
GB
Hi!

It seams that my problem is a very common one but I am just too stupid to get it solved.

What I want to have is a JTable with JButtons in one row.
That's no problem (hm... okay it was / is a problem) after searching half of the internet for examples. I found one that really worked but not the way I want it. The buttons just should throw an ActionEvent that I can catch in my main class (extends JFrame) and then the table's row to which this button blongs should be deleted.

I managed to do this with the example I found but tried to remove the row within the getCellEditorValue() of the "ButtonEditor" class (extends DefaultCellEditor). As a result I got an ArrayIndexOutOfBounceException.

I am really fishing in the dark here. Why is it the use of JTable that complicated?

Summary:
I need an implementation of JTable with a constructor that eats vectors for headers and data and holds a row of 'delete'-buttons that can remove 'their row'.

I know that this can be done but either I am to stupid or I am having a blockade. However... I hope that there is someone out there who can give me a working and transparent solution of what I need?!

The more I work with swing the more I hate it... this doesn't make any fun at all. :-(

Cheers

frag

patrick.metz@epost.de
 
These are all common problems solved by programmers every day. There are always aspects of UI’s that get sticky. Knowing OOAD and Patterns helps tremendously. Generally the level of difficulty is directly related with ones knowledge and experience with the technology in question. As one becomes more skilled and experienced these mundane tasks become simple. For most of us it is a matter of putting in the time and learning.

If you find developing code so distasteful you could look for a high level commercial tool that generates most of it for you. Or if none exist in Java you could limit your self to other high level languages and IDE’s that do, like VB, Delphi and .NET with Visual Studio.


-pete
 
@palbano:
I do not find developing code distasteful... I just hate developing GUIs with swing (oh, ok... and using date and time). ;-)
 
frag,

A trend in software development is that when economy is good and everybody is making huge profits, development is done in lower level languages and hype stuff. When economy is going worse, development shifts back to higher level languages (4GL, UML, code generation,...).

If you are used to a 4GL (or a 3GL on an AS/400), going back to a 2,5GL like java, Gui-development can be a pain from a productivity point of view.

I think you have to make a paradigm shift : If your boss wants you to code in java, you better make that you love it. The best way to do this is, (like palbano mentioned) to learn as much as you can about java and Swing.

[ But if economy keeps going down, 4GL and generators will come back. ]

Don't worry, be happy.

PS : How are the buttons in your table doing?
 
hologram,

thank you for sending me the examples. I wanted to have a look at them today... so I forwarded your mail to my office but our mailserver has some problems today and the mail did not yet arrive. ;-) I will let you know if I get the buttons to work.

Btw... I have another problem. I set the look&feel for the GUI with:

Code:
   // set GUI look and feel depending on operating system
   try{
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   }
   catch(Exception exception){
    System.out.println("Could not load desired look&feel for GUI... using default look&feel");
   }

The strange thing is that the scrollbars of my two JScrollPanes look different. I have a JTextArea in one of them and a JTable (yeah, the one with the buttons) in the other. However the scrollbars for the JTable look like they should do (like the normal scrollbars in window) but the scrollbars of the JTextField looks like they are metal-look&feel. I just wonder how this can happen.... have I used the UIManager in the wrong way?

Cheers

frag

patrick.metz@epost.de
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top