aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Borders Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Borders" Watch "Borders" New topic
Author

Borders

Angela Jessi
Ranch Hand

Joined: Nov 27, 2000
Posts: 428
Hi,
How to make Borders in AWT?(NOT SWING)
Thanks,
Angela
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Angela,
Since AWT uses native OS to draw UI objects there is no concept of borders that java can control ...
Want borders, start the music ... Swing!
Regards,
Manfred.
Angela Jessi
Ranch Hand

Joined: Nov 27, 2000
Posts: 428
Thanks Manfred
Is there other solution with AWT through which I can make UI like Borders?
Thanks,
Angela
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

It would be difficult to replicate all the functionality of the Borders provided by Swing, however, if you only want to implement a few types of Borders it is (relatively) easy, though a bit complicated, since you have to build the specialized components yourself ( basically, you would have to extend Panel to draw the border and hold your object in the center )... could you specify what kind of border you want?

-Nate

P.S. - I notice that there are alot of posts on here about how to implement Swing-like functionality in AWT components. This is understandable, since Swing is not useable in unmodified browsers... However, what I do not understand is the people who always have the quick answer, "You cannot do that in AWT... use SWING!" Guess what... anything that can be done in Swing can be done in AWT, because Swing is based on the AWT... Sure, it would be easier to just use Swing... but if you only need a small part of the functionality of Swing, why include all the Swing libraries in a huge jar file for your applet or force your users to download the Java plug-in? I personally can't wait until Swing is usable "out of the box" in browsers, but until then the best solution is probably custom AWT components... and you can develop any component or functionality that exists in Swing ( or even ones that do not! *Gasp!* Creative potential! What an underdeveloped commodity! ) in the AWT.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Angela Jessi
Ranch Hand

Joined: Nov 27, 2000
Posts: 428
Thanks a bunch Nathan
Right now I am developing some GUI functionality in my project.Now I want to make Tabel object with the use of AWT.
So I was thinking to make labels with simple borders. But If you have solution or sample example which has table object, please let me know.

Thanks again,
Angela
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Hmmm.... you are going to try to use the borders to build a table... You could do that, but it would be very, very messy... you would have to have a Panel and another component ( Like a textfield ) for each element in the table... That would be alot of objects and would be really slow... Is this going to be an editable or a non-editable table (i.e. is the user actually going to need to enter data into it, or is information just going to be displayed as a table)?

If the table is used only for output, you could just use a Canvas to draw the table on, and draw the data inside the cells you have drawn. Throw this canvas inside a scrollpane and you have a table!

On the other hand, if the user needs to edit the data you will have to either have a textfield for every cell in the table (bad...) or come up with some scheme that uses a drawn canvas like I described above, and uses only one textbox... when the user clicks in a "cell" of the table this calls a mouse listener, that creates a textbox "over" the cell and lets the user enter data... when the textbox loses focus, the user is done, so remove the textbox and add the value the user entered to the table... Much more difficult, but still "do-able"...

HTH,
-Nate
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Borders
 
Similar Threads
table borders - VideoServlet (4a)
JLabel borders
What's up with the sybex book?
create surrounding box
Want bottom line which connect an image of other cell