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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:10:04+00:00 2026-06-14T20:10:04+00:00

Right now I am making my jinternal frames transparent using this code: double rgbConversionBackpack

  • 0

Right now I am making my jinternal frames transparent using this code:

double rgbConversionBackpack = Double.parseDouble(MyClient.configFile.getProperty("BACKPACK_FRAME_ALPHA"));
double tmp = (rgbConversionBackpack / 100.0) * 255.0;
this.getContentPane().setBackground(new Color(140, 0, 0, (int)tmp));
this.setOpaque(false);

I have code on the sliders to set the alpha which all works perfectly and saves it to a properties file, yada, yada, yada. The question is how do I make the entire JInternal Frame transparent.

Right now I have only be able to set the content pane, and any other panels (etc) that are in the jinternal frames transparent, but I want to make the entire JinternalFrame(borders and all) transparent.

Screenshot below shows how on the backpack the red tinted are is partially transparent and looks decent, but still want the border to be transparent also.

enter image description here

Is there a way to override the draw super method for each of my classes the extend JInternalFrame to have it draw semi transparent(depending on value obviously)?

  • 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-14T20:10:05+00:00Added an answer on June 14, 2026 at 8:10 pm

    You could do this by changing the AlphaComposite that the JInternalFrame’s paint method uses. You have to be careful though to repaint the containing top level window at the location of the transparent component lest you have funny side effects. For example:

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    
    @SuppressWarnings("serial")
    public class TransparentInternalFrame extends JDesktopPane {
       private static final Color COLOR_1 = Color.red;
       private static final Color COLOR_2 = Color.blue;
       private static final float PT_2 = 30f;
       private static final int PREF_W = 800;
       private static final int PREF_H = 500;
    
       public TransparentInternalFrame() {
          add(new MyInternalFrame("Foo", 50, 50, 300, 300, 0.2f));
          add(new MyInternalFrame("Foo", 400, 100, 300, 300, 0.4f));
       }
    
       @Override
       protected void paintComponent(Graphics g) {
          super.paintComponent(g);
          Graphics2D g2 = (Graphics2D) g;
          g2.setPaint(new GradientPaint(0, 0, COLOR_1, PT_2, PT_2, COLOR_2, true));
          g2.fillRect(0, 0, getWidth(), getHeight());
       }
    
       @Override
       public Dimension getPreferredSize() {
          return new Dimension(PREF_W, PREF_H);
       }
    
       private static void createAndShowGui() {
          TransparentInternalFrame mainPanel = new TransparentInternalFrame();
    
          JFrame frame = new JFrame("TransparentInternalFrame");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.getContentPane().add(mainPanel);
          frame.pack();
          frame.setLocationByPlatform(true);
          frame.setVisible(true);
       }
    
       public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
             public void run() {
                createAndShowGui();
             }
          });
       }
    }
    
    @SuppressWarnings("serial")
    class MyInternalFrame extends JInternalFrame {
       private AlphaComposite comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
    
       public MyInternalFrame(String title, int x, int y, int w, int h, final float alpha) {
          super(title);
          setClosable(true);
          setBounds(x, y, w, h);
          setVisible(true);
    
          int sliderValue = (int) (alpha * 100);
          comp = comp.derive(alpha);
          final JSlider slider = new JSlider(0, 100, sliderValue);
          slider.setMajorTickSpacing(20);
          slider.setMinorTickSpacing(5);
          slider.setPaintLabels(true);
          slider.setPaintTicks(true);
          slider.setBorder(BorderFactory.createTitledBorder("Alpha Value"));
          slider.addChangeListener(new ChangeListener() {
    
             @Override
             public void stateChanged(ChangeEvent cEvt) {
                float alpha = (float) slider.getValue() / 100f;
                setAlpha(alpha);
                MyInternalFrame.this.repaint();
    
                Window win = SwingUtilities.getWindowAncestor(MyInternalFrame.this);
                win.repaint();
             }
          });
    
          add(new JLabel("My Label", SwingConstants.CENTER));
          add(slider, BorderLayout.SOUTH);
       }
    
       @Override
       public void paint(Graphics g) {
          Graphics2D g2 = (Graphics2D) g;
          g2.setComposite(comp);
          super.paint(g);
       }
    
       public void setAlpha(float alpha) {
          comp = comp.derive(alpha);
       }
    }
    

    AlphaComposite Demo

    But note that this program is not fully fixed. You’ll still see pixel errors if you drag one JInternalFrame over another. I still need to work the bugs out…

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

Sidebar

Related Questions

I'm making PriorityQueue<T> classes, and right now I am using List<T> as a backing
I'm making a vector application for Windows. Right now i'm using wglUseFontOutlines to generate
I am making a javascript code editor online, and right now I'm doing the
This is been making my programming really frustrating lately. I´m in Argentina right now
Right now, im using drupal for making a site. Im modifying the drupals user
Well I'm making profile pages so right now it looks like this http://example.com/random/?user=Robert What
I am making an app for twitter integration using Twitter4j API. Right now my
Right Now I am making a twitter app and I am Using IFTweetLabel. I
right now I'm creating an array and using: render :json => @comments This would
I am making a simple numeric expression solver using regexes and right now I'm

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.