Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2006

Tip: Looking for answers? Try searching our database.

Drawing number tables

Thread view: 
PGR - 11 Jan 2006 23:36 GMT
Hi:

I need to draw a table which will be full of numbers. I also need to draw
lines over the numbers (for example, draw a horizontal line from the first
column to the last one, over all the numbers of the first row, etc).

You can see an example of what I want here:
http://img314.imageshack.us/img314/184/image13891mv.png

I think JTable would be suitable for the work, but can't realize how to draw
the lines over a JTable's row (with Java2D, for example), so I hope you can
give me some solution or way to get the table done.

Thanks!

Signature

PGR

Andrey Kuznetsov - 12 Jan 2006 19:52 GMT
> I need to draw a table which will be full of numbers. I also need to draw
> lines over the numbers (for example, draw a horizontal line from the first
[quoted text clipped - 8 lines]
> can
> give me some solution or way to get the table done.

class MyTable extends JTable {

   public void paint(Graphics g) {
       super.paint(g);
       paintLines(g);
   }

   protected void paintLines(Graphics g) {
       //draw lines here
   }
}

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

PGR - 12 Jan 2006 22:10 GMT
Thank you, it looks easy and simple

Signature

PGR

Martin Bradley - 29 Jan 2006 23:06 GMT
>>I need to draw a table which will be full of numbers. I also need to draw
>>lines over the numbers (for example, draw a horizontal line from the first
[quoted text clipped - 20 lines]
>     }
> }

Would it not be better to create a TableCellRenderer that does the line
drawing for you rather than extending JTable?  Your TableCellRenderer
can use a JLabel to dislay the number.  JLabels can render HTML.  HTML
has a strike through <strike>word</strike>.

Thats what I would look into first anyway.

hope I helped,
Martin
Andrey Kuznetsov - 31 Jan 2006 00:52 GMT
>>>http://img314.imageshack.us/img314/184/image13891mv.png

> Would it not be better to create a TableCellRenderer that does the line
> drawing for you rather than extending JTable?  Your TableCellRenderer can
> use a JLabel to dislay the number.  JLabels can render HTML.  HTML has a
> strike through <strike>word</strike>.
>
> Thats what I would look into first anyway.

if you look at his image, you will find there also vertical lines,
Note also that lines must be _inside_of_cell_ to be drawn by renderer.

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.