Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  Layout Java Functions  (Read 1634 times)
0 Members and 1 Guest are viewing this topic.
Offline straydoginc

Junior Member





« Posted 2005-09-28 21:56:05 »

Ive read up on the different type of Layouts available to Java and am wondering if it would be best to not have one at all.

Question I have initially is do the Layouts only affect buttons or can they affect print strings and photo's also?
Online Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2005-09-28 22:05:05 »

Layout managers affect all non-window components (Button, Canvas, List, TextField, etc, etc).

Without layout-manager you can do absolute positioning of components, but be aware that it will most likely look completely crap and unprofessional on other systems than yours. So always use layout managers, unless... hm... I can't think of a reason not to.

Good luck with your GUIs, and don't forget to read the javadocs/guide from sun.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Jeff

JGO Coder




Got any cats?


« Reply #2 - Posted 2005-09-29 05:54:39 »

Without layout managers you also generally dont resize well.

BUT if we are talkign abotu games then mnost dont use ANY Swing or AWT at all beyond AWT buffer flipping (assuming we are talkign about a 2D game.   A 3D game, and even some 2D games dont use AWT at all but just render through OGL)

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2


Make it work; make it better.


« Reply #3 - Posted 2005-09-29 12:41:22 »

If you are having trouble understanding LayoutManagers, there is a tutorial on Sun's Java site that explains it all very well.

http://java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/index.html

Offline straydoginc

Junior Member





« Reply #4 - Posted 2005-09-29 15:08:21 »

Ive read the entire javadoc on the different layout managers. But thanx for the extra info. What I can't deside is.... My first Java project has been a simple 2 player battle applet that works pretty well for text. I just added a background image to it that defines areas where the players/monster pictures are supposed to be, the status objects such as HP, Hit, DMG, the 3 buttons (Attack, Reset, Exit), and the Status window which im hoping to use for a scrolling history of hit, misses, and damage dealt.

But after reading the different layout managers that java uses. I can't figure out a way beyond not using any at all that I could position these items where I want them. And i guess considering that the applet will never be bigger then the size i set it as in my applet tags on the html page then it shouldn't distort.

After the layout is done i will start working on DB connectivity Smiley that should be fun! But for now I'm really not sure what to use to lay it out. Also since everywhere I read they are saying to use a layout manager... how do i define where my buttons and such are supposed to go if i setLayout (null);  ??
Offline bauerr

Junior Member




Java!!!!!!!!!!! !!!


« Reply #5 - Posted 2005-09-29 15:25:36 »

If you're using null-layout, you're placing your buttons etc. with setBounds(..).

Offline straydoginc

Junior Member





« Reply #6 - Posted 2005-09-29 19:13:41 »

Would you happen to have a good visual example of using a null layout and setbounds to determine where the objects go and where to utilize the setbounds and such?
Offline aldacron

Senior Member


Medals: 9
Exp: 16 years


Java games rock!


« Reply #7 - Posted 2005-09-29 19:33:58 »

But after reading the different layout managers that java uses. I can't figure out a way beyond not using any at all that I could position these items where I want them. And i guess considering that the applet will never be bigger then the size i set it as in my applet tags on the html page then it shouldn't distort.

Most of the time you aren't going to be able to achieve the results you want by by attemptinig to layout all of the components with a single LayoutManager. What you have to do is make use of Panel objects. Look at the layout you're after and see how components can logically be grouped together in different areas of the screen. Divide the window up along the lines of those component groups. For each group, create a Panel and add the components of that group to the Panel. Each Panel object will use its own LayoutManager to get its components in the right positions within the Panel. With the components properly positioned in each Panel you can use a single LayoutManager to position the Panels appropriately within the frame. Using this technique you can easily create some complex layouts.
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2


Make it work; make it better.


« Reply #8 - Posted 2005-09-30 14:07:24 »

You can also have multiple nested panels.  That is why I pointed you to that particular tutorial.  It gives a lot of good tips on how to use the LayoutManagers together to achieve what you want.  After I read that tutorial, I could create any layout that I wanted.

Online Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #9 - Posted 2005-09-30 22:02:55 »

Same for me. I use nested Panel with all kinds of LayoutManagers everywhere.

Still it feels like a huge hassle, compared to DnD in... say... Delphi.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #10 - Posted 2005-10-01 05:33:48 »

The big advantage of layout managers is that resizing happens nicely and automatically.

The price you pay is more work to set it up.

If you want DnD there are a ton of GUI layout editors out there.  If you dont want the layout manager functionality just leave it null and voilla you have DnD placement.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline straydoginc

Junior Member





« Reply #11 - Posted 2005-10-03 17:55:15 »

I finally got it figured out with the no Layout Manager Smiley Desided that since its an applet there shouldn't be any resizing and I really need absolute positioning. Thanx for the help as always.

Forever the Java Noob!

-Me
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.

xsi3rr4x (53 views)
2014-04-15 18:08:23

BurntPizza (51 views)
2014-04-15 03:46:01

UprightPath (65 views)
2014-04-14 17:39:50

UprightPath (48 views)
2014-04-14 17:35:47

Porlus (65 views)
2014-04-14 15:48:38

tom_mai78101 (89 views)
2014-04-10 04:04:31

BurntPizza (149 views)
2014-04-08 23:06:04

tom_mai78101 (245 views)
2014-04-05 13:34:39

trollwarrior1 (203 views)
2014-04-04 12:06:45

CJLetsGame (210 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!