Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (789)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (864)
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  
  Active Menu Backrounds  (Read 1599 times)
0 Members and 1 Guest are viewing this topic.
Offline Sisyphus

Junior Newbie

« Posted 2005-06-16 03:20:36 »

   I am a noob programmer and I was wondering if any one knows how to code a backround to a menu (for a game) so it keeps changing pictures every few second and/or it shows different video clips. For example anyone who has played Rise of Nations or Rome: Total War, the menu is overlayed on a backround of moving art. If it is to complicated to overlay the two would anyone know how to make them into windows? a.k.a. Have a fullscreen game window with the pictures or video clips in an inside window and the menu as a seperate window next to it.

Offline Conflux

Senior Newbie

Java games rock!

« Reply #1 - Posted 2005-06-16 09:00:49 »

The most simple way is to put an animated gif image onto a JButton with 'new JButton(new ImageIcon("myanimated.gif"))'

If your game ist runnig in an active rendering loop (as it is supposed to be) you can just make a custom paint()-method for your menu-item which draws an image over it every time the whole frame gets an repaint(). The menu-item can be every kind of AWT or Swing component (Label, Frame, Button, MenuItem, etc.)

// create the item with a custom paint()-method
JButton menu_item = new JButton() {
  paint(Grahpics g) {
  g.drawImageI(...);  // drawing the bg-image
  g.drawString(...);  // drawing the text over the bg-image

//add the item to the Frame

while(true) {  //rendering-loop
Offline JuddMan

Senior Devvie

Medals: 1

Your Ad Here

« Reply #2 - Posted 2005-06-16 19:09:38 »

Override a JPanel and use it as your ContentPane... in the paintComponent() method, first paint the image and then paint the children...

public void paint(Graphics g)

each time you change the 'currentImage', call repaint();   and it'll update.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Sisyphus

Junior Newbie

« Reply #3 - Posted 2005-06-17 01:58:33 »

Thanks i'll try that Smiley
Pages: [1]
  ignore  |  Print  

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

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

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

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

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

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

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

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

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

nelsongames (4264 views)
2018-04-24 18:14:32
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

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