Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (855)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  java.awt classes in libGDX  (Read 3724 times)
0 Members and 1 Guest are viewing this topic.
Offline kovacsa

Senior Newbie





« Posted 2014-12-08 22:38:29 »

I am working on a game application, which uses java.awt classes, just like java.awt.point. It is no problem if I compile to desktop, but it causes error messages under android.

1  
Not found...


How can I import or use these classes? These are very important for the proper functionality of this application.
I have found a project(An attempt to facilitate AWT rendering on the Android platform), but it is now closed and all the files have been deleted, I think: https://code.google.com/p/awt-android-compat/
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #1 - Posted 2014-12-08 22:46:49 »

What classes are you using? Simple ones like Point are trivial to implement yourself, or better yet, use the libGDX versions: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector2.html

Don't try to use AWT on Android, and it has no place in your project if you are using libGDX.
Offline gouessej
« Reply #2 - Posted 2014-12-08 23:22:32 »

BurntPizza is right. You shouldn't use AWT from the very beginning of a project when you plan to target Android which uses a subset of J2SE in Dalvik VM and ART.

Julien Gouesse | Personal blog | Website | Jogamp
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kovacsa

Senior Newbie





« Reply #3 - Posted 2014-12-09 07:25:44 »

It is a "ported" native Java program, that is why I am using these classes.

I use these from AWT:

1  
2  
import java.awt.Point;
import java.awt.Rectangle;
Offline Springrbua
« Reply #4 - Posted 2014-12-09 07:48:20 »

If there are only this two classes, it shouldn't be hard to replace them. 
Libgdx does also have a Rectangle class and the Point class is simmilar to the Vector2 class. 
I guess thats the better solution.
Offline kovacsa

Senior Newbie





« Reply #5 - Posted 2014-12-09 09:09:59 »

When I try to import it, I get the following error:
Quote
The import com.badlogic.gdx.math.Rectangle collides with another import statement
Offline Springrbua
« Reply #6 - Posted 2014-12-09 09:35:07 »

That is because you allready import the java.awt.Rectangle. 
So you have 2 different classes, with the same name. 
If you now create a new Rectangle, who knows if it is a java.awt.Rectangle or a com.badlogic.gdx.math.Rectangle? 
As you are replacing the java.awt.Rectangle you can simply remove this import. 
I guess you will get a few errors, so you allready know where you need to replace the awt.Rectangle with the Libgdx Rectangle. 

In other cases, where you need 2 classes with the same name, you can import only 1 and define the other by using its full name. 
For example: 
1  
2  
3  
4  
5  
6  
7  
import java.awt.Rectangle;

public class Test {

    private Rectangle r;    // java.awt.Rectangle
    private com.badlogic.gdx.math.Rectangle r2;    // com.badlogic.gdx.math.Rectangle
}
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1569 views)
2018-06-10 19:43:48

EgonOlsen (1541 views)
2018-06-10 19:43:44

EgonOlsen (1141 views)
2018-06-10 19:43:20

DesertCoockie (1568 views)
2018-05-13 18:23:11

nelsongames (1172 views)
2018-04-24 18:15:36

nelsongames (1548 views)
2018-04-24 18:14:32

ivj94 (2306 views)
2018-03-24 14:47:39

ivj94 (1515 views)
2018-03-24 14:46:31

ivj94 (2602 views)
2018-03-24 14:43:53

Solater (879 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!