Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

AWT Ubuntu - deprecated?  RSS feed

 
Andrew Bedley
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks in no small part to you guys here, my beginning Java class is progressing quite nicely.

They now think I am good enough to play with the AWT toolkit, however my computer doesn't want to co-operate. Since I am running linux rather than the standard Windows, it does make these sort of troubleshooting ventures a little more difficult. I am trying to figure out if it is my OS that is causing problems, or if it is old code that is causing problems, or something altogether else.

This is not code that I have written, but it is the example to base my assignment on:


When I type javac Example1.java, I am greeted with the following message:

Note: Example1.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.


When I go rooting around for more up-to-date awt, the general message seems to be to use swing instead. I would assume we need to learn the basic AWT, and then move on to Swing, and then maybe something called JavaFX, no?

On top of this, the Oracle tutorial only seems to talk about applets, but I need a desktop app right now.

Finally the tutorial http://java.sun.com/developer/onlineTraining/awt/contents.html talks about using Java 1 or 2, but I thought we were up to like 6??

Thanks,

Andrew
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly is the "problem" you mentioned? Doesn't the code work? That message is just informational, not an error. If you want to avoid it, read the javadocs of the Frame.show method (or rather, Window.show).

And yes, AWT in general isn't used much any more, it has been supplanted by Swing. But some AWT classes are still necessary to use even for Swing GUIs (not Frame, though). See http://download.oracle.com/javase/tutorial/uiswing/ to get up to speed on Swing. (Note that the page you linked to has last been updated in 2000, so it's to be expected that it covers outdated material.)

As to methods and classes becoming deprecated, that routinely happens between Java versions, but so far none has ever been removed, so they keep working. It then takes a while for books and tutorials to get updated with the new stuff.
 
Andrew Bedley
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, okay, you might be right. I ran the thing (Java Example1) and it didn't look like it did anything, but give out a page of errors. Upon closer inspection after what you said, they may all just be warnings. I do see an application show up in my taskbar that says Example1, but when I click on it, nothing much happens. After what you have said, maybe that is because, well, there is nothing much happening in the program. It doesn't really maximize or anything, because I am guessing there is nothing much to see.

Well, thank-you for your response. It is always very hard to troubleshoot when I am not even sure what the code is supposed to do exactly (in this case, it really does very little - I was expecting more). Also, wow, Java is very wordy is it not? I have a huge list of stuff, and the thing still runs!

Error messages - Err, make that Warning messages:

java Example1
Jun 26, 2011 12:49:12 PM com.sun.corba.se.impl.ior.IORImpl getProfile
WARNING: "IOP00511201: (INV_OBJREF) IOR must have at least one IIOP profile"
org.omg.CORBA.INV_OBJREF: vmcid: SUN minor code: 1201 completed: No
at com.sun.corba.se.impl.logging.IORSystemException.iorMustHaveIiopProfile(IORSystemException.java:473)
at com.sun.corba.se.impl.logging.IORSystemException.iorMustHaveIiopProfile(IORSystemException.java:495)
at com.sun.corba.se.impl.ior.IORImpl.getProfile(IORImpl.java:334)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_Object(CDRInputStream_1_0.java:787)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_Object(CDRInputStream_1_0.java:761)
at com.sun.corba.se.impl.encoding.CDRInputStream.read_Object(CDRInputStream.java:231)
at com.sun.corba.se.impl.resolver.INSURLOperationImpl.getIORFromString(INSURLOperationImpl.java:120)
at com.sun.corba.se.impl.resolver.INSURLOperationImpl.operate(INSURLOperationImpl.java:130)
at com.sun.corba.se.impl.orb.ORBImpl.string_to_object(ORBImpl.java:836)
at org.GNOME.Accessibility.AccessUtil.getRegistryObject(AccessUtil.java:143)
at org.GNOME.Accessibility.JavaBridge.registerApplication(JavaBridge.java:1154)
at org.GNOME.Accessibility.JavaBridge.<init>(JavaBridge.java:405)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at java.awt.Toolkit.loadAssistiveTechnologies(Toolkit.java:786)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:875)
at java.awt.Window.getToolkit(Window.java:1209)
at java.awt.Window.init(Window.java:439)
at java.awt.Window.<init>(Window.java:477)
at java.awt.Frame.<init>(Frame.java:419)
at Example1.main(Example1.java:7)


 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you add "f.setSize(200, 200);" after creating the Frame you'll have a bit more to look at...

That other message is quite odd (and definitely not normal); but it also looks like something that can be ignored.
 
Andrew Bedley
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks for the help. I now have a gui program up and running, even with a couple of buttons! Okay so I still have a ways to go to back it do anything useful, but it at least looks like something now. And those pile of warnings don't stop me in the least.

Cheers,

Andrew
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!