egan
Oct 1 2003, 04:41 PM
How come when i use a JTextField it has a border and when i use a JTexeArea is dosen't I want a border around the JTextArea, is there a way of doing this. I know a could just use borderFactory and **** but i thought it would have one allready on it ?????
Also how do you space out components that are ijn a gridBagLayout??? i want to have a about a 10 pixel space between each off them
[ October 01, 2003, 16:32: Message edited by: egan ]
Gemme_Fatale
Oct 1 2003, 04:58 PM
I am trying to remember, but its been nearly 2 years since I did any java at uni, and my brain is going to implode.
Sorry.
I don't know why the text area doesn't have a border, but it incase you want to use a BorderFactory (should only be a few lines of code ?):
How to Use Borders As far as spacing components using GridBagLayout:
How to Use GridBagLayoutHave a look at the "specifying constraints" section (maybe the ipadx/ipady or Insets properties will do what you're after). The sample code (esp. the "The example explained" link ) seems pretty decent.
[ October 02, 2003, 19:58: Message edited by: au2 ]
egan
Oct 5 2003, 12:30 PM
Cool thanks, also i know you can use an ImageIcon to hold pictures but i want something that can return the url of the picture currnetly being displayed???? Any Ideas????
Not sure...One cheap (i.e. hack) way might be to possibly use the description property to store/retrieve the filename/location ?? e.g. from the api
QUOTE
code:
public ImageIcon(java.lang.String filename)
....
The description is initialized to the filename string.
code:
public ImageIcon(java.net.URL location)
...The icon's description is initialized to be a string representation of the URL In the above cases, I assume after you've constructed the ImageIcon you could use getDescription() to retrieve the filename/location string (might want to see what actually gets returned in the string though) ?
Edit: (I'm probably getting off track here) Had a quick look at the ImageIcon source code. It already has member variables to keep track of the URL or filename (which it sets in the appropriate constructors). But those member variables are private and have no get/set methods defined. So, depending on how keen you were, I guess you could subclass ImageIcon, add in variables to keep track of location/filename etc, making sure they get initialised (in the appropriate constructors). Then create get() type methods for your new variables ?
[ October 05, 2003, 15:35: Message edited by: au2 ]
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.