Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (780)
Games in Android Showcase (233)
games submitted by our members
Games in WIP (857)
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 3857 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.

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:
Offline BurntPizza

« JGO Bitwise Duke »

Medals: 486
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:

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:

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:
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: 
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  

hadezbladez (761 views)
2018-11-16 13:46:03

hadezbladez (394 views)
2018-11-16 13:41:33

hadezbladez (758 views)
2018-11-16 13:35:35

hadezbladez (200 views)
2018-11-16 13:32:03

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

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

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

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

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

nelsongames (2648 views)
2018-04-24 18:14:32
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 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‑
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!