|
-
September 20th, 2010, 02:18 PM
#16
Re: Application Window Size Problem.
Okay, I'll give it a go. Fingers crossed. Thanks again.
-
September 30th, 2010, 02:20 PM
#17
Re: Application Window Size Problem.
Hi again Keang,
I finally had a full afternoon free to give your VariableGridLayout class a go. It is excellent and works brilliantly, I am pleased with the results so far (still work in progress though). Thanks so much for telling me about it, and also for creating it !!
There is one thing that I just can't work out, which is not your class specific, but maybe you (or anyone reading this) can help with, as I have just wasted an hour trying to solve it.
Look at the image linked below, how do I add some padding between the edges of the TitledBorder and the components inside? In other words so there is a gap on the left between the left side of the border line and the left column of labels, likewise on the right side between the border line and the buttons (also at the top and bottom)?
http://www.zilefile.com/files/12580_..._DB_Screen.png
Many thanks again.
-
September 30th, 2010, 02:28 PM
#18
Re: Application Window Size Problem.
It is excellent and works brilliantly, I am pleased with the results so far (still work in progress though). Thanks so much for telling me about it, and also for creating it !!
I'm glad you found it useful.
how do I add some padding between the edges of the TitledBorder and the components inside?
The easiest way is to use a CompoundBorder which effectively allows you to add two borders. You create the CompoundBorder with the instances of 2 other borders. For the inner border use an EmptyBorder with the padding you require and for the outer border use the TitledBorder you are currently using.
-
October 1st, 2010, 07:34 AM
#19
Re: Application Window Size Problem.
EDIT:
OKAY forget all the below - I got the inner and outer borders the wrong way around when creating the CompoundBorder !! Oops.
Thanks again, all sorted. 
 Originally Posted by keang
The easiest way is to use a CompoundBorder which effectively allows you to add two borders. You create the CompoundBorder with the instances of 2 other borders. For the inner border use an EmptyBorder with the padding you require and for the outer border use the TitledBorder you are currently using.
Thanks again. Ok last question as it's the same subject, otherwise I've probably taken your patience with me too far and I'll start a new thread. 
What you suggest is what I had already done to create some padding between the main window (a JFrame) and the edges of the 3 panels. These 2 lines of code is what I used and it worked perfectly.
Code:
searchPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Search"));
searchPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10), searchPanel.getBorder()));
What I am trying to do is add padding on the inside of the 3 panels between the inside edges of the panels and the components inside, I did not realize that it was possible to add borders to components in the same way.
BUT it does not work in the way I wanted. In the top panel ('Search') I added padding to the left of the left col of compnents, the labels (Title, Director, Year, ...), I added padding to the right of the right col of components, the buttons (Search DVDs, Get All DVDs, ...), and to the bottom of the bottom row of components, the Notes label along to the Clear Search button.
See this screen grab - on the left it looks fine, there is a gap between the panel line and the col of labels, but the right side buttons and bottom row is not what I want!
http://www.zilefile.com/files/12581_...Screen_Pad.png
This is the code I used:
Code:
int padTop = 0;
int padLeft = 10;
int padBottom = 0;
int padRight = 0;
titleSearchLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), titleSearchLabel.getBorder()));
directorSearchLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), directorSearchLabel.getBorder()));
yearSearchLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), yearSearchLabel.getBorder()));
lengthSearchLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), lengthSearchLabel.getBorder()));
genresSearchLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), genresSearchLabel.getBorder()));
notesSearchLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), notesSearchLabel.getBorder()));
padTop = 0;
padLeft = 0;
padBottom = 0;
padRight = 10;
searchDVDsButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), searchDVDsButton.getBorder()));
searchDVDsGetAllButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), searchDVDsGetAllButton.getBorder()));
searchDVDsMostRecentButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), searchDVDsMostRecentButton.getBorder()));
searchDVDsRandomButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), searchDVDsRandomButton.getBorder()));
searchDVDsCustomSqlButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), searchDVDsCustomSqlButton.getBorder()));
searchClearButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), searchClearButton.getBorder()));
padTop = 0;
padLeft = 0;
padBottom = 10;
padRight = 0;
notesSearchLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), notesSearchLabel.getBorder()));
notesSearchField.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), notesSearchField.getBorder()));
orderBySearchLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), orderBySearchLabel.getBorder()));
orderBySearchCombo.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), orderBySearchCombo.getBorder()));
searchClearButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight), searchClearButton.getBorder()));
I then tried using just an empty border and not a compound one, using code like this for all the components, but that had very similar results to the code above.
Code:
titleSearchLabel.setBorder(BorderFactory.createEmptyBorder(padTop, padLeft, padBottom, padRight));
Where have I gone wrong?
Many thanks again and sorry to be so inexperienced with all this.
Last edited by mattst; October 1st, 2010 at 07:41 AM.
-
October 1st, 2010, 07:52 AM
#20
Re: Application Window Size Problem.
Adding borders to all the components is way too much effort, to get a gap inside the titled border you just need to add a CompoundBorder to the panels containing the titled borders but you need to read the API docs before using a new class.
CompoundBorder's constructor takes 2 arguments, the first argument is the outer border and the second argument is the inner border (personally I would have done this the other way around but we have to work with what we have been given). So you need to add the titled border and then the empty border ie:
Border titledBorder = BorderFactory.createTitledBorder("Search"));
Border emptyBorder = BorderFactory.createEmptyBorder(10, 10, 10, 10);
searchPanel.setBorder(BorderFactory.createCompoundBorder(titledBorder, emptyBorder));
-
October 1st, 2010, 09:17 AM
#21
Re: Application Window Size Problem.
 Originally Posted by keang
CompoundBorder's constructor takes 2 arguments, the first argument is the outer border and the second argument is the inner border (personally I would have done this the other way around but we have to work with what we have been given). So you need to add the titled border and then the empty border ie:
Hi again Keang,
Silly of me to get the inner and outer borders the wrong way around (I take it you saw my last post edit before you replied?).
Everything in the GUI is now done and I thought you might like to see the excellent results I've attained using your VariableGridLayout class. It is so very much better than what I managed using the GUI designer. Many thanks for all your help and indeed the class itself which, I have no doubt, I will use again and again.
Here's the finished GUI:
http://www.zilefile.com/files/12582_...VD_UI_Done.png
Thanks again, best wishes, etc..
-
October 1st, 2010, 09:53 AM
#22
Re: Application Window Size Problem.
I take it you saw my last post edit before you replied?
No, I must have been reading your post and writing my reply when you posted the edit, but no harm done.
Everything in the GUI is now done and I thought you might like to see the excellent results
Thanks. Yes that does look good - well done.
Many thanks for all your help...
My pleasure.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|