Results 1 to 5 of 5
  1. #1
    Kay Ahmad is offline Member
    Join Date
    Apr 2015
    Posts
    3
    Rep Power
    0

    Default 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);
    }
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: how to put background image in this?i had try so many ways to put it but it didnt

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: how to put background image in this?i had try so many ways to put it but it didnt

    Quote Originally Posted by Kay Ahmad View Post
    Java Code:
    	public void actionPerformed(ActionEvent event)
    	{
               Object source = event.getSources();
    This can't compile, ActionEvent does not have a method getSources().
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    Kay Ahmad is offline Member
    Join Date
    Apr 2015
    Posts
    3
    Rep Power
    0

    Default Re: how to put background image in this?i had try so many ways to put it but it didnt

    Quote Originally Posted by gimbal2 View Post
    This can't compile, ActionEvent does not have a method getSources().
    thank you for your information

  5. #5
    Kay Ahmad is offline Member
    Join Date
    Apr 2015
    Posts
    3
    Rep Power
    0

    Default Re: how to put background image in this?i had try so many ways to put it but it didnt

    Alright i go check that website,thanks

Similar Threads

  1. Background Image
    By Flopet17 in forum Advanced Java
    Replies: 5
    Last Post: 03-07-2014, 08:24 PM
  2. use image for background
    By tony_stark in forum AWT / Swing
    Replies: 1
    Last Post: 05-31-2011, 08:20 PM
  3. [Help] W/ background image
    By gundum584 in forum New To Java
    Replies: 9
    Last Post: 01-10-2011, 05:48 AM
  4. Background image
    By leiferouis in forum New To Java
    Replies: 9
    Last Post: 03-08-2009, 05:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •