0% found this document useful (0 votes)
47 views4 pages

Box Java

The document contains code for a Java applet that creates a GUI with multiple panels. It initializes buttons, progress bars, labels and separators. Buttons are added to different panels with box layouts arranged vertically and horizontally. Event listeners are added to buttons to increment the progress bar value on click. The applet displays options, pictures and a choice panel with OK and Cancel buttons to create an image game interface.

Uploaded by

dev_ok
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views4 pages

Box Java

The document contains code for a Java applet that creates a GUI with multiple panels. It initializes buttons, progress bars, labels and separators. Buttons are added to different panels with box layouts arranged vertically and horizontally. Event listeners are added to buttons to increment the progress bar value on click. The applet displays options, pictures and a choice panel with OK and Cancel buttons to create an image game interface.

Uploaded by

dev_ok
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

BOX.

JAVA:-

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
/*<applet code= box.class width=500 height=500></applet>*/
public class box extends JApplet
{
JProgressBar jp1=new JProgressBar();
JSeparator js1=new JSeparator(JSeparator.HORIZONTAL);
JLabel jlabel=new JLabel("");
String d="";
public void init()
{
Container contentPane =getContentPane();
contentPane.setLayout(new FlowLayout());
JPanel jpanel1=new JPanel();
JPanel jpanel2=new JPanel();
JPanel jpanel3=new JPanel();
JPanel jpanel4=new JPanel();
JPanel jpanel5=new JPanel();
JPanel jpanel6=new JPanel();
//jp1=new JProgressBar();
//jp1.setValue(10);

Icon normal=new ImageIcon("label.jpg");


Icon rollover =new ImageIcon("a2.jpg");
Icon pressed =new ImageIcon("a3.jpg");

JButton jbutton=new JButton(),jbutton1=new JButton(),jbutton2=new


JButton(),jbutton3=new JButton(),jbutton4=new JButton("OK"),jbutton5=new
JButton("CANCEL"),jbutton6=new JButton("new"),jbutton7=new JButton("new"),jbutton8=new
JButton("new"),jbutton9=new JButton("new");
jbutton.setIcon(normal);
jbutton1.setIcon(normal);
jbutton2.setIcon(normal);
jbutton3.setIcon(normal);

jpanel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Options"));

jpanel1.setLayout(new BoxLayout(jpanel1,BoxLayout.Y_AXIS));

jpanel1.add(Box.createVerticalStrut(10));
jpanel1.add(jbutton);
jpanel1.add(Box.createVerticalStrut(10));
jpanel1.add(jbutton1);
jpanel1.add(Box.createVerticalStrut(10));
jpanel1.add(jbutton2);
jpanel1.add(Box.createVerticalStrut(10));
jpanel1.add(jbutton3);
jpanel1.add(Box.createVerticalStrut(10));

jpanel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Picture"));

jbutton6.setBounds(50,50,200,100);
jpanel2.add(jbutton6);

jpanel2.add(jbutton7);
jpanel2.add(jbutton8);
jpanel2.add(jbutton9);
jpanel2.setLayout(new BoxLayout(jpanel2,BoxLayout.X_AXIS));
jpanel2.add(Box.createRigidArea(new Dimension(20,330)));
//jpanel2.add(jpanel3);

jpanel2.add(Box.createRigidArea(new Dimension(200,330)));

jpanel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Your
Choice"));
jpanel3.setLayout(new BoxLayout(jpanel3,BoxLayout.X_AXIS));
jpanel3.add(Box.createHorizontalStrut(10));
jpanel3.add(jbutton4);
jpanel3.add(Box.createHorizontalStrut(10));
jpanel3.add(jbutton5);
jpanel3.add(Box.createHorizontalStrut(10));

//jp1.setStringPainted(true);

jbutton4.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
jp1.setValue(jp1.getValue() +25);
//d=jp1.getValue();
// jlabel("d");

}
});
contentPane.add(jpanel1);
contentPane.add(jpanel2);
contentPane.add(js1);
contentPane.add(jpanel3);
contentPane.add(jp1);
contentPane.add(jlabel);
}
}
TOPIC:- Image Game.

Submitted To:- Submitted By:-


Ms.Rajni Devender kumar
MCA 5th (B)
7008210248

You might also like