Results 1 to 5 of 5
- 04-30-2015, 06:28 AM #1
Member
- Join Date
- Apr 2015
- Posts
- 3
- Rep Power
- 0
how to put background image in this?i had try so many ways to put it but it didnt dis
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class loginstaff extends JFrame implements ActionListener
{
public static void main(String[]args)
{
JFrame frame = new JFrame("TMpoint");
frame.setSize(400,200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
JPanel panel = new JPanel();
frame.add(panel);
placeComponents(panel);
frame.setVisible(true);
}
private static void placeComponents(JPanel panel)
{
panel.setLayout(null);
JLabel label1 = new JLabel("Staff ID : ");
JTextField textfield1 = new JTextField(20);
label1.setBounds(10, 10, 80, 25);
textfield1.setBounds(100, 10, 160, 25);
panel.add(label1);
panel.add(textfield1);
JLabel label2 = new JLabel("Password : ");
JTextField textfield2 = new JTextField(20);
label2.setBounds(10, 40, 80, 25);
textfield2.setBounds(100, 40, 160, 25);
panel.add(label2);
panel.add(textfield2);
JButton login = new JButton("Login");
login.setBounds(250, 80, 80, 25);
panel.add(login);
}
public void actionPerformed(ActionEvent event)
{
Object source = event.getSources();
if(source==login);
{
homepage frame = new homepage();
frame.setTitle("Homepage");
frame.setVisible(true);
frame.setSize(400,200);
frame. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
}
- 04-30-2015, 07:55 AM #2
Re: how to put background image in this?i had try so many ways to put it but it didnt
BB Code List - Java Programming Forum - Learn Java Programming
https://tips4java.wordpress.com/2008...kground-panel/
Background Image On J Panel at JavaRanch
Also, learn to use layouts and get rid of your setLayout(null).
Lesson: Laying Out Components Within a Container (The Javaâ„¢ Tutorials > Creating a GUI With JFC/Swing)
db
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 04-30-2015, 11:26 AM #3
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
- 04-30-2015, 11:39 AM #4
Member
- Join Date
- Apr 2015
- Posts
- 3
- Rep Power
- 0
- 04-30-2015, 11:40 AM #5
Member
- Join Date
- Apr 2015
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Background Image
By Flopet17 in forum Advanced JavaReplies: 5Last Post: 03-07-2014, 09:24 PM -
use image for background
By tony_stark in forum AWT / SwingReplies: 1Last Post: 05-31-2011, 09:20 PM -
[Help] W/ background image
By gundum584 in forum New To JavaReplies: 9Last Post: 01-10-2011, 06:48 AM -
Background image
By leiferouis in forum New To JavaReplies: 9Last Post: 03-08-2009, 06:49 PM
Bookmarks