Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
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  
  Writing a GUI for my RPG  (Read 1955 times)
0 Members and 1 Guest are viewing this topic.
Offline K.I.L.E.R

Senior Member




Java games rock!


« Posted 2004-01-29 00:37:06 »

Man, how can you create 2 applets?

I want 2 applets and a frame to make my game. I have already got the in game mechanics running fine.

Random battles, 2 dungeons, different difficulty levels dependent upon dungeon, part of the world and player level, etc...

Now comes the part where I'm supposed to knock in a pretty GUI which AFAIK cannot be achieved with Swing but can be achieved with some work with applets.

Applet 1: LHS of screen -> Display player stats
Applet 2: RHS of screen -> Monster stats/Inventory button underneath monsters stats
Frame: Center of screen -> Display text from files into a TextArea.

Is there any good substitute for a TextArea?

I don't know how some of you Java game devs are able to display text on pretty surfaces.
Swing is not pretty but applets can be made to look nice but it requires a bit of work.

I'm in need of desperate help.

Thank You.

Vorax:
Is there a name for a "redneck" programmer?

Jeff:
Unemployed. Wink
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #1 - Posted 2004-01-29 01:33:11 »

Ok. I read your post 4 times, but it still doesn't make much sense Roll Eyes

Maybe it won't be a bad idea if you draw a little sketch?

> Swing is not pretty[...]

Swing looks like you want it to look. You can change everything. You can change the colors, the borders, fonts... everything. Really.

Simple stuff with the set* methods. E.g. icons of a JButton (normal, rollover, pressed), drawing of the focus, contentAreaFilled... whatsoever.

If you want to generally change some stuff or things wich don't hava set methods, you can use UIManager.put().

E.g.
UIManager.put("ScrollBar.track",           new ColorUIResource(147,180,211));
or
UIManager.put("ToolTip.border",BorderFactory.createEmptyBorder());

And you can even change the way how specific UI* are drawn (e.g. the look of JScrollbars), by writing your own L&F (it doesn't have to be a complete L&F you know?).

弾幕 ☆ @mahonnaiseblog
Offline K.I.L.E.R

Senior Member




Java games rock!


« Reply #2 - Posted 2004-01-29 02:24:19 »

Hehehe, sorry.

I'll try and break my points down to a more coherent fashion. Smiley

JTextArea -> It doesn't ley me start a new line when I want it to. Nor does it let me set colours of specific words.
I also want the border of the TextArea to be a picture.

Swing -> I want to make my JButtons look like graphics and not buttons however I want the functionality of a Swing button still available.

JPanels -> I want a different background image for different panels.

JFrame -> I want to get rid of the standard minimise, resize, exit border and replace it with a docrated border around my program. Of course the minimise, resize, exit buttons will still be there, just look different.

Thanks.

Vorax:
Is there a name for a "redneck" programmer?

Jeff:
Unemployed. Wink
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #3 - Posted 2004-01-29 06:06:43 »

Ok. Let's see...

Quote
JTextArea -> It doesn't ley me start a new line when I want it to. Nor does it let me set colours of specific words.


Try JEditorPane. It's more flexible than JTextArea. Also swing components can display (simple) html. Example.

Quote
I also want the border of the TextArea to be a picture.


I would set the border of the JEditorPane to null... and the image stuff can be done in the Panel, wich contains it (see that quote at the end).

Quote
Swing -> I want to make my JButtons look like graphics and not buttons however I want the functionality of a Swing button still available.


A quite complete JButton:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
JButton add=new JButton(a2aIcon); //usual icon
add.setToolTipText("Auswahl inzufügen"); //toolTipText
add.setRequestFocusEnabled(false); //no focus request
add.setMargin(new Insets(0,0,0,0)); //space around the icon
add.setFocusPainted(false); //that blue box
add.setRolloverEnabled(true); //on by default if you set a rollover icon
add.setRolloverIcon(a2bIcon); //our rollover icon
add.setPressedIcon(a2cIcon); //our pressed icon
add.setBorderPainted(false); //no border
add.setContentAreaFilled(false); //no filling of the space
add.setActionCommand("add"); //aye sir!
add.addActionListener(this); //listen carefully :)


Check the documentation for the details:
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JButton.html

Quote
JPanels -> I want a different background image for different panels.


Extend JPanel and override the paint method.

ugly exampel image

Quote
JFrame -> I want to get rid of the standard minimise, resize, exit border and replace it with a docrated border around my program. Of course the minimise, resize, exit buttons will still be there, just look different.


Hadn't done that so far. However, it can be done by writing a L&F wich covers that part (I think).

弾幕 ☆ @mahonnaiseblog
Offline K.I.L.E.R

Senior Member




Java games rock!


« Reply #4 - Posted 2004-01-29 06:17:43 »

Hey that example looks great.

Thanks. Smiley

Vorax:
Is there a name for a "redneck" programmer?

Jeff:
Unemployed. Wink
Offline DrBizzar0

Junior Member




Raj raj!


« Reply #5 - Posted 2004-01-29 06:25:54 »

JTextArea
You'd want to use a JTextPane instead

http://java.sun.com/docs/books/tutorial/uiswing/components/text.html


Make JButtons look like graphics
JButton(Icon icon)

http://java.sun.com/docs/books/tutorial/uiswing/components/button.html


JPanels
To my knowledge there's no support for background images in JPanels. One sollution might be to make you r own Panel class extending JPanel and implementing background image support.


JFrame
One way that could be achived would be to use frame.setUndecorated(true)  and then place graphics and attach listeners yourself.
Offline Jeff

JGO Coder




Got any cats?


« Reply #6 - Posted 2004-01-29 15:42:19 »

Quote
Hehehe, sorry.

I'll try and break my points down to a more coherent fashion. Smiley

JTextArea -> It doesn't ley me start a new line when I want it to.


Try using a newline ("\n")  with JTextPane Smiley

Quote

Nor does it let me set colours of specific words


Set the attributes in JTextPane's InsertText.

Quote

I also want the border of the TextArea to be a picture.


Swing supports custom border managers.  or you can do a background image in a panel and put your widgets ontop of it.

Quote

Swing -> I want to make my JButtons look like graphics and not buttons however I want the functionality of a Swing button still available.


As has already been pointed out you can set the graphics. In addition ANY swing component can be subclassed and you can override paint() with your own arbitrary paint code.

Quote

JPanels -> I want a different background image for different panels.


Just subclass JPanel and override the paint() method. i have a standard "ImagePanel" class I use that does exactly this.

Quote

JFrame -> I want to get rid of the standard minimise, resize, exit border and replace it with a docrated border around my program.


You can set a frame "Undecorated" and then draw into it yourself.

Quote

Of course the minimise, resize, exit buttons will still be there, just look different.


OR if you want exactly the same functionality you can subclass and modify a look and feel.

Big hint.  ALL an applet has to work with are AWT and Swing.  If you see it in an  Applet, you can by definition do it in AWT and/or Swing.

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

CopyableCougar4 (14 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!