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 922315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:00:34+00:00 2026-05-15T19:00:34+00:00

After I add in this code to load the available font family and add

  • 0

After I add in this code to load the available font family and add it in to combobox

 GraphicsEnvironment ge = GraphicsEnvironment.
  getLocalGraphicsEnvironment();
String[] fontNames = ge.getAvailableFontFamilyNames();

It load very slow took about 7 seconds to show the page when i trigger the page. After i take it out it load fine as normal. Is there any solution, any people faceing the same problem?

  • 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-05-15T19:00:35+00:00Added an answer on May 15, 2026 at 7:00 pm

    The delay is due to the fact that getAvailableFontFamilyNames creates a 1 pt font for every font it can find. It allows the JVM to distinguish between fonts it can use and things that only look like they may be fonts.

    The best approach is to call it in a SwingWorker and then update the combo from the done method.

    update:
    The poster’s code updated to use the generified SwingWorker.
    Note: I am returning the array of names as it eliminates the need for synchronization.

    SwingWorker aWorker<String[],Void> = new SwingWorker<String[],Void>() {
        protected void done() { 
            String[] fontNames = get();
            for (int i = 0; i < fontNames.length; i++) 
                fontFamily.addItem(fontNames[i]);
        }
        @Override
        protected String[] doInBackground() throws Exception {
            GraphicsEnvironment env = GraphicsEnvironment .getLocalGraphicsEnvironment();
            return env.getAvailableFontFamilyNames(); 
        }
    };
    aWorker.run();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my js code: <script> function add(){ $('#myTable tr:last').after('<tr><td>4<span onclick=del()>del row</span></td></tr>'); } function
The XML dataset file after I add it to a DataSet looks like this:
My code as below, How to remove the white space after add hello. to
I want to add space after every two chars in a string. For example:
According to Facebook: The best place to put this code is right after the
I am check the retainCount for the subview after add to the view. the
I'm using CSS :before and :after to add dotted line visual elements to a
How I can add mp3 sounds to android project and after that add them
My eclipse rcp application depends on a set of eclipse plugins, after I add
I'm using 3 views in my calendar: month, agendaWeek, and agendaDay. After I add

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.