Results 1 to 3 of 3
Thread: TitledBorder in Swing
- 10-10-2010, 07:05 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 1
- Rep Power
- 0
TitledBorder in Swing
Hello all,
I have a problem creating proper TitledBorder to JPopupMenu.
The result is a border that is very thick, and white, while in all the examples I found on the net the thickness is 1 - simple line.
The TitledBorder class in java sais that it uses the look&feel to determine the border, but I want it to be thickness 1.
How should I do it?
Thanks!
The code:
Class MenuPopup extends JPopupMenu{
...
LinedBorder border = new LinedBorder(Color.WHITE, 1);
//creates border with thickness 1.
border = new TitledBorder(border, "some title);
setBorder(border);
//The result is a border with thikcness 5 or more.
...
}
- 10-10-2010, 07:21 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
mhm..and which look&feel do you use? :confused:
that can not be your code, because there are many many errors.Java Code:The code: Class MenuPopup extends JPopupMenu{ ... LinedBorder border = new LinedBorder(Color.WHITE, 1); //creates border with thickness 1. border = new TitledBorder(border, "some title); setBorder(border); //The result is a border with thikcness 5 or more. ... }
what about this snippet? the same issue?Java Code:public static void main(String[] args) throws Exception { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(); JPanel panel = new JPanel(); panel.setComponentPopupMenu(new JPopupMenu() { { add(new JLabel("hello popup")); setBorder(new TitledBorder(new LineBorder(Color.WHITE, 1), "title")); } }); frame.add(panel); frame.setSize(500, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); }
-
I think that at this point you'll have to post some more code. I recommend that you create and post the smallest program possible that is compilable, runnable, demonstrates your problem, and has no extraneous code not related to the problem, an SSCCE . Please see the link for details on how to create one of these because trust me, if your SSCCE is compliant with the specs, you'll likely get a very helpful answer from someone here quickly.
Also, when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?
To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.
Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:
Best of luck and welcome to the java-forums.org!Java Code:[code] // your code goes here // notice how the top and bottom tags are different [/code]
Similar Threads
-
Swing
By tmotse in forum AWT / SwingReplies: 0Last Post: 03-31-2010, 10:18 AM -
swing.jar
By krrishnak in forum AWT / SwingReplies: 2Last Post: 04-05-2009, 05:29 AM -
What is next to Swing
By javaplus in forum AWT / SwingReplies: 1Last Post: 01-13-2008, 10:16 PM -
where is the swing jar?
By katie in forum AWT / SwingReplies: 1Last Post: 08-06-2007, 10:58 PM -
map javax.swing.text.Element to javax.swing.text.View
By elizabeth in forum New To JavaReplies: 1Last Post: 07-30-2007, 07:02 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks