Having a Translucent window, how to make a button not translucent?

Seems to be a simple question. I have a JFrame that I make translucent following this guide:
http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/
I add a JPanel to this frame and it is also translucent and then I add JButtons to the JPanel. I want the buttons to be solid and not translucent.
Having great problems, sure be happy if I got any advice.
Shares some code, dont know if it helps, the buttons use imageicons. This is the Jpanel code:
public class ClockFrame extends JPanel {
     private ClassLoader cl;
     private JButton[][] clock = new JButton[6][60];
     boolean gradient = true;
     public ClockFrame()
          this.setOpaque(!gradient);
          this.setLayout(null);
          this.setVisible(true);
          this.setDoubleBuffered(false);
          cl = this.getClass().getClassLoader();
          init();
      protected void paintComponent(Graphics g) {
         if (g instanceof Graphics2D && gradient) {
             final int R = 240;
             final int G = 240;
             final int B = 240;
             Paint p =
             new GradientPaint(0.0f, 0.0f, new Color(R, G, B, 0),
                 getWidth(), getHeight(), new Color(R, G, B, 255), true);
             Graphics2D g2d = (Graphics2D)g;
             g2d.setPaint(p);
             g2d.fillRect(0, 0, getWidth(), getHeight());
         } else {
             super.paintComponent(g);
private void buttonHelper(JButton b, double radix, int type)
          b.setBorderPainted(false);
          b.setContentAreaFilled(false);
          b.setFocusable(false);
          b.setBounds(findPosX(radix,type) + 250, findPosY(radix,type) + 200, 200, 200);
          this.add(b);
     }

http://picasaweb.google.com/lh/photo/8g0eDzQs_0Qt3MJKBLMTDQ?feat=directlink
can you see this image? think it shows pretty clearly what effect I wish to have. Picture is taken running from eclipse.
I think it is a pretty interesting problem so will share rest of the code.
First is Main JFrame class, second is AWTUtilitiesWrapper from guide posted in first post.
public class MainFrame {
     private static final long serialVersionUID = 1L;
     private static JFrame frame;
     private static Container c;
    private boolean isTranslucencySupported;
    private GraphicsConfiguration translucencyCapableGC;
     public MainFrame()
          frame = new JFrame( "Time" );
          frame.setSize(800     ,      600);
          frame.setResizable(false);
          c = frame.getContentPane();
          c.setLayout(new OverlayLayout(c));
          c.add(new ClockFrame());
        isTranslucencySupported = AWTUtilitiesWrapper.isTranslucencySupported(AWTUtilitiesWrapper.PERPIXEL_TRANSLUCENT);
        translucencyCapableGC = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
        if (!AWTUtilitiesWrapper.isTranslucencyCapable(translucencyCapableGC)) {
            translucencyCapableGC = null;
            GraphicsEnvironment env =
                    GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice[] devices = env.getScreenDevices();
            for (int i = 0; i < devices.length && translucencyCapableGC == null; i++) {
                GraphicsConfiguration[] configs = devices.getConfigurations();
for (int j = 0; j < configs.length && translucencyCapableGC == null; j++) {
if (AWTUtilitiesWrapper.isTranslucencyCapable(configs[j])) {
translucencyCapableGC = configs[j];
if (translucencyCapableGC == null) {
isTranslucencySupported = false;
          //sets custom location on screen and sets no default os border
          frame.setLocation(300,100);     
          frame.setUndecorated(true);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setVisible(true);
          init();
     public static Container getContainer()
          return c;
     private void init()
          if(isTranslucencySupported)
          AWTUtilitiesWrapper.setWindowOpacity(frame, 0.7f);
          AWTUtilitiesWrapper.setWindowOpaque(frame, false);
import java.awt.GraphicsConfiguration;
import java.awt.Shape;
import java.awt.Window;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
* @author Anthony Petrov
public class AWTUtilitiesWrapper {
private static Class<?> awtUtilitiesClass;
private static Class<?> translucencyClass;
private static Method mIsTranslucencySupported, mIsTranslucencyCapable, mSetWindowShape, mSetWindowOpacity, mSetWindowOpaque;
public static Object PERPIXEL_TRANSPARENT, TRANSLUCENT, PERPIXEL_TRANSLUCENT;
static void init() {
try {
awtUtilitiesClass = Class.forName("com.sun.awt.AWTUtilities");
translucencyClass = Class.forName("com.sun.awt.AWTUtilities$Translucency");
if (translucencyClass.isEnum()) {
Object[] kinds = translucencyClass.getEnumConstants();
if (kinds != null) {
PERPIXEL_TRANSPARENT = kinds[0];
TRANSLUCENT = kinds[1];
PERPIXEL_TRANSLUCENT = kinds[2];
mIsTranslucencySupported = awtUtilitiesClass.getMethod("isTranslucencySupported", translucencyClass);
mIsTranslucencyCapable = awtUtilitiesClass.getMethod("isTranslucencyCapable", GraphicsConfiguration.class);
mSetWindowShape = awtUtilitiesClass.getMethod("setWindowShape", Window.class, Shape.class);
mSetWindowOpacity = awtUtilitiesClass.getMethod("setWindowOpacity", Window.class, float.class);
mSetWindowOpaque = awtUtilitiesClass.getMethod("setWindowOpaque", Window.class, boolean.class);
} catch (NoSuchMethodException ex) {
Logger.getLogger(AWTUtilitiesWrapper.class.getName()).log(Level.SEVERE, null, ex);
} catch (SecurityException ex) {
Logger.getLogger(AWTUtilitiesWrapper.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(AWTUtilitiesWrapper.class.getName()).log(Level.SEVERE, null, ex);
static {
init();
private static boolean isSupported(Method method, Object kind) {
if (awtUtilitiesClass == null ||
method == null)
return false;
try {
Object ret = method.invoke(null, kind);
if (ret instanceof Boolean) {
return ((Boolean)ret).booleanValue();
} catch (IllegalAccessException ex) {
Logger.getLogger(AWTUtilitiesWrapper.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(AWTUtilitiesWrapper.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvocationTargetException ex) {
Logger.getLogger(AWTUtilitiesWrapper.class.getName()).log(Level.SEVERE, null, ex);
return false;
public static boolean isTranslucencySupported(Object kind) {
if (translucencyClass == null) {
return false;
return isSupported(mIsTranslucencySupported, kind);
public static boolean isTranslucencyCapable(GraphicsConfiguration gc) {
return isSupported(mIsTranslucencyCapable, gc);
private static void set(Method method, Window window, Object value) {
if (awtUtilitiesClass == null ||
method == null)
return;
try {
method.invoke(null, window, value);
} catch (IllegalAccessException ex) {
Logger.getLogger(AWTUtilitiesWrapper.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(AWTUtilitiesWrapper.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvocationTargetException ex) {
Logger.getLogger(AWTUtilitiesWrapper.class.getName()).log(Level.SEVERE, null, ex);
public static void setWindowShape(Window window, Shape shape) {
set(mSetWindowShape, window, shape);
public static void setWindowOpacity(Window window, float opacity) {
set(mSetWindowOpacity, window, Float.valueOf(opacity));
public static void setWindowOpaque(Window window, boolean opaque) {
set(mSetWindowOpaque, window, Boolean.valueOf(opaque));

Similar Messages

  • How to make a button not clickable???

    i wanna make a button not clickable, once it is clicked... help me to do this
    Thanks
    Rubin

    you can either call setEnabled(false) or remove the listenerFor sake of GUI ergonomics, I'd suggest the first solution.
    If you implement the second solution, you'll have the user clicking on the button again and again and asking himself why nothing happens.

  • I want to make a note and put in a folder like we just place a notepad by right clicking in windows,how should I create a note in a folder in mac pro ...?

    I want to make a note and put in a folder like we just place a notepad by right clicking in windows,how should I create a note in a folder in mac pro ...?

    There's no "New File" shortcut in Finder on Macs, so you have to launch the application you want (eg TextEdit), create your document, and save it there. There are workarounds using Terminal (the touch command), AppleScript/Automator, and using third-party launch programs like Quicksilver, but natively, it can't be done.
    Matt

  • How to make "payment terms" not modifiable in sales order

    Hello every 1,
    please help, i want to know:
    how to make "payment terms" not modifiable in a sales order , as we know it comes directly from CMR and client wants "PAYMENT TERMS" to be not modifiable.
    Look forward for your response.
    Thanks in Advance,
    Deepak

    You need to use SHD0 or userexit chnages, like always determine from customer master, if user changes, give message like not modifiable  or ask abaper to make non modifable field

  • How do I make a button NOT take focus when it is clicked?

    I am trying to create a virtual keypad and the problem is that when I have a Robot make a KeyEvent for a certain number when a certain button is pressed, the TextField loses focus and the focus is placed on the button that was pressed, so nothing appears in the TextField.
    How can I make a button NOT take the focus when it is pressed?
    Edited by: tox0tes on Nov 28, 2008 8:06 PM

    great. another way is to have a call to myTextField.requestfocus() in the button's actionlistener actionPerformed method, but that leads to tight coupling.

  • How to make the buttons INVISIBLE in the Application toolbar

    Hi All,
    I have a requirement to create a button in the Application toolbar of the Module Pool Screen. The field should be made Invisible by default. and it should be displayed based on one condition.
    Could you please let me know how to make that particular button INVISIBLE. I think we can make it invisible by using EXCLUDING statement. But, How to make the button VISIBLE again when the check is satisfied.
    I found from the portal that the FM 'VIEW_SET_PF_STATUS' can be used to make a button INVISIBLE. Could anyone help me out how to pass the parameters to this Function module?
    or is there any Function Module available to make the button VISIBLE and INVISIBLE? Please help me on this issues.
    Is there any possibility to make the button VISIBLE or INVISIBLE as we do for the screen fields using LOOP AT SCREEN..?
    Thank you in advance.
    Regards.
    Paddu.

    Hi,
    Try to use below in the PBO module status_0100 OUTPUT.
    DATA t_fcode TYPE TABLE OF sy-ucomm.
    refresh t_fcode[].
    APPEND 'Function code name of the button' TO t_fcode. 
    Check the condition here for which you want to make field visible.
        DELETE FCODE of the button from T_FCODE table
      ENDIF.
      SET PF-STATUS 'STATUS_0100' EXCLUDING t_fcode.

  • How to make a button to stop and run a for loop?

    How to make a button to stop and run a for loop?  and if it is stopped it shall start from where i t stopped.

    Your VI has some very fundamental flaws.
    The start/stop button is outside the FOR loop, thus it will NOT get read during execution of the FOR loop, but only before the FOR loop starts. Think dataflow!
    Thus the terminal of the start/stop button belongs inside the FOR loop.
    Your FOR loop iterates 20x, which probably takes about a nanosecond. You will NOT be fast enough to reliably press the start/stop button during a specific iteration of the FOR loop.
    Your code does not "stop and run" a FOR loop (sic). The loop always spins, but executes an empty case when "Stopped". I guess that's what you actually want?
    Once you solve (2), the x indicator will contain a random value whenever you "stop".
    As soon as the 20 iterations complete, the outer while loop spin an things start over, another nanosecond later.
    Place e.g. a 500ms wait inside the FOR loop to solve this.
    Don't place terminals of indicators on top of formula nodes.
    Your formula does not produce any output, so really has no purpose.
    Use a real "stop" button to terminate the while loop (mechanical action: latch when released). Right now you are using a plain switch, which does not reset to false before the next run. This means that you need to manually reset it before running the program again.
    It is oftern useful to operate the VI in execution highlighting mode. You will immediately see that your button does not get read during execution of the FOR loop. Try it!
    LabVIEW Champion . Do more with less code and in less time .

  • How to make dyn/admin not to prompt for username and password?

    Hello all
    How to make dyn/admin not to prompt for username and password? I am writing a selenium job to automate cache invalidation to load test a production issue we are facing. Selenium is opening a fresh firefox session and prompting for username and password every time. I am also trying to modify my script such that it will use the same session again and not prompt for username and password. But I thought of asking this question in the group.
    Your inputs will help a lot.
    Thanks,
    Sundar

    Hi,
    You can set enabled property of /atg/dynamo/servlet/adminpipeline/AuthenticationServlet/ to false. It will not prompt for authentication.
    Gopi

  • How to make a Button to work Actively even if there is a mandatory field..?

    Hi All..
    How to make a Button to work Actively even if there is a mandatory field to be fulfilled..???
    I am badly in need of this logic, as i have to incorporate in my code..
    Points will be rewarded without fail..

    Hi Pavan,
    I also faced the same requirement. U can do one thing like remove the obligatory keyword of that parameter/select-option. U can handle the same using the program in at selection-screen event. See this sample of code,
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:  s_land1 for T005-LAND1 <b>[Needs to be mandatory]</b>                 no intervals no-extension.
    SELECT-OPTIONS:  s_panid FOR zoindex_val-zopanid.
    SELECT-OPTIONS:  s_effdat FOR zoexchrate-zedate.
    SELECTION-SCREEN END OF BLOCK b2.
    *-- AT SELECTION-SCREEN
    AT SELECTION-SCREEN.
      CASE sscrfields-ucomm.
    *-- Obligatory Country Code
      IF s_land1[] IS INITIAL.
        MESSAGE e050 WITH text-050.
                     "Please select the Country Code
      ENDIF.
    So whenever u do F8/Enter other than that push button, it will prompt u to enter the country code first then only u can proceed.
    Hope this would help u in some way. Please do reward the helpful answers.

  • How to make iTunes Match not convert my files ALACs in 256 kbps (VBR)? How to get iTunes to convert CDs to Apple loselss?

    How to make iTunes Match not convert my files ALACs in 256 kbps (VBR)? How to get iTunes convert CDs in Apple loselss? The difference between 256 (VBR) and Apple Losless is very clear...

    Dear Michael, good day!
    1. As per your instruction, I turned off iTM.
    Small discrepancy – where are two screens with iTM switch:
    -Settings > iTunes & App Store. 
    -Settings > Music
    I switched OFF in both.
    NB: I turned device to English for convenience.
    2. My next step was Setting > General > Usage – tapped {Music};
    {All music} screen appeared; I swiped it and taped Delete. 
    3. I performed “hard reset” …………………………………..
    4. Switched back On iTM
    5. Taped Music app on Home screen
    iTM has started –  (it took 18 minutes  to completed, 60 mbps Wi-Fi speed )
    Regret to inform… All the same:
    Erase and reset to factory default? Or I did smf wrong?

  • How to make a JScrollPane not getting Focus?

    How to make a JScrollPane not getting Focus?
    When i tab out from a textfield inside a scroll pane focus is going to ScrollPane .And if i press tab once more then only focus is going to other textField which is outside the scrollpane.
    For me when i press tab from a text field inside a scrollPane ,i should go to textfield out side the scroll pane.
    satish

    Hi,
    I've the same problem, that I have to double click on tab
    to step from a textfield with a scrollpane to the next textfield in my panel.
    I tried to implement a FocusListener on my JScrollPane, but without success.
    Can you tell me in detail how to implement this listener ?
    Kind regards
    Andy Kanzlers

  • How to make "Utility" button in Printer Setup Utility available

    There, i add a printer in the Printer Setup Utility and select it. i want to open printer utility, but the "Utility"
    button in Printer Setup Utility is dimmed. In addition,
    "Printer\Configure printer" in the Printer Setup Utility menu is also dimmed.
    How to make "Utility" button in Printer Setup Utility available?
    Thanks in advance.

    Hi Jiong,
    That button is to acess the printer utility for that particular printer, not all printers come with a utility. If you have the disk that came with your printer, you can see if it has a Macintosh driver, if it does then it mimght have the utility with it. It's pretty hard to run the utility on its own, its burried somewhere in the system so that's why you have that menu item. You can alternatively go on the internet and download the latest driver, which might have a utility. All the utility will do will give you options to check nozzle patterns, alighnement, ink tank levels, and cleaning options - just mimnor maintenence junk, non-essentials, etc. I think Tiger just comes with a whole heap of generic drivers for different printer lines, can't say for sure.
    I wouldn't worry about it, especially if you have a relatively old printer.
    Hope that helps
    DKR

  • How to make a button load a sprite from library??

    PLEASE HELP!!
    Hey everyone.. iv been looking for help for a few weeks but cant seem to find the awnsers
    I am trying to create a newspaper that consists of four pages. Each   page i have created and are sitting in the library as sprites. Each page   has buttons that need linking so that when pressed it loads the next   page or page that i want. This is the part i am confused with =/ how do i   make the buttons on each page load the next page (sprite) from the   library??
    Basically i want to no how to make a button load a sprite from the library when clicked. Does anyone no the script for this?
    Thanks for any help

    A question arises as to whether or not you are posting in the right forum.  Sprites are AS3 objects.
    If you want to add movieclips to the stage from the library using AS2, then you need to assign them each an Identifier via right clicking them in the library and selecting the Linkage option... from there you slect the option to Export for Actionscript and then assign the Identifier.
    You then use the attachMovie() method to make use of that Identifier to dynamically load the library object.

  • HOW TO MAKE ROUND BUTTON

    HI PLS TELL ME HOW TO MAKE ROUND BUTTON ON FORM.

    Rounded end buttons (e.g. Oracle Look and feel) are do-able in both 6i and 9i using PJCs in the 9i demos see the rollover button example, in 6i I seem to remember that there is a RoundedButton sample in the demos.
    Both sets of demos can be downloaded from http://otn.oracle.com/products/forms.
    If you want circular buttons then you'd have to use an Image for that.

  • ICC file associated with photoshop process on Windows, how to make them not associated?

    In my code, an ICC profile is created and copy to the system folder (C:\Windows\System32\spool\drivers\color)
    then assign this profile to current document in photoshop using sPSActionControl->Play(&result, StringToKey("assignProfile"), iDescriptor, mode); // iDescriptor contains the ICC profile name
    after assigning profile, the .icc file is associated with the ps process, that is, I can't delete it or rename it, nor can I replace it with another file having the same name. But on Mac, the ICC file won't be associated with the process, so I can overwrite the icc file and do other work, that's better.
    How to make the icc file not taken by photoshop after assigning profile on windows?

    what i finally did to go around this problem was to make another user on my computer and only download podcasts. just as long as you don't hook the ipod up in this new profile, you should be fine

Maybe you are looking for

  • Pdf file in portal

    Hi Detlev, I have received a requirement wherein the pdf file needs to be stored within portal, and on click of a link on the left detailed tree navigation iview, the pdf file needs to open up. The user does not want to store document in KM. Please a

  • Date field encryption using Dbms_Obfuscation_Toolkit.DESENCRYPT

    Hi, I need to encrypt the date field in the table using Dbms_Obfuscation_Toolkit.DESENCRYPT . This is an table is an existing table and is accessed by many interfaces, so we cannot change the column type of this date field. Is there a possibility of

  • Excise amt in respect to GRN

    Is there any report that tells that what is the excise amt with reference  to GRN.\ Plz guide

  • Unchecked or Unsafe operation -- recompile

    Hi, How can I set compiler options in Jdeveloper? I am getting a Note: C:\JDeveloper10131\j2ee\home\application-deployments\AbcEJBTest\AbcEJB\ejb_webs ervice1\runtime\ControllerResponseElement_LiteralSerializer.java uses unchecked or unsafe operation

  • Beyond JDeveloper 9.0.3 modeling features

    Hi, I'm really impressed by the way JDev 9.0.3 enhance productivity while modeling EJB on Class Diagrams and other modeling features alredy present. Having read the book "Developing Enterprise Java Applications with J2EE and UML" (ISBN: 0201738295) I