LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 01-27-2004, 05:38 AM   #1
rmartine
Member
 
Registered: Dec 2002
Location: San Luis Obispo, CA
Distribution: Fedora Core 3
Posts: 618

Rep: Reputation: 30
Java font issue


I wrote a little Text Editor using the javax.swing package and noticed the fonts looked ugly. Anti-aliasing is turned off by default.

As an experiment, I created a subclass for a JTextArea and wrote a paintComponent() routine that enabled anti-aliasing. The fonts look blurry and that is a problem.

I have another version of the editor using the heavyweight components of just awt and the anti-aliasing looks great. I'm guessing it's because the heavyweights use native platform code.

Could someone point me in some kind of direction?? Here is my paintComponent() function and some other code related to how everything is put together. Am I missing something in there?

Code:
public class TextEditor {

AntiAliasedJTextArea textArea;

textArea = new AntiAliasedJTextArea();

textArea.setEditable(true);
textArea.setFont(new Font("Arial", Font.PLAIN, 14));

rootContainer.add(scrollPane); // The JTextArea is added to the
                               // JScrollPane then inserted to the
                               // rootContainer

}




private class AntiAliasedJTextArea extends JTextArea {
    	
    	public AntiAliasedJTextArea() {	}
    	
    	protected void paintComponent(Graphics g) {
    		
    		// Create a new Graphics 2D
    		Graphics2D 		g2d = null;
    		
    		
    		g2d = (Graphics2D) g ; 
    		
    		// Set rendering Hints
    		g2d.setRenderingHints(new RenderingHints(
    			RenderingHints.KEY_ANTIALIASING, 
    			RenderingHints.VALUE_ANTIALIAS_ON ));
    		
    		// Paint component	
    		super.paintComponent(g);	
    	}

    }
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Font issue. Wr3ck Slackware 4 09-09-2005 04:05 PM
NVidia Font Issue RySk8er30 Linux - Newbie 1 03-20-2005 01:21 PM
Mandrake 10.1 Font Issue. jsi386 Mandriva 3 01-21-2005 08:45 AM
Photoshop Font issue nenyo Linux - Software 3 01-13-2005 06:27 PM
Weird terminal font issue geomatt Linux - Software 1 10-12-2004 05:46 AM


All times are GMT -5. The time now is 04:42 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration