adding background image
how do i add background image to this code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class sampleProg extends JFrame {
JButton button = new JButton ("Result");
JButton button2 = new JButton ("Clear");
JLabel label = new JLabel ("Full Name");
JLabel label2 = new JLabel ("Age");
JLabel label3 = new JLabel ("English");
JLabel label4 = new JLabel ("Mathematics");
JLabel label5 = new JLabel ("Science");
JLabel label6 = new JLabel ("Social Studies");
JLabel label7 = new JLabel ("Height in cm");
JLabel label8 = new JLabel ("Weight in lbs");
JLabel label9 = new JLabel ("Message");
JLabel label10 = new JLabel ("Average");
JLabel label11 = new JLabel ("Remarks");
JLabel label12 = new JLabel ("Laurize Albarracin");
JTextField text = new JTextField ("");
JTextField text2 = new JTextField ("");
JTextField text3 = new JTextField ("");
JTextField text4 = new JTextField ("");
JTextField text5 = new JTextField ("");
JTextField text6 = new JTextField ("");
JTextField text7 = new JTextField ("");
JTextField text8 = new JTextField ("");
JTextField text9 = new JTextField ("");
JTextField text10 = new JTextField ("");
JTextField text11 = new JTextField ("");
int average;
JPanel background = new JPanel();
JFrame frame = new JFrame();
public sampleProg (String str){
super(str);
background.setLayout (null);
background.setBounds (30,50,90,20);
button.setBounds(350,170,90,20);
button2.setBounds(450,170,90,20);
label.setBounds(30,90,90,20);
label2.setBounds(30,130,90,20);
label3.setBounds(30,170,90,20);
label4.setBounds(30,210,90,20);
label5.setBounds(30,250,90,20);
label6.setBounds(30,290,90,20);
label7.setBounds(350,90,90,20);
label8.setBounds(350,130,90,20);
label9.setBounds(350,210,90,20);
label10.setBounds(350,250,90,20);
label11.setBounds(350,290,90,20);
label12.setBounds(300,35,150,20);
text.setBounds(130,90,190,20);
text2.setBounds(130,130,190,20);
text3.setBounds(130,170,190,20);
text4.setBounds(130,210,190,20);
text5.setBounds(130,250,190,20);
text6.setBounds(130,290,190,20);
text7.setBounds(450,90,250,20);
text8.setBounds(450,130,250,20);
text9.setBounds(450,210,250,20);
text10.setBounds(450,250,250,20);
text11.setBounds(450,290,250,20);
button.addActionListener (new ActionListener () {
public void actionPerformed (ActionEvent e){
text9.setText("Hi! "+text.getText()+"you are"+text2.getText()+"years of age and now you stand"+text7.getText()+"in cm while you're weight is"+text8.getText()+"in lbs. These are your remark and average");
int English = Integer.parseInt (text3.getText());
int Mathematics = Integer.parseInt (text4.getText());
int Science = Integer.parseInt (text5.getText());
int SocialStudies = Integer.parseInt(text6.getText());
average = (English+Mathematics+Science+SocialStudies)/4;
text10.setText(Integer.toString(average));
}
}
);
button2.addActionListener (new ActionListener(){
public void actionPerformed(ActionEvent e){
text.setText("");
text2.setText("");
text3.setText("");
text4.setText("");
text5.setText("");
text6.setText("");
text7.setText("");
text8.setText("");
text9.setText("");
text10.setText("");
text11.setText("");
}
});
background.add(button);
background.add(button2);
background.add(label);
background.add(label2);
background.add(label3);
background.add(label4);
background.add(label5);
background.add(label6);
background.add(label7);
background.add(label8);
background.add(label9);
background.add(label10);
background.add(label11);
background.add(label12);
background.add(text);
background.add(text2);
background.add(text3);
background.add(text4);
background.add(text5);
background.add(text6);
background.add(text7);
background.add(text8);
background.add(text9);
background.add(text10);
background.add(text11);
getContentPane().add(background);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
}
public static void main (String[]args){
sampleProg frame = new sampleProg("Swing Application");
frame.setSize(730,350);
frame.show();
}
}
View Answers
Related Tutorials/Questions & Answers:
adding background image - Java Beginnersadding background image how do i add
background image to this code... = new JTextField ("");
int average;
JPanel
background = new JPanel...);
background.add(text11);
getContentPane().add(
background background imagebackground image how to set
background image in jsp using netbeans IDE 6.9
Advertisements
UIView Image BackgroundUIView
Image Background
In this tutorial, we are going to show you how to add
image at
background in UIView. There are two different ways of
adding background image in your iphone application..
1. Either you can set the UIView
UIToolBar background imageUIToolBar
background image Hi,
How to set
background image of UIToolBar? Give me code for
adding UIToolBar's
background image.
Thanks
how to set background imagehow to set
background image how to set
image in
background in that
image i want over lay text how it possible in jsp?
using flash
image how it is overlayed in jsp page?
thanks
UIView Background Image:@"myimage.png"]];
Read more at UIView
Image Background Tutorial page.
Thanks...UIView
Background Image HI,
Please let's know how to add
background image to a view?
Thanks
Hi
You can use the following code
UITableViewCell background image iPhone application. I have to add the
background image to UITableViewCell. Please tell me how to add UITableViewCell
background image.
Thanks
Hi,
Here is the code example of UITableViewCell
background using
image.
UIView
Background image UIBarButtonItemBackground image UIBarButtonItem i wanted to add a
background image to my UIBarButtonItem.. that i created into .xib in my iPhone application.
Set the
background image to UIBarButtonItem
UIBarButtonItem *btn
uinavigationcontroller background image a
background image to uinavigationcontroller... the
Background Image to it as given belowâ?¦
#import <UIKit/UIKit.h>
#import <...uinavigationcontroller
background image I wants to add a
background UITextField Background ImageUITextField
Background Image How can i set a
background image... a
Background Image on UITextField
- (void)viewDidLoad {
[super viewDidLoad... wanted to add a small
image on text field as a right or left view. Find the code
Background Image for Navigation BarBackground Image for Navigation Bar
The tutorial illustrates how to add
background image for UINavigationBar.
To add a
background image to UINavigationBar... {
UIImage *
image = [UIImage imageNamed: @"background.png"];
[
image Photoshop change a background image
Photoshop: change a
background image
... to change
the
background of an
image. If you want to try this then this tutorial...
in which you want to change the
background image. I have selected an
image backgroundbackground how to add
image as
background to a frame
JSP Background Image
JSP
Background Image
... to create JSP
Background Image on your
login page.
Understand...;images1.gif"> is used to displays the
background image.
The JSP file
Photoshop Tutorial :background image own
background image. So let's
try.
Take a new file: Go to file menu and click... as a
background image as I have taken here.ADS_TO_REPLACE_5
Fill: Now go to Edit...
Make a Bullet
Background
Set Transparent Background ImageSet Transparent
Background Image
Swing components not only allow you to change the
background color of a component, but also you can give the beautiful look to your frame or other components by setting the transparent
background image background images in css not workingbackground images in css not working In the application i'm passing a
background image from CSS in the given format ...
background-
image: url... of
adding background images in css
Button with Image a button with iPhone
image on it. There is nothing in
adding Images of Iphone... toolbar...lets find out the steps.
Steps of
adding image on Button into iPhone... on
background but not on button
image.
Download the Source Code
UIButton Image SizeUIButton
Image Size
In this example we are going to discuss about how to set
image size and setting
image as a UIButton
background.
We are doing...];
//set
image as
background
[myButton setBackgroundImage
How to change background, change background
How to change
background
This example will teach you to change
background of any object... of the another picture to make
background
picture.
Paste: Go to Edit menu > Paste
iphone Image Moveiphone
Image Move
In this tutorial will learn how to use
Image View into view with
background image set and that
image can be moved any where on the view... and in View Controller will write the code for the
image so that it can move, will use
GRADIENT BACKGROUNDGRADIENT BACKGROUND How to set gradient colors a s
background for a jframe? pls help me..............
http://www.roseindia.net/java/example/java/swing/GradientColor.shtml
imageimage how to add the
image in servlet code
ImageImage how to insert
image in xsl without using xml. the
image was displayed in pdf..Please help me
ImageImage how to insert
image in xsl without using xml. the
image was displayed in pdf..Please help me
ImageImage how to insert
image in xsl without using xml. the
image was displayed in pdf..Please help me
image image Dear every body please help me how to add and retrive
image and video into oracle 11g using jsp
adding a dialogueadding a dialogue Blockquote
Hi can you help with the program below,the program is a loop that prints out a code and a quantity when prompt for the user input.what I need is to modify the code to incorporate a dialogue asking