Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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  
  FSEM, Active Rendering & Swing  (Read 1515 times)
0 Members and 1 Guest are viewing this topic.
Offline ScottKun

Junior Newbie





« Posted 2008-04-26 06:43:10 »

Hey Everyone. I am new to the whole graphics thing to please bare with me =x.
There are going to be a lot of questions here sorry haha.

i am making a game that is played in FSEM, using active rendering and it is going to incorporate smaller movable windows inside of it. I don't want to use JInternalFrames because the upper bar looks ugly (I want the game to have its own look instead of platform specific). I had a few ideas about how to do this but all seemed to fail terribly...

The game uses no Jpanels it is basically just g.drawImage(); to the screen (This could be a problem) Maybe i have to use a JLayerdPane have a background pane that holds the game play graphics and such and then other panels that work as windows over that. Unfortunately for me i have no idea how to g.draw w/e into a panel or would i even have to do this... wow the more i write this the more of an idiot i think i am  Cheesy

Swing Issue:
when i added a simple JTextArea and JTextField as one component and set the desired location and size to the frame it always expands to the full size of the screen. This is also accompanied by flickering of the now full screen component over the painted graphics. Only after i minimized the window and reopened it would it stop flickering. then after a few key presses in the JTextField the program would lockup and i could have to force quit it. I think this is caused by the active rendering, The swing components being repainted and updated and such a fast pace. So I added:
1  
2  
3  
4  
5  
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    paintComponents(getGraphics());
                }
            });

to the render loop. This was a Hit and Miss fix. sometimes it works great but the lockups still occur.

For all i know this could be and probably is a stupid question. I know i need to learn more about how FSEM and swing work... lets just say graphics in general haha. but some help would be most appreciated. Im not sure if i gave all the info needed so please ask for w/e u may need. i have not decided if i want to post source yet but anything else then go for it.

Thanks for your time =D
Offline CommanderKeith
« Reply #1 - Posted 2008-04-26 11:01:46 »

Hi,

You're right onto the problems, and these are not easy things to solve. Most people here actually find swing such a head-ache that they don't use it at all.

You may want to avoid using swing compponents in the game because they're very inefficiently painted - remember that each component has its background painted, even when they overlap so it's slow. If you just want movable windows and text fields then I think you should implement them yourself. Text fields would be hard to do, maybe you can find a non-swing one somewhere?

If you really want to use Swing, I've got a game with source you can download here (http://www.java-gaming.org/forums/index.php?topic=18019.0) which uses actively rendered Swing components for the menus, and a passively-rendered textfield at the bottom (which is not painted every frame). Look at GameDesktopPane (extends JLayeredPane), GameFrame and ViewPane. But I think you should steer clear of swing if you want to paint the components every frame.

good luck   Smiley
Keith

Offline Trussell

Junior Duke




Game Developer


« Reply #2 - Posted 2008-04-26 18:34:09 »

How do you even start a JOGL window in FSEM?

I am a noob attempting to make a video game.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline purpleguitar

Junior Duke





« Reply #3 - Posted 2008-04-27 11:36:14 »

I am new to the whole graphics thing to please bare with me

Ick, no! I think you have the wrong message board for that kind of thing.


Sorry, I couldn't help myself.
Offline ScottKun

Junior Newbie





« Reply #4 - Posted 2008-04-28 22:42:14 »

Quote
Ick, no! I think you have the wrong message board for that kind of thing.
Lol yeah i obviously am  Tongue, im a terrible person xD

Quote
You may want to avoid using swing compponents in the game because they're very inefficiently painted - remember that each component has its background painted, even when they overlap so it's slow. If you just want movable windows and text fields then I think you should implement them yourself. Text fields would be hard to do, maybe you can find a non-swing one somewhere?

Yeah i thought so. I have a good idea how to implement my own windowing system, basically using a lot of rectangles and mouse/action listeners although i have no idea how to start with the textfields. This in a way feels like its being redundant since swing does it all, but for some reason theres no way to modify it easily for active rendering. I would think there would be something that would be more active rendering friendly made by sun since they say they support gaming... maybe i just have to do some more research.

Thanks for all the help any more info would be great.

Also another question would it be wise to use another API for 2d work im using java2D atm and im thinking i want to add a simple 3D env. to the game. just wondering some Pref / Exp with them. Thanks again.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (37 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (27 views)
2014-10-15 16:18:58

TehJavaDev (52 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (77 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!