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.
make slideshow in JAVAhow to create a slideshow in java with buttons?
Page 1 of 1
8 Replies - 9633 Views - Last Post: 06 December 2010 - 06:37 AM
#1
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.
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.
Replies To: make slideshow in JAVA
#2
Re: make slideshow in JAVA
Posted 06 December 2010 - 02:08 AM
Okay? So work that out.
#3
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.
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.
#4
Re: make slideshow in JAVA
Posted 06 December 2010 - 05:11 AM
Ice(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.
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?
#5
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
#6
Re: make slideshow in JAVA
Posted 06 December 2010 - 06:04 AM
masijade, 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?
#7
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.
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
#8
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.
#9
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/
I have a tutorial on it here:
http://www.dreaminco...part-1-loading/
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote







|