make slideshow in JAVA

how to create a slideshow in java with buttons?

Page 1 of 1

8 Replies - 21508 Views - Last Post: 06 December 2010 - 06:37 AM Rate Topic: -----

#1 JaCod  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 27-October 10

make slideshow in JAVA

Posted 06 December 2010 - 01:32 AM

how to create a slideshow in java with buttons?
I'm still having trouble making a slide images appear alternately, this time using the keypad as a medium for change to the next image.
:dontgetit:
Is This A Good Question/Topic? 0
  • +

Replies To: make slideshow in JAVA

#2 masijade  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 196
  • View blog
  • Posts: 580
  • Joined: 03-April 10

Re: make slideshow in JAVA

Posted 06 December 2010 - 02:08 AM

Okay? So work that out.
Was This Post Helpful? 0
  • +
  • -

#3 Ice(ITB)  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 19-August 09

Re: make slideshow in JAVA

Posted 06 December 2010 - 04:11 AM

You have the problem learned off well... but you need to think about how your gonna step through a program, that will solve this problem. Don't let the entire programs needs scare you. First start with the easy stuff, like making the gui, having the buttons where you want them, and then worry about the next part... perhaps where to put the images. Or what to put them in. Break the big problem into small ones, that can be solved with code.

If you can't make a big problem into a sovlable chain of smaller problems... then you got a lot of work to do and to be honest you'll find it hard to survive as a programmer.

Have a look at flow charts. They can help you understand the stages a program has to reach. Making it clear what parts are seperate pieces of code... ie functions/methods.
Was This Post Helpful? 0
  • +
  • -

#4 JaCod  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 27-October 10

Re: make slideshow in JAVA

Posted 06 December 2010 - 05:11 AM

View PostIce(ITB), on 06 December 2010 - 03:11 AM, said:

You have the problem learned off well... but you need to think about how your gonna step through a program, that will solve this problem. Don't let the entire programs needs scare you. First start with the easy stuff, like making the gui, having the buttons where you want them, and then worry about the next part... perhaps where to put the images. Or what to put them in. Break the big problem into small ones, that can be solved with code.

If you can't make a big problem into a sovlable chain of smaller problems... then you got a lot of work to do and to be honest you'll find it hard to survive as a programmer.

Have a look at flow charts. They can help you understand the stages a program has to reach. Making it clear what parts are seperate pieces of code... ie functions/methods.


This is my code


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;


class Gambar extends JFrame  {
	private JLabel lblsource=new JLabel("Source Code");
   	private TextArea txahasil=new TextArea();
	private JButton bttest=new JButton("next");
	JLabel gambar = new JLabel(new ImageIcon("gb.png"));
        JLabel gambar = new JLabel(new ImageIcon("gb2.png"));
	public Gambar() {
		setTitle("Make to Next Picture");
		Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
		int w=400;
		int h=550;
		int l = (dim.width - w)/2;
		int t = (dim.height - h)/2;
		setLocation(l,t);
		setSize(w,h);
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	public void komponenVisual() {
		getContentPane().setLayout(null);

		getContentPane().add(bttest);
		bttest.setBounds(10,60,80,20 );
	    getContentPane().add(gambar);
        gambar.setBounds(10,90,380,150);
		txahasil.setEditable(false);
		setVisible(true);
	}

	public void aksiReaksi() {
       bttest.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {

	      }
		});



	}

 public static void main(String args[]) {
		Gambar vk=new Gambar();
		vk.komponenVisual();
		vk.aksiReaksi();
	}
}



I intend to convert images (gb.png) to the next image (gb2.png) while clicking the "next". maybe that's my current difficulties, how? if anyone can give me advice?
Was This Post Helpful? 0
  • +
  • -

#5 masijade  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 196
  • View blog
  • Posts: 580
  • Joined: 03-April 10

Re: make slideshow in JAVA

Posted 06 December 2010 - 05:18 AM

Wow, you actually did something. By removing the component containing the image from the container in which it resides and adding a newly created component in it's place. See the API docs for the container (and/or layout) involved and its remove/delete and add methods. Then validate/repaint the container containing that component.

This post has been edited by masijade: 06 December 2010 - 05:19 AM

Was This Post Helpful? 0
  • +
  • -

#6 JaCod  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 27-October 10

Re: make slideshow in JAVA

Posted 06 December 2010 - 06:04 AM

View Postmasijade, on 06 December 2010 - 04:18 AM, said:

Wow, you actually did something. By removing the component containing the image from the container in which it resides and adding a newly created component in it's place. See the API docs for the container (and/or layout) involved and its remove/delete and add methods. Then validate/repaint the container containing that component.


I mean: how memnambahkan method in ActionListener for something to change the image into gb2.png gb.png?
:helpsmilie:
Was This Post Helpful? 0
  • +
  • -

#7 Ice(ITB)  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 19-August 09

Re: make slideshow in JAVA

Posted 06 December 2010 - 06:08 AM

Ah ;D good to see you got somewhere.
To continue as you intend would end up creating a lot of JLabels.

When in reality all you ever need is one JLabel that displays an image, then changes to the next image when a button is hit.

lets say you make a Jlabel called displayBox. Well then everytime you wanted to set a new image to this you'd use use the JLabel funtion .setIcon( with a new image Icon declared in here);

The setIcon would be called inside an action listener set on the next/back buttons.

This post has been edited by Ice(ITB): 06 December 2010 - 06:12 AM

Was This Post Helpful? 0
  • +
  • -

#8 masijade  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 196
  • View blog
  • Posts: 580
  • Joined: 03-April 10

Re: make slideshow in JAVA

Posted 06 December 2010 - 06:09 AM

And that's what I just described. Give it a try. I will not write code for you, it is your assignment, you need to do it.
Was This Post Helpful? 0
  • +
  • -

#9 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2876
  • View blog
  • Posts: 11,051
  • Joined: 15-July 08

Re: make slideshow in JAVA

Posted 06 December 2010 - 06:37 AM

Ice(ITB) is right on the money here. You should have a JLabeland add it to the screen. Then simply load images into ImnageIcons and set the image to the JLabel.

I have a tutorial on it here:
http://www.dreaminco...part-1-loading/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1