Font and labels

Hi, elementary question...
in my program I have many labels as class variables. I initialize them all in init(). How can i change their font. All of them should be the same font, just not the default one. Also i would like to make certain ones bold. How do I do this?
Thanks!

This should work:
yourLabel.setFont(new Font("Verdana", Font.PLAIN, 11));
yourLabel2.setFont(new Font("Verdana", Font.BOLD, 11));

Similar Messages

  • Font and size help

    lblProvNameText = new JLabel("Provider ID");
    lblProvNameText.setMinimumSize(new Dimension(100, 15));
    lblProvNameText.setPreferredSize(new Dimension(100, 15));
    lblProvNameData = new JLabel("");
    lblProvNameData.setMinimumSize(new Dimension(100, 15));
    lblProvNameData.setPreferredSize(new Dimension(100, 15));
    lblProvNameText.setFont(new Font("Ariel",Font.PLAIN,12));
    for each component, i am setting the minimum size etc ..
    is there a way i can pass this to a method and set the font and size for labels and just call the method (should that method validate(); again or don't have to ....?
    anyhow i am repainting at end of components once..
    method addcomp()
    //add
    revalidate();

    import java.awt.*;
    import javax.swing.*;
    public class LabelDemo {
      public static void main(String[] args) {
        JLabel
          labelOne   = new JLabel("Label 1"),
          labelTwo   = new JLabel("Label 2"),
          labelThree = new JLabel("Label 3"),
          labelFour  = new JLabel("Label 4");
        JLabel[] labels = {
          labelOne, labelTwo, labelThree, labelFour
        Color[] backgroundColors = {
          Color.blue, Color.red, Color.yellow, Color.green
        Color[] foregroundColors = {
          Color.yellow, Color.cyan, Color.pink, Color.blue
        Font labelFont = new Font("lucida sans regular", Font.PLAIN, 18);
        JPanel panel = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridwidth = gbc.REMAINDER;
        gbc.weighty = 1.0;
        gbc.insets = new Insets(10,0,10,0);
        for(int i = 0; i < labels.length; i++) {
          labels.setOpaque(true);
    labels[i].setBackground(backgroundColors[i]);
    labels[i].setForeground(foregroundColors[i]);
    labels[i].setPreferredSize(new Dimension(120,25));
    labels[i].setFont(labelFont);
    labels[i].setHorizontalAlignment(JLabel.CENTER);
    panel.add(labels[i], gbc);
    JFrame f = new JFrame("Label Demo");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(new JScrollPane(panel));
    f.setSize(400,300);
    f.setLocation(300,400);
    f.setVisible(true);

  • Why controls and labels don't go to their respective places?

    i wonder why the controls and labels don't go to their respective setLocations, they just keep stacking theirselves at the top....
    don't bother the whole code, it still not yet finish.
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Fonts2 extends Applet implements ItemListener
    Label ds, bc, fset, col, st, sz, xyz, opt, qua, totcha, cas;
    CheckboxGroup g1 = new CheckboxGroup();
    CheckboxGroup g2 = new CheckboxGroup();
    CheckboxGroup g3 = new CheckboxGroup();
    CheckboxGroup g4 = new CheckboxGroup();
    Checkbox blue,red,green, pink, yellow, magenta, style1, style2, style3, size1, size2, size3;
    Font plain, bold, italic, a1;
    String fs="Arial";
    public void init(){
    ds = new Label("Display Settings");
    bc = new Label("Background Color");
    fset = new Label("Font settings");
    col = new Label("Color");
    st = new Label("Style");
    sz = new Label("Size");
    plain = new Font(fs,Font.PLAIN,12);
    bold = new Font(fs,Font.BOLD,12);
    italic = new Font(fs,Font.ITALIC,12);
    blue = new Checkbox("blue",false, g3);
    red = new Checkbox("red", false, g3);
    green = new Checkbox("green", false, g3);
    pink = new Checkbox("pink",false, g4);
    yellow = new Checkbox("yellow",false, g4);
    magenta = new Checkbox("magenta",false, g4);
    style1 = new Checkbox("plain", false, g1);
    style2 = new Checkbox("bold", false, g1);
    style3 = new Checkbox("italic", false, g1);
    size1 = new Checkbox("14", false, g2);
    size2 = new Checkbox("16", false, g2);
    size3 = new Checkbox("18", false, g2);
    ds.setLocation(10,10); ds.setSize(100,20);
    bc.setLocation(20,30); bc.setSize(120,20);
    blue.setLocation(150,30); blue.setSize(50,20);
    red.setLocation(210,30); red.setSize(50,20);
    green.setLocation(270,30); green.setSize(50,20);
    fset.setLocation(20,50); fset.setSize(120,20);
    col.setLocation(80,70); col.setSize(50,20);
    st.setLocation(180,70); st.setSize(50,20);
    sz.setLocation(280,70); sz.setSize(50,20);
    pink.setLocation(75,90); pink.setSize(50,20);
    yellow.setLocation(75,110); yellow.setSize(50,20);
    magenta.setLocation(75,130); magenta.setSize(50,20);
      style1.setLocation(175,90); style1.setSize(50,20);
      style2.setLocation(175,110); style2.setSize(50,20);
      style3.setLocation(175,130); style3.setSize(50,20);
      size1.setLocation(275,90); size1.setSize(50,20);
      size2.setLocation(275,110); size2.setSize(50,20);
      size3.setLocation(275,130); size3.setSize(50,20);
    add(ds); add(bc); add(fset); add(col); add(st); add(sz);
    add(blue); add(red); add(green);
    add(pink); add(yellow); add(magenta);
    add(style1); add(style2); add(style3);
    add(size1); add(size2); add(size3);
    blue.addItemListener(this);
    red.addItemListener(this);
    green.addItemListener(this);
    pink.addItemListener(this);
    yellow.addItemListener(this);
    magenta.addItemListener(this);
    style1.addItemListener(this);
    style2.addItemListener(this);
    style3.addItemListener(this);
    size1.addItemListener(this);
    size2.addItemListener(this);
    size3.addItemListener(this);
    public void itemStateChanged(ItemEvent e){
    if(blue.getState()==true){setBackground(Color.blue); repaint();}
    if(red.getState()==true){setBackground(Color.red); repaint();}
    if(green.getState()==true){setBackground(Color.green); repaint();}
    if(pink.getState()==true){style1.setForeground(Color.pink); repaint();}
    if(yellow.getState()==true){style1.setForeground(Color.yellow); repaint();}
    if(magenta.getState()==true){style1.setForeground(Color.magenta); repaint();}
    if(style1.getState()==true){style1.setFont(plain);}
    if(style2.getState()==true){style1.setFont(bold);}
    if(style3.getState()==true){style1.setFont(italic);}
    if((style1.getState()==true)&&(size1.getState()==true)){a1 = new Font("Arial", Font.PLAIN, 14); style1.setFont(a1);}
    if((style1.getState()==true)&&(size2.getState()==true)){a1 = new Font("Arial", Font.PLAIN, 16); style1.setFont(a1);}
    if((style1.getState()==true)&&(size3.getState()==true)){a1 = new Font("Arial", Font.PLAIN, 18); style1.setFont(a1);}
    if((style2.getState()==true)&&(size1.getState()==true)){a1 = new Font("Arial", Font.BOLD, 14); style1.setFont(a1);}
    if((style2.getState()==true)&&(size2.getState()==true)){a1 = new Font("Arial", Font.BOLD, 16); style1.setFont(a1);}
    if((style2.getState()==true)&&(size3.getState()==true)){a1 = new Font("Arial", Font.BOLD, 18); style1.setFont(a1);}
    if((style3.getState()==true)&&(size1.getState()==true)){a1 = new Font("Arial", Font.ITALIC, 14); style1.setFont(a1);}
    if((style3.getState()==true)&&(size2.getState()==true)){a1 = new Font("Arial", Font.ITALIC, 16); style1.setFont(a1);}
    if((style3.getState()==true)&&(size3.getState()==true)){a1 = new Font("Arial", Font.ITALIC, 18); style1.setFont(a1);}
    }

    just add :
    setLayout(null);at the start of init() method.
    Thanks!

  • Address Book and Label Printing

    I've been trying to do this and have run into a sea of problems/bugs.
    A lot come to light after switching back and forth between the Layout and Label tabs. This seems to render the preview window inoperative. For example, after choosing print from the file menu then clicking Layout then clicking Label in the Print Dialog Box:
    1) changing font is not reflected in preview pane
    2) clicking "country" check box is not reflected in preview pane
    3) zoom control does nothing
    4) changing label type does not update preview pane
    After printing and then trying to print a second time, I notice that some setting are not saved. For example, the Country, if it was checked, has reverted back to being not checked and the font has reverted to Lucida Grande 12. More importantly, the label type reverts back to the default 5161, but only after every second print. (ie choose print from file menu set label type to 2163, print, select print from file menu: label type is 2163, print, select print from file menu again and label type has now reverted to 5161
    When selecting a different Label from the layout menu, ie Avery 2163 Top, the Preview Pane is only partially updated. The addresses are relocated on the page but a full 8 1/2X11 page is still shown. if I cancel the Print and return, the preview page size has been resized to reflect the smaller label size.
    I've also a great deal of difficulty getting Address Book to print correctly on Avery 2163 labels. These labels are 2" wide and the program seems to want to print on 8 1/2 inch wide paper. As a result, only the left hand portions of the address appear on the label, and even that is not properly spaced vertically to appear correctly within each label. I was able to get it to print correctly only when I selected "Scale to Fit Paper" in the Paper Handling Section
    These problems don't seem isolated to my machine (A PowerPC G5). I was able to replicate on an intel imac.
    Has anyone else had problems printing labels?

    Warren: looking at other threads out there it doesn't appear that you can print the spouse/partner/friend field. One poster suggested using Avery DesignPro for Mac, which merges with your AddressBook, and allows you to select which fields to include.  The only caveat is that it doesn't show it working with Lion (os 10.7).  You can download it here:
    http://www.avery.com/avery/en_us/Templates-%26-Software/Avery-DesignPro-for-Mac. htm?N=0&refchannel=c042fd03ab30a110VgnVCM1000002118140aRCRD
    Hope this helps.
    -McCArch
    (also posted this in the other thread where you asked a similar question)

  • How do I change font and colors back to default?

    I have changed the font and color of the text through the tools button and the options button and the content tab. I find nothing telling me how to change the font and colors back to default font and colors. Can you advise me? I'm using Windows 7 Home Premium OS. Thanks.

    Hi Brenda19605,
    You can use this article to set the fonts and colors: https://support.mozilla.org/en-US/kb/change-fonts-and-colors-websites-use?esab=a&s=font&r=0&as=s
    The default settings for the font are in this article:
    https://support.mozilla.org/en-US/kb/Some%20text%20shows%20up%20bold%20after%20upgrade
    Unfortunately for the default colors has no good reference. But for text it is black (most lower left) color, background is white (most upper left color). Unvisited links is blue (column 8, row 5) and visited link is purple (column 9, row 5).
    Let me know if you need anymore help!
    Lordfreak

  • I am using Illustrator CS5. I am using a certain font and when I make a selection to use one of the letter options or a glyph, it does not take my selection; in other words, nothing changes.

    I am using Illustrator CS5. I am using a certain font and when I make a selection to use one of the letter options or a glyph, it does not take my selection; in other words, nothing changes.

    What font? What system? What Glyph? What language settings? Could be anything. Either way, ask in the AI forum. You'll get quicker answers there - if you provide all the required info.
    Mylenium

  • Problem with fonts and appearance on firefox

    Hello everyone, I have firefox 18 and for a few days Firefox is very unstable ... starts normal, but a second to another entire interface (colors, fonts and website) .. deforms everything .. and I've tried reinstalling the application to delete my session .. and always the same .... someone has an idea of what I can do?
    Here a picture of how it looks
    https://www.dropbox.com/s/a8wdeo4kpz2jd … 2%3A25.png
    https://www.dropbox.com/s/liuf8ryjf4c2f … 4%3A54.png
    PD: The problem is only with firefox,Chrome is fine..
    Last edited by armandopk (2013-01-22 22:41:05)

    From Mozilla support

  • How to change DEFAULT font and font size on new Pages document

    When I open a new Page document, it always comes in with a default font and font size. I know how to change those settings on the open document.
    I want to know how to change the ~default~ font and font size so that a new Page document always opens with those default settings.
    -Thanks for your service to the community.

    Hi Lionate
    Welcome to the forum.
    Make a document to your liking.
    Change the Body style and any other styles in :
    +Menu > Show Styles Drawer > click on the little triangle next to Body > redefine Style from Selection+
    Capture the page:
    +Menu > Format > Advanced > Capture Pages… > Name it > OK+
    +Menu > Format > Advanced > Manage Pages… > Delete other Sections/Pages > OK+
    Save as a template:
    +Menu > File > Save as Template…+
    +Menu > Pages > Preferences > General Preferences > For New Documents > click Use template: > Choose > browse to the template above+
    Peter

  • Need help. I am running a 27 in imac with 16 gigs of ram. Photoshop runs really fast, except when opening files. It takes 5-10 minutes to open even a small file of 1 meg. I cleaned and validated all the fonts and removed all questionable fonts. Reset pref

    Need help. I am running a 27 in imac with 16 gigs of ram. Photoshop runs really fast, except when opening files. It takes 5-10 minutes to open even a small file of 1 meg. I cleaned and validated all the fonts and removed all questionable fonts. Reset preferences and still have problem. Slow to open and in force quit "Photoshop not responding" At this point should I uninstall and start over.

    What are the performance Preferences?

  • After removing system fonts and reinstalling fonts, FireFox will not start

    After removing system fonts and reinstalling fonts, FireFox will not start! When I start FireFox the "Mozilla Crash Reporter" opens as if FF just crashed??? I don't see any records in event viewer. I am using FF v3.6.3 on a Windows 7 box. I tried uninstalling 3.6.3 and installing 3.0.18 and had the same problem!
    == This happened ==
    Every time Firefox opened
    == After a uninstalled all fonts including system fonts and then reinstalling system fonts. ==
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.4; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; AskTB5.5)

    The files with submitted crash report ids are inside the ''submitted '' directory, from the directory you found the LastCrash.txt timestamp file.
    The file names will begin with '''bp-'''
    There might be more information from the crash report, but it might just tell us you are crashing the first time Firefox tries to use a font.
    One thing I suppose you could do is select only those fonts you've got in Tools -> Options -> Content -> Fonts and Colors -> Advanced and then uncheck the '''Allow pages to use their own fonts''' option.
    See http://support.mozilla.com/en-US/kb/Options+window+-+Content+panel#Fonts_Dialog
    To be honest, I can't find anything on this Netscape Font Navigator and it sounds highly dubious.

  • How do I use all fonts and Microsoft Word?

    Although my fonts seem to be installed correctly, I often get a message when I try to use a new font that says "font not available for use in Microsoft Word," or some such. How can I make installed fonts available for Word? (By the way, this was true with earlier versions of OS 10.4, as well.)

    Fonts you download or otherwise acquire as font files should be placed in the Fonts folder in your Library or in the Fonts folder in the global Library. Having been placed there, the Mac OS knows what to do and there's nothing more for you to do.
    However, if you add fonts to the Fonts folder while an application is running...well the OS is supposed to let the program know about that and the program is supposed to gracefully accept them but it doesn't always work that way. I've never seen the error you mention but I can imagine it occurring if you've just added a font and the program was running. Just quit and restart the program.
    Having said that, some programs, Word included, prebuild font lists to enable faster loading times. I can also imagine Word's font list becoming corrupt (which happens all too frequently) which might cause your error message. The fix is to delete the font cache file. (found in the ~/Library/Preferences/Microsoft/Office Font Cache)

  • Sharpener Pro 3 has problems in Aperture as the Pre sharpener continually asks one to buy or activate and the Output Sharpener causes Aperture to hang. Have removed all duplicate fonts and tried using a new user account. Any ideas?

    I am experiencing problems with Sharpener Pro 3 as an Aperture 3 plug-in. These are:  the Pre sharpener continually asks one to buy or activate and the Output Sharpener causes Aperture to hang. Following discussions with Nik Software I have removed all duplicate fonts and tried using a new user account. Neither of the courses of action worked. Have other users experienced these difficulties? Can you suggest an alternative remedy?

    I am experiencing problems with Sharpener Pro 3 as an Aperture 3 plug-in. These are:  the Pre sharpener continually asks one to buy or activate and the Output Sharpener causes Aperture to hang. Following discussions with Nik Software I have removed all duplicate fonts and tried using a new user account. Neither of the courses of action worked. Have other users experienced these difficulties? Can you suggest an alternative remedy?

  • How can I change the font and color of an email signature?

    How can i change the font and color of an email signature?

    Mail > Preferences > Signature
    Highlight the Signature.
    Click Format in the menu bar and select " Show Fonts".
    Select the Font.
    Highlight the Text.
    Click Format in the menu bar and select " Show Colors".
    Select the color.
    Mail > Preferences > Composing > Message Format:  Rich Text
    Best.

  • I would like to print links as regular text i.e. not underlined or in a different font and color.

    I have created a page with my resumé, using Dreamweaver CS4 on my iMac (running OS X 10.6.6).  You can see the page here: http://www.peterforkes.com/Resume.html
    It looks great when it is on the screen, but when I print it I would like the links to not be underlined and also to be displayed in the same font (and color) of the text surrounding it (a link is largely useless on a piece of paper, if it it not showing the URL).
    So, I created a stylesheet called "print.css" and have this in it:
    a:link {
    text-decoration: none;
    In my html document (Resume.html)  I have this code, at the top:
    <link href="_css/Resume.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="_css/Print.css" rel="stylesheet" type="text/css" media="print" />
    Now, things such as the graphics in my document do not print out (this is how I want it) but links seesm to be doing unexpected things for me.  As I mentioned, when I print the page I would like them to:
    a) not print with an underline (which I would expect the code snippet shown above to do).
    b) I would like the link color to be the same as the surrounding text (I have links in several places, such as in <h2>, <h3> and <p>).
    c) I would like the link to have the same font and text size as the surrounding text.
    Any help is always appreciated.
    Peter A. Forkes

    You've solved it for a:link but you may print the page with the <a> tag in link or visited state so you need to cover both.
    In http://www.peterforkes.com/_css/Print.css
    change
    a:link {
    text-decoration: none;
    to
    a:link, a:visited {
    color: #333;
    text-decoration: none;

  • Can I set a default font and font color for the text field properties?

    I am setting up applications, some of the information I fill in prior to sending it to the client; I would like that text to always be in a specific font and color so it is clear to the client what information I filled in for them when they are reviewing the document.
    Thank you

    Not at this time, but I've asked the product team to consider adding it as a feature. Thanks for the suggestion.

Maybe you are looking for

  • Rounding off to a variable value to 4 decimal values in sap script ouput

    Hi All, I have a value getting displayed in sap script output as 235.6789 i want to Round off this variable value to 4 decimal values! What is the formatting option need to be used & how! Thanks in advance. Thanks, Deep.

  • Problem in Rough Cut Plan while displaying horizon nbr of columns

    Hi Expert, During the creation of Rough Cut plan for material Trx MC87, the system display only one Column. I Tried to extend the period by using the the button "page Right" and "page left" but there is no  chance. your support is highly suitable Olf

  • Unable to open or re-install iTunes

    I am not able to open iTunes, I get the message 'this application has failed to start because MSVCR80.dll was nit found.' I tried to reinstall itunes, but it does not work either.

  • Manipulating live objects in the Run Time system

    A Graphic User interface exists that has GUI components say JButtons. This program cannot be edited. If the container ( say a GUI panel , where this JButton resides ) of this GUI is obtained then the components in this container can be obtained using

  • HD-DVD on Xbox 360

    Hi all, I'm still testing my HD-DVD that brun with DVDSP 4.12, it plays faultlessly on Toshiba HA2, but the menu button overlays are all became invisible on Xbox 360, but still working. Anyone have idea of what went wrong with the button overlay ? G