Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Problem with Aero Window


  • Please log in to reply
15 replies to this topic

#1 toto_7

toto_7

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 244 posts

Posted 03 December 2011 - 06:35 PM

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
  • 0

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

-Michael Sinz

#2 lethalwire

lethalwire

    while(false){ ... }

  • Senior Member
  • PipPipPipPipPipPip
  • 766 posts
  • Programming Language:C, Java, PHP, JavaScript
  • Learning:PHP

Posted 03 December 2011 - 06:47 PM

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.
  • 0

#3 toto_7

toto_7

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 244 posts

Posted 03 December 2011 - 06:51 PM

My version is Version: 3.7.1
  • 0

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

-Michael Sinz

#4 lethalwire

lethalwire

    while(false){ ... }

  • Senior Member
  • PipPipPipPipPipPip
  • 766 posts
  • Programming Language:C, Java, PHP, JavaScript
  • Learning:PHP

Posted 03 December 2011 - 06:57 PM

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?
  • 0

#5 toto_7

toto_7

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 244 posts

Posted 03 December 2011 - 07:00 PM

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

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

-Michael Sinz

#6 ttax

ttax

    CC Lurker

  • New Member
  • Pip
  • 5 posts

Posted 03 December 2011 - 07:09 PM

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

  • 0

#7 toto_7

toto_7

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 244 posts

Posted 03 December 2011 - 07:17 PM

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]"
  • 0

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

-Michael Sinz

#8 lethalwire

lethalwire

    while(false){ ... }

  • Senior Member
  • PipPipPipPipPipPip
  • 766 posts
  • Programming Language:C, Java, PHP, JavaScript
  • Learning:PHP

Posted 03 December 2011 - 07:23 PM

Can you post the full error message?
  • 0

#9 toto_7

toto_7

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 244 posts

Posted 03 December 2011 - 07:29 PM

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
  • 0

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

-Michael Sinz

#10 ttax

ttax

    CC Lurker

  • New Member
  • Pip
  • 5 posts

Posted 03 December 2011 - 07:31 PM

could you post your full code?
  • 0

#11 lethalwire

lethalwire

    while(false){ ... }

  • Senior Member
  • PipPipPipPipPipPip
  • 766 posts
  • Programming Language:C, Java, PHP, JavaScript
  • Learning:PHP

Posted 03 December 2011 - 07:33 PM

It seems to be a problem with eclipse...
Try to refresh the project directory. (Press F5 while the Project Explorer is selected)
  • 0

#12 toto_7

toto_7

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 244 posts

Posted 03 December 2011 - 07:41 PM

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?
  • 0

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

-Michael Sinz




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download