Change font of a single word in JTextArea

Hallo,
I would like to change the font of a word in a string in a JTextArea.
I only found jtextArea.setFont().
thank you.

Which basically means you need to use JTextPane as JTextArea does not support this. Here is a simple working example:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=342068

Similar Messages

  • On my MacBook Pro, sometimes when I click to close tabs in Safari the button will not work.  I have to click on some other part of the screen and then it will.  This happens in other programs like Word/Excel for changing font, etc. Solution/Suggestions?

    On my MacBook Pro, sometimes when I click to close tabs in Safari the button will not work.  I have to click on some other part of the screen and then it will.  This happens in other programs like Word/Excel for changing font, etc. Solution/Suggestions?

    Start up in Safe Mode.
    http://support.apple.com/kb/PH4373

  • Changing Fonts in JTextArea

    Is there a way to have a JTextArea select all the text currently typed inside it and have it change the font size? I've tried <JTextArea>.setFont(new Font("Serif", Font.PLAIN, 16) and that doesn't seem to work. Any ideas? I'm certain it's either a very simple fix or impossible...little middle ground.

    Remove the MouseListeners from the divider so it can't respond to MouseEvents:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.plaf.basic.*;
    public class SplitPaneFixedDivider extends JFrame
         public SplitPaneFixedDivider()
              JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
              JPanel top = new JPanel();
              top.setPreferredSize( new Dimension(500, 400) );
              top.setBackground( Color.RED );
              splitPane.setTopComponent( top );
              JPanel bottom = new JPanel();
              bottom.setPreferredSize( new Dimension(500, 100) );
              bottom.setBackground( Color.BLUE );
              splitPane.setBottomComponent( bottom );
              getContentPane().add(splitPane);
              BasicSplitPaneUI splitPaneUI = (BasicSplitPaneUI)splitPane.getUI();
              Component divider = splitPaneUI.getDivider();
              divider.setCursor(null);
              MouseListener[] actions = (MouseListener[])divider.getListeners(MouseListener.class);
              for (int i = 0; i < actions.length; i++)
                   divider.removeMouseListener( actions[i] );
              MouseListener[] action3 = (MouseListener[])splitPane.getListeners(MouseListener.class);
              for (int i = 0; i < action3.length; i++)
                   splitPane.removeMouseListener( action3[i] );
              setResizable( false );
         public static void main(String[] args)
              SplitPaneFixedDivider frame = new SplitPaneFixedDivider();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }Of course this defeats the purpose of using a JSplitPane, so an easier solution, as suggested above, is to just use a LayoutManager to mimic the look of a JSplitPane. I prefer the BorderLayout:
              JPanel top = new JPanel();
              top.setPreferredSize( new Dimension(500, 400) );
              top.setBackground( Color.RED );
              getContentPane().add(top, BorderLayout.NORTH );
              JPanel middle = new JPanel();
              middle.setPreferredSize( new Dimension(500, 10) );
              getContentPane().add( middle );
              JPanel bottom = new JPanel();
              bottom.setPreferredSize( new Dimension(500, 100) );
              bottom.setBackground( Color.BLUE );
              getContentPane().add(bottom, BorderLayout.SOUTH );
              setResizable( false );

  • How do I change the style of one word in a paragraph

    I've been fighting with this issue for a while and after google searches and switching to word for mac (ugh) I have decided to ask for help!
    I have a paragraph in my document, and I'd like to format a single word in that paragraph to a different font style. When I select the word, and only the word that needs to have the different style, and click the style from the format tab on the right, the entire paragraph is changed to that style.
    I've tried selecting the word and clicking on the style, I've tried just putting the cursor on the word, but every time the entire paragraph is changed to the selected style. Just to clarify, I dont simply mean changing the font, but using a predefined style from the document.
    Any IDEAS?

    OK! Nevermind, I figured it out.
    The Styles that show at the top of the Format tab are Paragraph Styles. There is a tiny dropdown under Font called Character Styles. I had to preset the style there and use that for individual words.

  • Cannot change font size when highlighted. All font changes. How do I correct this?

    Frustrated as to why when I highlight a single word to change font size or style every word on the page follows the adjustment. I need to be able to change words individually with font, size and color.

    I have stopped using Text Edit as I find it flaky. Instead I prefer Bean:
    http://www.bean-osx.com/Bean.html
    which does not have that problem!

  • Changes font and size when cutting and pasting

    Cutting and pasting in a document made with a single font and size results in the moved word changing font and size. Checked all preferences, etc. and can't figure it out. Thanks, Jim

    Hello
    Look at:
    http://discussions.apple.com/thread.jspa?messageID=607239
    Yvan KOENIG (from FRANCE mardi 26 septembre 2006 20:03:27)

  • Word wrap splitting single word

    When I have a line that doesn't fit a single word, instead of trying again on the next parcel where it might fit, TLF (or maybe text.engine)  splits the single word between multiple lines.  Is there any way to change this behavior?

    One my colleagues who works on the Player reminded me that there *is* an option for controlling this behavior in the Player, so I was wrong about that, I'm sorry. The fitSomething parameter to TextBlock.createTextLine would get you what you want. I think it would get you the side effect that a long word might not fit anywhere, so you see the text in the container (and posssibly also other linked containers) stop short because of a long word you can't see (the one that didn't fit). If the long word is at the start of the container, you'd see the whole container empty. But this could be what you want.
    So if you're overriding our code anyway, you could also try changing the way createTextLine is called.
    - robin

  • How to change fonts in iCal?

    How to change fonts in iCal?  I can't harly read my calendar-tiny print size.  How could I change the font size?

    Your question really got me thinking.   Actually, I don't think you should feel like an idiot at all.  I think it is Apples failure that they made this difficult.  Seriously, who would ever think to press Command and arrow to switch months?  The little arrows next to the word Today are so small and inconspicuous that I remember having this very same question when I started using iCal too. 
    So, here is what I did to make it easier for my wife that uses iCal too. 
    Open System Preferences, Keyboard, Keyboard Shortcuts Tab, and finally Application Shortcuts.
    Click on the Plus symbol under the right hand pane.
    Select iCal from the Application list
    Add two shortcuts:  One named Next and the other named Previous and press your desired Keyboard Shortcut.
    I assigned the left arrow and right arrow for these tasks.
    Now it makes more sence for someone that is not used to Apples idotic way of doing things. ;-)
    I use keyboard shortcuts all over the place.  Actually, sometimes it gets me into trouble when I use someone elses computer and my shortcuts don't work.  I blame their computer for it and forget it was my "tuning".

  • Change font size on macbook pro 15 retina

    HELP... Cant see the words
    can someone please tell me how to change font size on macbook pro 15 retina... I have this HUGE screen but the font on the screen is SUPER small.... can someone help me

    Sorry, OS X hasn't evolved to a scalable UI type for hard of seeing users. If you drop the resolution your type gets blurry.
    However I have two solutions.
    1: You hit System Preferences > Accessibility and set a control key for zoom/in out, set the zoom to where the pointer is at and get a third party scroll wheel mouse. This way you hold the control key and can zoom in/out anywhere the mouse is pointed at.
    2: You follow my User Tip here and use Firefox with the associated add-ons.
    Since Firefox is customizable, your able to create larger menu type and have web pages automatically zoomed (full page, graphics and all) to your minimal needs.
    Also FF will remember your window size so your not having to resize that each time you open the program. There is also a Full screen option.
    Since web browsing takes up a lot of time on machines, at least you have that part licked. If you use web based email like GMail, since it's in a web browser that is zoomed as well.
    Web browsing for hard of seeing users

  • Change font size in Z-Report created from template

    A Z-report is being created from template which uses WWI.INI file integration to generate the report in Microsoft Word. In that report the text from phrases is passing over the specified text box. So all the phrases are not displayed.
    Now user either want the size of font to decrease or change the size of the box.
    We are going ahead with changing the font size. To do so we are editing the template in CG42. Is this approach is correct or we can change the font size from somewhere else??. If yes ,then how to proceed ??
    Your help will be greatly appreciated as I am new to EHS and have very limited knowledge.

    Hello Aasim,
    Just try it out
    If you are afraid to destroy something on the WWI template create a copy of the template and do your testing there....
    Read the SAP help on WWI.
    Can I edit font in the Microsoft Word file which is generated after I click "Document (F7)" button??
    Yes you can.
    If yes , then suppose I change the font size in a text box there.Does the font of phrase's text also changes accordingly when the report is generated.
    Yes.
    And does that change is for all the phrases in that text box ( since no. of phrases varies according to the specification)???
    Yes it will change the font size for all phrases in that text box.
    There is an option in WWI where you can change the text size dynamically if the text is in a real text box.
    However I'm currently not sure if this works for all kind of WWI templates or only for labels.
    Hope this helps
    Mark

  • Change Font in TextArea

    Hello,
    I'm working on a small Editor-App and I just want to add the oppurtunity to change fonts. I'm using a TextArea and it should be possible to change the font for parts of the TextArea, not just for the whole one.
    Thanks for your solutions
    Greets
    Thomas

    The java.awt.TextArea doesn't support multiple fonts in a single TextArea. AFAIK, if you want to use java.awt, you'll have to write your own. The javax.swing text classes make it easier.

  • Change font in String ?

    Is it possible to change font of a String like U cant do it with html coding? If I have :
    String text ="this is a text";
    can I change the color and the size of the text and so on, instead of the default ones?

    You can set these attributes for the component which displays your string. For example, if you want to use a JLabel to display your String you can set the font, font style and colour of the JLabel.
    JLabel lab = new JLabel(String);
    lab.setFont(new Font("Arial", Font.BOLD, 16);
    lab.setForegound(Color.red);You can do the same for JTextAreas and JTextFields. However, all of the text in these components will take the same formatting. JTextPane and JEditorPane are more flexible in that you can display text in various colours and fonts etc.
    have a look at the Swing Tutorial. Follow the link to Text Components.

  • Change font in Hangman widget

    Is there anyway to change the font for the letters in the hangman widget?  I love the game, but the font is really hard to read.  I am working with low level literacy learners, and this would be a fantastic game, but the font has to be cleaner so it is more accessible.  For that matter - is there a way to change fonts in ANY of the widgets?  Again, it goes to the accessibility factor, and some fonts are just so tiny (or in some cases too big) for our resources.  Would be nice to see Adobe work in customizations for this into the widgets. 

    Magritte,
    First of all save any important notes that you may have using a word processing program.
    Then find the widget-com.apple.widget.stickies.plist file in your Macintosh HD/Users/yourusername/Library/Preferences folder, drag it to the Desktop and log out/in or restart and let us know what happens.
    ;~)

  • Changing font in a textarea

    Hey,
    I was wondering how would I code my textarea so that when I choose to change font, it will not change the font of previously entered text.
    Thanks in advance.

    If this "textarea" is a TextArea or a JTextArea or a JTextField, then the answer is that you can't. That tutorial you were shown tells you how to do what you want... the very first paragraph differentiates between "styled" components (what you are asking for) and "unstyled" components (what you have, probably).

  • Changing fonts and font sizes with hotkeys

    In MS Word you can select text and hit Ctrl + Shift + "F" to get to the drop down menu to change the font and just hit tap to change the size. Is that possible in Pages?

    Use cmd shift + or - to change font size.
    It may be cmd - for the reduce size, I may have regularised the keyboard shortcut on my system.
    You will need to use the toolbar or the type palette to change the font itself.
    Peter
    btw Once you are in the various pulldown menus, including the toolbar Type menus, you can use your up or down keys plus enter or return to change selections.

Maybe you are looking for