examples please

Posted on 2003-02-19
Medium Priority
Last Modified: 2010-03-31
can anyone tell me how to make a swing component transparent to a specified level. i need some code thank you

Question by:Predikshon
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

by:Mark Roberts
ID: 7983214
To make a component transparent you would us the setBackground(color) method and pass it a color with the alpha set to the appropriate level of transparency.

Accepted Solution

Mark Roberts earned 600 total points
ID: 7983303

searchBtn = new JButton("Search");
searchBtn.setBackground(new Color(0,255,0,0));

This would create a JButton with it's color set to Green but with total transparency (not very useful since the button will actually end up being the same color as the component behind it).  Using values from 0 - 255 you can adjust the amount of transparency.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question