Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (761)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (845)
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 3635 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 (349 views)
2018-06-10 19:43:48

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

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

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

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

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

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

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

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

Solater (412 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
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!