Java Forum / General / June 2007
Setting One Font for All Swing Components in a Panel
Hal Vaughan - 05 Jun 2007 17:09 GMT I've never had to worry about what font I was using before, but now I'm going to have a JComboBox with combined data from several sources and need to use a fixed width font so I can line up data. If possible, I'd like to just use the same font for all the components in that panel. I know I can set the font for each component individually and I did set the font for the panel, but that doesn't effect the components in the panel.
Is there a way to specify a font for a panel or JTabbedPane and have that same font automatically used for all the components in the panel? Could this be done for a window? I'd like to just specify the font once and not over and over with each component.
Thanks!
Hal
SadRed - 05 Jun 2007 23:40 GMT > I've never had to worry about what font I was using before, but now I'm > going to have a JComboBox with combined data from several sources and need [quoted text clipped - 11 lines] > > Hal public class MyContainer extends JPanel{ Font font; ...
public void addImpl(Component comp, Object constraints, int index){ comp.setFont(font); super.addImpl(comp, constraints, index); }
... }
Hal Vaughan - 06 Jun 2007 07:13 GMT >> I've never had to worry about what font I was using before, but now I'm >> going to have a JComboBox with combined data from several sources and [quoted text clipped - 25 lines] > ... > } Thanks. It took me a bit to go over this, but once I caught on, it makes sense. As I said in a separate reply to someone else, I'll be trying this when I get back to that particular section.
I appreciate your time and effort!
Hal
Andrew Thompson - 05 Jun 2007 23:54 GMT > I've never had to worry about ... ...multi-posting? Please refrain from multi-posting, in future. <http://www.physci.org/codes/javafaq.html#xpost>
(X-post to c.l.j.p./g., w/ f/u to c.l.j.p. only))
Hal Vaughan - 06 Jun 2007 00:33 GMT >> I've never had to worry about ... > [quoted text clipped - 3 lines] > > (X-post to c.l.j.p./g., w/ f/u to c.l.j.p. only)) Posted to one, needed the answer so I could move on to another item, so I posted it to another group. I didn't multi-post and had waited hours for an answer before posting to the 2nd group -- and then, only after realizing there was a better forum for that post (and that I needed an answer quickly if at all possible).
The headers indicate that.
Now, is there a chance you could help me out with this problem? I've essentially had to move on and drop this part of the GUI due to timing pressure, but if there's a quick and easy answer, it would be a huge help.
Hal
Andrew Thompson - 06 Jun 2007 00:39 GMT > ...had waited hours for > an answer before posting to the 2nd group ... You poor, poor thing. Perhaps if this matter is so urgent, you should hire a consultant, rather than treat these groups as if we (collectively) were your paid servants.
For future reference, though I disagree with your impatience, a simple explanation at the second post would have sufficed. I might even have given you an answer.
Andrew T.
Hal Vaughan - 06 Jun 2007 01:53 GMT >> ...had waited hours for >> an answer before posting to the 2nd group ... [quoted text clipped - 10 lines] > > Andrew T. Thank you, your worship.
Hal
Brandon McCombs - 06 Jun 2007 05:50 GMT >>> ...had waited hours for >>> an answer before posting to the 2nd group ... [quoted text clipped - 13 lines] > > Hal Hal,
You'll find it is better to simply ignore Andrew as he seems to annoy more than help by replying with useless messages concerning posting practices (you should have done this but not that and don't do this...). Hopefully at some point he will understand the error of his ways but I highly doubt it. Think of him as a self-proclaimed usenet moderator, one that can, thankfully, be ignored.
Patricia Shanahan - 06 Jun 2007 06:16 GMT ...
> You'll find it is better to simply ignore Andrew as he seems to annoy > more than help by replying with useless messages concerning posting > practices (you should have done this but not that and don't do this...). > Hopefully at some point he will understand the error of his ways but I > highly doubt it. Think of him as a self-proclaimed usenet moderator, one > that can, thankfully, be ignored. Meanwhile, I hope that Hal did read SadRed's substantive response, suggesting overriding the JPanel's addImpl method with one that forces the font setting.
Patricia
Hal Vaughan - 06 Jun 2007 07:06 GMT > ... >> You'll find it is better to simply ignore Andrew as he seems to annoy [quoted text clipped - 9 lines] > > Patricia I've read it and have it noted. I had to switch over to a few other items for a while (I was hoping I could get an answer while I was still on the same section) and will be trying that when I get back to that topic. (And if I have some problems, of course, I'll be asking about those!)
Thanks, both you and SadRed for a useful message!
Hal
Hal Vaughan - 06 Jun 2007 07:09 GMT >>>> ...had waited hours for >>>> an answer before posting to the 2nd group ... [quoted text clipped - 22 lines] > highly doubt it. Think of him as a self-proclaimed usenet moderator, one > that can, thankfully, be ignored. Yes, I should have. It's been a rough week (already) during a very rough time and yes, I should have ignored him. I didn't post on both groups at the same time and there was a lot going on, but it must have been more important to him to make a judgement than to try to help.
I was thinking of him very much as that self-proclaimed moderator, which was the reason for my remark.
Thank you, as well as the others, who actually took the time to help me out or to tell me to blow it off.
Hal
Lew - 06 Jun 2007 13:42 GMT >> You'll find it is better to simply ignore Andrew as he seems to annoy >> more than help by replying with useless messages concerning posting [quoted text clipped - 13 lines] > Thank you, as well as the others, who actually took the time to help me out > or to tell me to blow it off. OTOH, of course, is that multi-posting is an annoying practice that makes it difficult to follow the conversations.
It is arguable that Andrew should have been more diplomatic, but that doesn't necessarily invalidate his point.
 Signature Lew
Free MagazinesGet 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 ...
|
|
|