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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:52:02+00:00 2026-06-09T21:52:02+00:00

JDK 7 added a new transparency slider to the JColorChooser : The problem is

  • 0

JDK 7 added a new transparency slider to the JColorChooser:

enter image description here

The problem is that I do not want to allow my users to pick transparent colors. Unfortunately, there doesn’t seem to be an easy way to disable the slider.

One way to get rid of the transparency is to just create a new color based on the selected one but removing the alpha value. However, this gives a false impression to the user as the slider now effectively does nothing and I would hate to have a useless UI element around.

So my question is, what’s the best way to get rid of the transparency slider?

P.S.: IMO, it’s weird that they would just add the slider and make it the default behavior. This might cause a lot of bugs in JDK 6 programs that do not expect the color chooser to return a color with an alpha value.

  • 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-09T21:52:03+00:00Added an answer on June 9, 2026 at 9:52 pm

    According to the documentation, it’s possible to just modify/configure the existing classes. So recommended way to go is therefore to create your own ChooserPanels (they need to extend AbstractColorChooserPanel) and then invoke

    JColorChooser jc = new JColorChooser();
    jc.setChooserPanels(new AbstractColorChooserPanel[]{yourChooserPanel});
    

    Alternatively, if yor aree looking for a faster/nastier/uglier way to do it, wrote this for you:

    private static void removeTransparencySlider(JColorChooser jc) throws Exception {
    
        AbstractColorChooserPanel[] colorPanels = jc.getChooserPanels();
        for (int i = 1; i < colorPanels.length; i++) {
            AbstractColorChooserPanel cp = colorPanels[i];
    
            Field f = cp.getClass().getDeclaredField("panel");
            f.setAccessible(true);
    
            Object colorPanel = f.get(cp);
            Field f2 = colorPanel.getClass().getDeclaredField("spinners");
            f2.setAccessible(true);
            Object spinners = f2.get(colorPanel);
    
            Object transpSlispinner = Array.get(spinners, 3);
            if (i == colorPanels.length - 1) {
                transpSlispinner = Array.get(spinners, 4);
            }
            Field f3 = transpSlispinner.getClass().getDeclaredField("slider");
            f3.setAccessible(true);
            JSlider slider = (JSlider) f3.get(transpSlispinner);
            slider.setEnabled(false);
            Field f4 = transpSlispinner.getClass().getDeclaredField("spinner");
            f4.setAccessible(true);
            JSpinner spinner = (JSpinner) f4.get(transpSlispinner);
            spinner.setEnabled(false);
        }
    }
    

    Good luck with it 🙂

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

Sidebar

Related Questions

I have a problem, concerning the jdk/jre usage of my eclipse. I know that
I want to install JDK 1.5 and 1.6 on XP, is it possible? how
I have created the project using the JDK 1.4. Now I want to use
So I want to create a JDBC connection to MySQL server that is installed
I have added my mysql-connector-java-5.1.18-bin.jar to jre and jdk libs. And Here it is:
I installed JDK 7 and Eclipse 3.6M6 . Then, I added JRE 7 as
I'm trying to get the new 1.7 JDK working with Eclipse (this is Oracle's
The JDK documentation for java.lang.String.hashCode() famously says: The hash code for a String object
I am using jdk 1.6 My main method : exmp3<String , Integer> exmp3 =
I had java jdk 1.6 installed, and today installed jdk 1.7 becaused needed to

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.