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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:00:49+00:00 2026-06-10T01:00:49+00:00

In the preferences of my Java application they can set the debug level presented

  • 0

In the preferences of my Java application they can set the debug level presented as a JComboBox containing the seven default levels. The list contains SEVERE,WARNING,INFO ecetera which is rather ugly and Id rather replace with ‘Severe, Warning’ for english.

java.util.logging.Level as used by java logging has contructors that can take a different resource bundle so I thought of sublassing Level so that i can chnage the resource bundle to my own.

But how do I get java logging to use modified levels

EDIT

Used a modified version of the example class given in kans answer below

class LevelItem extends Object
{
    public final Level level;
    public LevelItem(Level level)
    {
        this.level = level;
    }

    public String toString()
    {
        return level.getLocalizedName().substring(0,1)+
               level.getLocalizedName().substring(1).toLowerCase();
    }

    public boolean equals(Object obj) 
    {
        return (obj instanceof LevelItem &&
            (this.level.equals((((LevelItem) obj).level))));
    }
}

but need to add equals method so setSelectedItem() works for me in combobox

i.e

 debugLevelCombo = new JComboBox();
 debugLevelCombo.addItem(new LevelItem(Level.SEVERE));
 debugLevelCombo.addItem(new LevelItem(Level.WARNING));
 debugLevelCombo.addItem(new LevelItem(Level.INFO));
 debugLevelCombo.addItem(new LevelItem(Level.CONFIG));
 debugLevelCombo.addItem(new LevelItem(Level.FINE));
 debugLevelCombo.addItem(new LevelItem(Level.FINER));
 debugLevelCombo.addItem(new LevelItem(Level.FINEST));
 debugLevelCombo.setSelectedItem(new
      LevelItem(Level.parse(UserPreferences.getInstance().getDebugLevel())));
  • 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-10T01:00:51+00:00Added an answer on June 10, 2026 at 1:00 am

    You must not change classes inside “java” package. It is part of JDK. And obviously it is not an option for GUI. Just learn more how to use JComboBox to render values differently. E.g. you could create a wrapper class:

    class LevelItem
    {
       private final Level level;
       public LevelItem(Level level) {this.level=level;}
       public String toString()
       {
         if(Level.WARNING.equals(level) return "Warning";
         if(Level.INFO.equals(level) return "Information";
    ...
         }
       }
    }
    

    And use it for combobox values. Or maybe it is possible to make a custom renderer. This is example how to create a customized rednerer: How to use Map element as text of a JComboBox

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I write system preferences with Java, using Preferences.systemRoot() ? I tried with:
On Windows, the Java preferences, which you access in your application from java.util.prefs.Preferences are
Can we allow user to set and save application data and temp data using
I am learning how to set up preferences in an android application. I have
The Java Preferences application on my OS X Lion workstation indicates that I have
I have a Grail application that references a Java library (as an IntelliJ Module
What is the best way to export the eclipse/java preferences to the database programmatically?
In eclipse preferences Windows > Preferences > Java > Junit What effect does the
Preferences objects present a way to store arbitrary data into Rally which can be
I have implemented an Java Swing application that uses an embedded JavaDB database. The

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.