0

Could you please suggest database grid component that allows to save or load column layout (things like sequence, names, width) to/from files.

I am also interested in an approach that would allow to implement this functionality using standard library.

Charles
  • 50,943
  • 13
  • 104
  • 142
Cybex
  • 481
  • 1
  • 6
  • 29

2 Answers2

1

The Delphi ecosystem is a bit different from Java. First, Delphi is pretty much an integrated tool so the components out there are wide-ranging and very data-centric. Java is a much larger ecosystem and it is far more focused on data-structures which you can read and write to from the GUI.

That being said, yes, there are a lot of grids out there. In Java it is a JTable in Swing and a TableView in JavaFX2 (arguably the new Swing). Swing is mature and has a horde of tables available for it, but in my experience it is easier to just write a custom JTable and work from there. The Java tutorials will get you up and running.

The long and short here is you don't need a component that is provided, but you can build one yourself (probably in less than a couple hours if you're proficient), probably a couple days making mistakes if you're not.

If you really are looking for an "out of the box" solution that feels more like Delphi then I recommend: http://www.jidesoft.com/products/grids.htm

Honestly getting a JTable up and rolling and building a TableModel is a very simple task. I'd recommend doing it as you're going to need to think differently in Swing. If you're willing to try something with less support JavaFX 2 is definitely more flexible. As to your comment about column orders etc... all of these approaches support doing that. In swing you can look at the TableColumnModel.

Daniel B. Chapman
  • 4,647
  • 32
  • 42
  • I think you misunderstood my question, getting grid and adding TableModel is not a problem - JTable itself is already a pretty good solution. Main thing that I miss in it is the layout-related functionality. Thanks for the link, I'll check it. – Cybex Sep 15 '12 at 14:49
  • Its all there--if you're not tied to Swing JavaFX does have most of the support DataGrids had built in. It is a little Callback heavy, but the API is much easier that Swings. – Daniel B. Chapman Sep 15 '12 at 15:28
  • This is a desktop application, so yeah, I am pretty much tied with Swing. I am thinking about trying Preferences API, though. Have seen some solutions using it. – Cybex Sep 15 '12 at 17:04
  • @Cybex, I just ported a Swing framework to JavaFX 2 (shipping with Oracle JDK 1.7_05 I think). You might give it a shot, rendering is much faster and the L&F is easier. While I really like Swing, if you don't have a huge amount of tech-debt moving forward might be easier. I'd recommend the 8 hours to play around with it. – Daniel B. Chapman Sep 15 '12 at 18:33
  • Daniel, thanks, I think I'll try to play with JavaFX to see if it suits. – Cybex Sep 15 '12 at 20:29
1

I can also check Open Swing Framework