View RSS Feed

DuvanSlabbert

  1. Setting JWindow or JFrame Opacity

    by , 10-17-2011 at 10:37 PM
    Ever wanted to try and set the transparency level of some JWindow's or JFrames? Here is another snippet of code to keep close by that might come in handy.

    Java Code:
    try {
    	Class<?> awtUtilitiesClass = Class.forName("com.sun.awt.AWTUtilities");
    	Method method = awtUtilitiesClass.getMethod("setWindowOpacity", Window.class, float.class);	
    		
    	method.invoke(null, /*JFrame or JWindow here*/, /*The opacity level in float value from 0.0 to 1*/);
    ...

    Updated 10-19-2011 at 10:41 AM by DuvanSlabbert

    Categories
    AWT and Swing
  2. Setting JWindow or JFrame Opaque

    by , 10-17-2011 at 10:31 PM
    Ever tried setting the visibility of a rootpane on your JWindow or JFrame without loosing visibility of the components on that JWindow or JFrame???

    Here is a little snippet of code to keep close by as it might come in handy

    Java Code:
    try {
    	Class<?> awtUtilitiesClass = Class.forName("com.sun.awt.AWTUtilities");
    	Method method = awtUtilitiesClass.getMethod("setWindowOpaque", Window.class, boolean.class);
    	method.invoke(null, /*JFrame
    ...

    Updated 10-19-2011 at 10:34 AM by DuvanSlabbert

    Categories
    AWT and Swing
  3. Adding "Global" KeyListener

    by , 10-17-2011 at 07:00 PM
    Want to add a so called "Global" Keylistener to your Java application even if it is a JWindow or JFrame without having focus on it. Just download the file in the link and extract, add the jhook.jar file to your project library and use this demo code to get the keys pressed.

    Java Code:
    Keyboard kb=new Keyboard();
            kb.addListener(new KeyboardListener() {
                public void keyPressed(boolean keydown, int vk){
                    System.out.println(vk);
    ...

    Updated 10-19-2011 at 09:33 AM by DuvanSlabbert

    Categories
    AWT and Swing