Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9151793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:53:21+00:00 2026-06-17T11:53:21+00:00

Anyone here using the Alloy Look and Feel? I’m facing a strange bug with

  • 0

Anyone here using the Alloy Look and Feel? I’m facing a strange bug with anti-aliasing and JTextComponents. Alloy by default does not use anti-aliasing at all, so I have to force it by creating my own UI-classes. This works fine in most cases, but there are certain characters that wreak havoc to anti-aliasing.

For example, if the Alloy is set as a Look and Feel, and I insert some Hebrew text into a JTextComponent, e.g: שלום, מה שלומך שמי הוא האקזיד’, the WHOLE JTextComponent suddenly loses anti-aliasing – permanently.

The strange thing is that I do not even extend the AlloyTextPaneUI, but BasicTextPaneUI to do the anti-aliasing, so I am puzzled where the Alloy comes into the picture (other Look and Feels appear to work just fine).

I am having very hard time tracing this bug… Anyone faced the same issue?

Here’s a short example demonstrating the problem:

import com.incors.plaf.alloy.AlloyLookAndFeel;
import com.incors.plaf.alloy.themes.glass.GlassTheme;

import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTextPaneUI;
import javax.swing.text.BadLocationException;
import javax.swing.text.StyledDocument;
import java.awt.*;

public class Scrap {

    static {
        // NOTE: You need a license code for Alloy!
        AlloyLookAndFeel.setProperty("alloy.licenseCode", "your license here");

        UIManager.put("TextPaneUI", MyTextPaneUI.class.getName());

        try {
            UIManager.setLookAndFeel(new AlloyLookAndFeel(new GlassTheme()));
        } catch (UnsupportedLookAndFeelException e) {
            e.printStackTrace();
        }

        // With system Look and Feel everything works just fine...
//      try {
//          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//      } catch (ClassNotFoundException e) {
//          e.printStackTrace();
//      } catch (InstantiationException e) {
//          e.printStackTrace();
//      } catch (IllegalAccessException e) {
//          e.printStackTrace();
//      } catch (UnsupportedLookAndFeelException e) {
//          e.printStackTrace();
//      }
    }

    public static void main(final String args[]) {
        JTextPane text = new JTextPane();

        text.setFont(new Font("Monospaced", Font.PLAIN, 14));

        StyledDocument doc = text.getStyledDocument();

        try {

            doc.insertString(doc.getLength(), "Here's some regular text. Nice and smooth with anti-aliasing.\n\n", null);

            doc.insertString(doc.getLength(), "Here's some more text Blaa Blaa Blaaa. Lorem ipsum... now try to uncomment the Hebrew text.\n\n", null);

            // Try to uncomment this line and the anti-aliasing breaks for the whole JTextPane
//          doc.insertString(doc.getLength(), "שלום, מה שלומך שמי הוא האקזידן\n\n", null);

            // Here's another strange glyph that breaks the anti-aliasing
//          doc.insertString(doc.getLength(), "ಠ", null);

        } catch (BadLocationException e) {
            e.printStackTrace();
        }

        JFrame frame = new JFrame();

        JScrollPane scroll = new JScrollPane();
        scroll.setViewportView(text);
        scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        frame.add(scroll, BorderLayout.CENTER);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setSize(600, 300);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    public static class MyTextPaneUI extends BasicTextPaneUI {

        @Override
        protected void paintSafely(Graphics g) {
            Graphics2D g2 = (Graphics2D) g;
            g2.setRenderingHint(
                            RenderingHints.KEY_TEXT_ANTIALIASING,
                            RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
            super.paintSafely(g);
        }

        public static ComponentUI createUI(JComponent c) {
            return new MyTextPaneUI();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:53:22+00:00Added an answer on June 17, 2026 at 11:53 am

    After some very frustrating experimentation I got it fixed.. I’m still not sure what exactly caused it but here’s how I fixed it. There is apparently a key missing/broken in the UIDefaults in Alloy (I don’t know which one). So I added all the defaults from the initial Look and Feel to the Alloy properties. This is kind of a quick and dirty solution (only problem I had was that the menus became non-opaque), but it’s good enough for my needs. Maybe someone else finds it helpful as well.

    AlloyLookAndFeel laf = new AlloyLookAndFeel(theme) {
        @Override
        public UIDefaults getDefaults() {
            UIDefaults defs = new UIDefaults();
    
            defs.putAll(UIManager.getLookAndFeelDefaults());
    
            initClassDefaults(defs);
            initSystemColorDefaults(defs);
            initComponentDefaults(defs);
    
            defs.put("Menu.opaque", true);
    
            return defs;
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the Jquery Datepicker found here . Does anyone know how I
anyone using the jQuery Elastic plugin around here? Pretty handy but I just don't
Anyone out there using the FTUtils library for iPhone development? Following the instructions here
Does anyone here use phpmailer? I downloaded the files for phpmailer 5.2.1 (the newest
Does anyone here know of a Javascript application (something similar to Lightbox, only not
Has anyone attempted using perlembed in Mono on Linux? Here is the link: perlembed
Does anyone else think Silverlight 4 security is a bit screwball? Look at the
Has anyone here created a Flash site or application that is ADA (Section 508)
Can anyone here help me with the integration of the DailyMotion API? I am
Has anyone here tried to use a custom animation with MBProgressHUD. There is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.