Jump to content

Problem with Aero Window

- - - - -

  • Please log in to reply
15 replies to this topic

#1
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
Hello,

I'm trying to create a Frame with Aero vision. Found this linkHow to Create Translucent and Shaped Windows (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features). Also, downloaded the SDK 7. Problem is that Eclipse not recognise lines such as
TranslucentWindow tw = new TranslucentWindow();
underline TranslucentWindow -> "TranslucentWindow cannot be resolved to a type". The same message have it and for this line
 if (!gd.isWindowTranslucencySupported([U][COLOR="#FF0000"]TRANSLUCENT[/COLOR][/U])) {
. Inside Eclipse's settings I have 1.7 level for Compiler. Any idea why I have this? Need to do something more? Still Eclipse running SDK 6?

Thank you,
toto7

"Programming is like sex. One mistake and you have to support it for the rest of your life."

-Michael Sinz

#2
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
You might have to download the latest version of eclipse. The version I'm using is Eclipse 4.0.1.
I believe Eclipse Indigo 3.7 is the first stable version of eclipse that runs JDK 7.

Any versions before that, eclipse will cry.

#3
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
My version is Version: 3.7.1

"Programming is like sex. One mistake and you have to support it for the rest of your life."

-Michael Sinz

#4
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
It's hard to say.
Have you tried copy/pasting the code directly from the tutorial website and tried to run it?
If you didn't do that, make sure everything is spelled correctly(Class names)
If you DID copy and paste, have you tried programming any of the other new features from java 7?

#5
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
Yes I copies and paste the code from tutorial. Well, can you support me with a small piece of code for Java 7, please

"Programming is like sex. One mistake and you have to support it for the rest of your life."

-Michael Sinz

#6
ttax

ttax

    Newbie

  • Members
  • Pip
  • 5 posts
you could do a switch-case on Strings (that's new to Java 7). i.e.:

String tempString  = "hello", message = "";

switch(tempString) {

   case "hello": message = "hello"; break;

   case "world": message = "world"; break;

}

System.out.println(message);

Edited by ttax, 03 December 2011 - 07:09 PM.
typo


#7
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
Very Strange :confused: .. Used your code ttax (Thanks by the way) and told me that switch using String is not compatible with Java under 1.7 . Had as a solution to turn my project to 1.7, did it and fixed. Ran the program and was fine. Now trying with tutorial, and still has the same errors :mad:


*Opened Build Path and I have just this Library "JRE System Library [JavaSE-1.7]"

"Programming is like sex. One mistake and you have to support it for the rest of your life."

-Michael Sinz

#8
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
Can you post the full error message?

#9
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
Sure:

For this line
if (!gd.isWindowTranslucencySupported(TRANSLUCENT)) {
TRANSLUCENT cannot be resolved to a variable

For this line
[COLOR="#FF0000"]TranslucentWindow [/COLOR]tw = new [COLOR="#FF0000"]TranslucentWindow[/COLOR]();
TranslucentWindow cannot be resolved to a type

"Programming is like sex. One mistake and you have to support it for the rest of your life."

-Michael Sinz

#10
ttax

ttax

    Newbie

  • Members
  • Pip
  • 5 posts
could you post your full code?

#11
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
It seems to be a problem with eclipse...
Try to refresh the project directory. (Press F5 while the Project Explorer is selected)

#12
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
Is not my code, got it from the tutorial

import java.awt.*;

import javax.swing.*;

import static java.awt.GraphicsDevice.WindowTranslucency.*;


public class TranslucentWindow extends JFrame {

    public TranslucentWindow() {

        super("TranslucentWindow");

        setLayout(new GridBagLayout());


        setSize(300,200);

        setLocationRelativeTo(null);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


        //Add a sample button.

        add(new JButton("I am a Button"));

    }


    public static void main(String[] args) {

        // Determine if the GraphicsDevice supports translucency.

        GraphicsEnvironment ge = 

            GraphicsEnvironment.getLocalGraphicsEnvironment();

        GraphicsDevice gd = ge.getDefaultScreenDevice();


        //If translucent windows aren't supported, exit.

        if (!gd.isWindowTranslucencySupported(TRANSLUCENT)) {

            System.err.println(

                "Translucency is not supported");

                System.exit(0);

        }


        // Create the GUI on the event-dispatching thread

        SwingUtilities.invokeLater(new Runnable() {

            @Override

            public void run() {

                TranslucentWindow tw = new TranslucentWindow();


                // Set the window to 55% opaque (45% translucent).

                tw.setOpacity(0.55f);


                // Display the window.

                tw.setVisible(true);

            }

        });

    }

}


---------- Post added at 03:37 AM ---------- Previous post was at 03:34 AM ----------

****!!! Can't understand why...Restarted, refreshed still nothing...

---------- Post added at 03:41 AM ---------- Previous post was at 03:37 AM ----------

Sorry guys. I think understand what is happening, copy and paste the code in an already exist project, so may that project created with 1.6 . Made new project and is working fine :mad: finally. Sorry again. How I can fix that issue?

"Programming is like sex. One mistake and you have to support it for the rest of your life."

-Michael Sinz




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users