Setting font in JTextArea

I am trying to set the font for a JTextField and when I compile I get a "Cannot resolve symbol error: method setFont()"
All my other JTextArea method calls are working, I am only having a problem with setFont().
JTextArea myTextArea = new JTextArea();
myTextArea.setFont(Font.ITALIC);
Thanks in advance!

That's because setFont() accepts a Font not an int.
textArea.setFont(new Font(null, Font.ITALIC, 10));

Similar Messages

  • How to set font in JTextArea

    There is a function setFont() in class JTextArea, but it seems i only can set "bold","Italic" and "font size", but i want to set something like "Times new roman" and "Courier New"
    who knows how to set?
    //

    If your Java Runtime isn't configured (for whatever reason) to see the fonts you want, setting the font's name might just set it to the default value. Hence it looks like nothing happened.
    To see what fonts are available:String[] fontNames = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
    for (int j=0; j<fontNames.length; j++)
      System.out.println(fontNames[j]);To set a font:String fontname = "Courier New";
    int style = Font.PLAIN;
    int size = 12;
    Font f = new Font(fontname, style, size);
    jtextfield.setFont(f);
    NOTE: I haven't tested the above code. But it's the right idea.

  • Setting terminal font in JTextArea

    Hello,
    I want to print text file with table created by using terminal font.But when i open that in JTextArea with setting terminal font for JTextArea,I am not getting same formatting as I am getting notepad.
    The problem is that I can't set terminal font to JTextArea.
    I open font.properties file in jdk1.3\jre\lib and tried to edit it but not unsuccessful.
    Any one help me ?

    Hello,
    I want to print text file with table created by
    y using terminal font.But when i open that in
    JTextArea with setting terminal font for JTextArea,I
    am not getting same formatting as I am getting in
    notepad.
    The problem is that I can't set terminal font to
    o JTextArea.
    I open font.properties file in jdk1.3\jre\lib and
    tried to edit it but unsuccessful.
    Any one help me ?

  • Printing Problem with already set Font

    Post Author: tejas_kishanwala
    CA Forum: General
    hi,
    i have created a report using Crystal Report 9 with font Draft 10CPI using Printer EPSON FX-2175 on Windows XP with SP2.  after then when i call this report from my .NET Application (developed on VS 2005). the report is not showing as well printing with the already set Font (Draft 10CPI) Kindly do needful for the same. Tejas Kishanwala 

    Post Author: mewdied
    CA Forum: General
    Is the font Draft 10CPI a printer font?  If it is, you are running across a limitation of .NET not Crystal Reports.  .NET only supports True type and Open type fonts.  Microsoft has a KB about it, but I cannot find it right now.

  • Setting Font Color and Bold Property in ALV Grid

    I have a requirement to set the font in particular ALV Cells  in red color.
    Also this font (text) has to be set to Bold.
    I know how to set cell coloring in ALV Grid, but have no idea regarding how to set font color.
    Could please give me an idea/code segment/suggestion.
    Thank You!

    Please refer this post
    Coloring of ROWS in ALV tree

  • Can't set FONT in iCHAT

    When I try to hit SET FONT in iChat prefs, nothing happens.
    Fonts work in other apps.
    ?????

    I found it. DUH... the font window opened behind my prefs window.

  • [Solved] css setting font family, ff3 vs ie7

    In my css, I've set 'font-family: sans;' in body { }, and in ff3 on my Arch laptop, it displays correctlly. In ie7 on my wifes vista laptop, it still reverts back to w/e serif font it uses if it can't find one set by the web page. I have no idea why this is happening, and I can't seem to fix it. Can anyone give me a hand?
    Last edited by Sjoden (2009-01-04 03:07:09)

    Agh, well, I looked at thayer's blog to see if that worked in both browsers and it did, so I checked to see how he had his fonts set up.
    font-family: Arial, DejaVu Sans, sans-serif;
    The closest I got to that was 'font-family: Arial, DejaVu, sans;'

  • Setting font and color TextItems

    This script is failing to set font, and how can I set font color?; I am new to PS Scripting:
         var originalUnit = preferences.rulerUnits
          preferences.rulerUnits = Units.INCHES
         var docRef = app.documents.add( 11, 17, 300, "Test", NewDocumentMode.CMYK)
        MyLayer = docRef.artLayers.add()
         MyLayer.kind = LayerKind.TEXT
         var myFont = app.fonts.getByName("ArialMT");
         // Set the contents of the text layer.
         var textItemRef = MyLayer.textItem
         textItemRef.font = myFont;
         textItemRef.size = UnitValue(36, 'pt');
         textItemRef.font = '_Aviano-Regular';
         textItemRef.style = "Italic";
         textItemRef.contents = "Sample Text";
         // Restore original ruler unit setting
          app.preferences.rulerUnits = originalUnit
    Thanks

    The font needs to be the postscript name, this will give you a list of them.
    var Dlog =
    "dialog{text:'Script Interface',bounds:[100,100,500,270],"+
    "FontName:DropDownList{bounds:[30,40,370,60]},"+
    "PostScriptName:DropDownList{bounds:[30,100,370,120]},"+
    "statictext0:StaticText{bounds:[40,10,200,30] , text:'Font Name'},"+
    "statictext1:StaticText{bounds:[40,70,141,87] , text:'Postscript Name'},"+
    "button0:Button{bounds:[140,130,240,150] , text:'Ok' }}";
    win = new Window(Dlog,"Use the Postscript Name in your script.");
    var item;
    var item2;
    for (var i=0,len=app.fonts.length;i<len;i++) {
      item = win.FontName.add ('item', "" + app.fonts[i].name);
      item2 = win.PostScriptName.add ('item', "" + app.fonts[i].postScriptName);   
    win.FontName.selection = win.FontName.items[0] ;
    win.PostScriptName.selection = win.PostScriptName.items[0] ;
    win.FontName.onChange = function() {
    win.PostScriptName.selection = win.PostScriptName.items[parseInt(this.selection)] ;
    $.writeln(win.PostScriptName.items[parseInt(this.selection)]);
    win.PostScriptName.onChange = function() {
    win.FontName.selection = win.FontName.items[parseInt(this.selection)] ;
    win.center();
    win.show();
    Here is your code with colour addded...
         var originalUnit = preferences.rulerUnits
          preferences.rulerUnits = Units.INCHES
          var FillColor = new SolidColor;
        FillColor.rgb.hexValue = 'ff0000';
         var docRef = app.documents.add( 11, 17, 300, "Test", NewDocumentMode.CMYK)
        MyLayer = docRef.artLayers.add()
         MyLayer.kind = LayerKind.TEXT
         var myFont = "ArialMT";
         // Set the contents of the text layer.
         var textItemRef = MyLayer.textItem
         textItemRef.font = myFont;
         textItemRef.size = UnitValue(36, 'pt');
         textItemRef.font = myFont;
         //textItemRef.style = "Italic";
         textItemRef.fauxItalic = true;
         textItemRef.contents = "Sample Text";
         textItemRef.color = FillColor;
         // Restore original ruler unit setting
          app.preferences.rulerUnits = originalUnit

  • How do I set font default in aperture?

    how do I set font default in aperture?

    how do I set font default in aperture?
    Do you want to change the size of the fonts or the shape for the fonts in the user interface or in the products (books, webpages)?
    Aperture does not allow to change the fonts used in the graphical user interface, neither the size nor the shape. To change the fonts for the products (books, etc.), pick a theme with the fonts you like.
    Regards
    Léonie

  • Set font size for ChoiceGroup

    Hi,
    Is there any way to set font size of the String elements of ChoiceGroup

    Hi,
    Yes, there is, but only if you're using MIDP2.0.
    Check the API documentation of ChoiceGroup and see that there's a setFont(.., ..) method. The given index (int value) identifies the index of the element in the list for which the font will be set. This means that different elements in one choicegroup can have different fonts.
    Test it carefully, I've noticed that not all devices show correct behaviour on this. Also note that certain devices ignore certain font settings (for example italics, because a lot of native implementations won't have a font in italics).
    Good luck!

  • Set font on a text

    Hi!
    I've got some problem with setting font on a text, this is my coed:
    var ar_delaney_e:Font = new ar_delaney();
    textcount=1;
    //Setting a variable to     ar_delaney_e
    this["font_"+String(textcount)] = "ar_delaney_e";
    //Create a textFormat
    var textFormat:TextFormat = new TextFormat();
    //Setting font textformat fon to ar_delaney_e??
    textFormat.font = this["font_"+String(textcount)];
    //Set textformat to my text
    myText.defaultTextFormat = textFormat;
    Fon is embedded hav also tried textFormat.font = this["font_"+String(textcount)].fontName; instead of textFormat.font = this["font_"+String(textcount)]; but no one of this will work, how can you fix this?

    On stage I got a button with instance name add_text_btn, and a mc called "knapp_bild". So when pressing add_text_btn the function func_add_text_btn creates a movie clip with a text in it and also variables for size, color and font for the text. the two variables size and color works fine.
    add_text_btn.addEventListener(MouseEvent.CLICK, func_add_text_btn);
    function func_add_text_btn(event:MouseEvent):void{
    textcount++;
    var MovieClip:MovieClip = new MovieClip();
    MovieClip.x = 80;
    MovieClip.y = 60;
    MovieClip.alpha = 1;
    MovieClip.name="mc_text"+String(textcount);
    //Variables for font, size and color
    this["size_"+String(textcount)] = 40;
    this["color_"+String(textcount)] = "0x00CC00";
    this["font_"+String(textcount)] = "ar_delaney_e";
    textFormat.font = this["font_"+String(textcount)].fontName;
    textFormat.size = this["size_"+String(textcount)];
    textFormat.color = this["color_"+String(textcount)];
    var textField:TextField = new TextField()
    textField.defaultTextFormat = textFormat;
    textField.autoSize="left";
    textField.text = 'Text '+String(textcount);
    textField.name = "text"+String(textcount);  // give them names
    textField.background=false;
    textField.embedFonts=true;
    var mc_name=String("mc_text"+String(textcount));
    knapp_bild.addChild(MovieClip);
    MovieClip.addChild(textField);
    textField.mouseEnabled=false;
    MovieClip.width=textField.width;
    Later on in the program this["font_"+String(textcount)] will change but it dosen't work in the func_add_text_btn function now so let's just try to fix that first. Hope you can see something that mabe won't work and just ask if you got any qusetion. Thanks for your help!

  • How to set Font in JEditorPane

    i have problem set Font in JEditorPane.please help how to set Font in JEditorPane.
    My Code,
    JEditorPane view = new JEditorPane();
    view.setEditable(false);
    view.setContentType("text/html");
    JScrollPane scroll = new JScrollPane(view);
    scroll.setMinimumSize(new java.awt.Dimension(50, 50));
    scroll.setPreferredSize(new java.awt.Dimension(450, 300));
    scroll.setAutoscrolls(true);
    scroll.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scroll.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    view.setBorder(null);
    view.setFont(new java.awt.Font("Monospaced", 0, 12));
    view.setDragEnabled(true);
    view.setMargin(new java.awt.Insets(10, 10, 10, 10));
    view.setMinimumSize(new java.awt.Dimension(100, 20));
    view.setPreferredSize(new java.awt.Dimension(450, 300));

    Have a look at SimpleAttributeSet.

  • Set Font globally in JavaFX

    How I can set the Font type globally in JavaFX application?
    Is there any solution which I can use? in JavaFX 8 the default Font is changed I would like to use the same Font used in JavaFX 2.2.
    Ref Set Font globally in JavaFX - Stack Overflow

    Add a stylesheet with the rule
    .root { -fx-font: 13 "Comic Sans MS"; }
    or whatever font size and family you want.
    You can also use an inline style on the root node, e.g.,
    Parent root = scene.getRoot();
    root.setStyle("-fx-font: 13 \"Comic Sans MS\"; ");

  • How to set font for title and message in JOptionPane?

    Hi,
    I have following test code.
    JOptionPane.showMessageDialog(null, "Some Alert Message", "Alert", JOptionPane.ERROR_MESSAGE);In this code can we set font for "Some Alert Message", "Alert"?
    Regards,
    Kalyani......

    roll-your-own?
    import javax.swing.*;
    class Testing
      public static void main(String[] args)
        JDialog.setDefaultLookAndFeelDecorated(true);
        JOptionPane optionPane = new JOptionPane("<html><font size='5'>Your message here</font></html>");
        optionPane.setOptionType(JOptionPane.DEFAULT_OPTION);
        optionPane.setMessageType(JOptionPane.ERROR_MESSAGE);
        JDialog dialog = optionPane.createDialog(null, "Alert");
        dialog.getLayeredPane().getComponent(1).setFont(dialog.getFont().deriveFont(18f));//size = 18/whatever
        dialog.setModal(true);
        dialog.setVisible(true);
    }

  • How to set font for  JOptionPane.showMessageDialog() ?

    Hi,
    I want to set font for JOptionPane.showMessageDialog(). I have tried with following but it did not worked.
    javax.swing.UIManager.put("JOptionPane.font", "Verdana"); Do any one have idea how to do this. Your suggestion would be helpfull to me.
    Thank you.

    Then you'll have to loop over the components in the JOptionPane and setFont for each JButton. My SwingUtils class (search the net using Darryl SwingUtils, I can't give you a link as it's blocked from my office) can make this easier.
    Sample code:import darrylbu.util.SwingUtils;
    import java.awt.Font;
    import javax.swing.*;
    import javax.swing.plaf.FontUIResource;
    public class OptionPaneFonts {
       public static void main(String[] args) {
          UIManager.put("OptionPane.messageFont", new FontUIResource(new Font(
                  "Verdana", Font.BOLD, 32)));
          SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
                new OptionPaneFonts().makeUI();
       public void makeUI() {
          JOptionPane pane = new JOptionPane("So it's a date?",
                  JOptionPane.QUESTION_MESSAGE,
                  JOptionPane.YES_NO_CANCEL_OPTION,
                  UIManager.getIcon("OptionPane.questionIcon"),
                  new String[]{"Okey-dokey", "Not on your life!",
                     "Let me think about it"
                  }, null);
          for (JButton button : SwingUtils.getDescendantsOfType(JButton.class, pane)) {
             button.setFont(new Font("Tahoma", Font.ITALIC, 18));
          JDialog dialog = new JDialog((JWindow) null);
          dialog.setModal(true);
          dialog.add(pane);
          dialog.pack();
          dialog.setLocationRelativeTo(null);
          dialog.setVisible(true);
    }db
    Edited by: DarrylBurke -- shortened the code

Maybe you are looking for

  • Word Templates: Show all ordered Items

    Hi, I created a webservice in CRM 7.0 which would give back all ordered items. Now I want to make a list of these and create a Word Document out of it. I use the "Create from template" button in the attachment component. The order number etc is shown

  • Adobe Exchange Plugin Slowing Down Photoshop CC?

    Recently, Photoshop CC has been running really slow, and slowing down my computer as a whole. I've been trying to trouble shoot what was causing this, because it wasn't doing this previously. I believe I've narrowed it down to two things - Too many s

  • MergedCompositeChannels and smart object

    Is mergedCompositeChannels include previos smart filter ? My filter plugin drawing some lines on document for comic artists. I'm using Channnel Port Suite's ReadScaledPixels Callback with mergedCompositeChannels for preview. When I create the smart o

  • Help! File Upload Portlet

    Come on Plumtree Support, I know you can do it... How do I write a portlet that will upload a file and save it in a designated Knowledge Directory folder that the user picks from an existing Knowledge Directory folder list ? In addition, can I also p

  • Debug Javasctipt in Adobe Captivate

    What is the best way to debug JavaScript in Adobe Captivate? Using the below tutorial I am trying to set a cookie that remembers the menu of sections that have been viewed when the browser reopens. Basically sets and loads 6 variables with a cookie.