• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Alignment format on JTable

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm working on GUI part now. I created my own TableModel class say, FlightTableModel, by extending AbstractTableModel interface. Since I use DataInfo[] to hold the data in FlightTableModel and DataInfo holds a String array. So, all the data display on JTable will be String type and will be left aligned. I feel uncomfortable everytime I saw the Price and AvailableSeats data are left aligned.
Could you please tell me what did you realize the right alignment? Or just let it be left?
Thank you for your help.
May
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For this assignment, you can do it simply by overiding the method "public Class getColumnClass(int columnIndex)" and returing Integer.class for the column index in question and String.class for the rest.
 
May Wong
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rajesh,
Thank you for your help. I happened to define my own FTable extends JTable. So, it's very easy to override. Now, I feel much more comfortable.
May
 
Rajesh Matti
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May- I am bot happy about subclassing JTbale for the purpose you have mentioned. Never extend anything if the framework already allows a way to do it, that is exactly sun mentioned in its requirement.
 
May Wong
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops, I didn't notice that.Thanx Rajesh!!
In order to make the GUI look good. I added some functions on Swing components. For example, everytime when the mouse moves into button area the foreground color of the button will be changed. Since there are several buttons in my GUI, I created my own FButton class by extending JButton to let me use it more conveniently. Do you think is it OK?
Does anybody do the same thing as me?
 
Rajesh Matti
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May- That sounds really what I would like to do. But think, is it an overkill ?.
-Rajesh
 
reply
    Bookmark Topic Watch Topic
  • New Topic