View Single Post
  #3 (permalink)  
Old 11-05-2007, 07:53 AM
archanajathan archanajathan is offline
Member
 
Join Date: Nov 2007
Posts: 5
archanajathan is on a distinguished road
Code:
import javax.swing.*; import java.awt.*; import java.io.*; import javax.imageio.*; import java.awt.image.*; import java.awt.event.*; import java.applet.*; import java.net.*; public class welcome extends JFrame { JTextArea txt=new JTextArea("WELCOME"); //TEXT AREA JTextArea txt1=new JTextArea("HELLO"); //TEXT AREA JButton enter=new JButton(" ENTER "); //ENTER BUTTON JLabel label_image1=new JLabel(); JLabel label_image2=new JLabel(); JPanel jp=(JPanel)this.getContentPane(); public static void main(String args[]) { new welcome(); } public welcome() { setExtendedState(getExtendedState() | Frame.MAXIMIZED_BOTH);//MAXIMIZES THE WINDOW ON EXECUTION try { label_image1.setIcon(new ImageIcon("a4.jpg")); //SETS THE IMAGES OF THE LABELS label_image2.setIcon(new ImageIcon("a5.jpg")); jp.setLayout(null);//REQUIRED TO POSITION THE COMPONENTS jp.setBackground(new Color(0,0,0)); //FRAME BACKGROUND SET TO BLACK enter.setForeground(new Color(0,255,255)); //ENTER BUTTON FOREGROUND = LIGHT BLUE txt.setForeground(new Color(255,0,0)); //FOREGROUND OF TEXT = RED txt1.setForeground(new Color(255,0,0)); //FOREGROUND OF TEXT = RED enter.setBackground(new Color(0,0,255)); //BACKGROUND OF BUTTON = DARK BLUE txt.setBackground(new Color(0,0,0)); //BACKGROUND OF TEXT = BLACK txt1.setBackground(new Color(0,0,0)); //BACKGROUND OF TEXT = BLACK enter.setFont(new Font("Cooper Black",Font.PLAIN, 30)); //FONT OF ENTER BUTTON txt.setFont(new Font("Courier", Font.BOLD, 48)); //FONT OF TEXT txt1.setFont(new Font("Courier", Font.BOLD, 20)); //FONT OF TEXT enter.setBounds(430,450,150,50); //PARAMETERS(X,Y,WIDTH,HEIGHT) txt.setBounds(300,100,400,200); //SET POSITION AND SIZE OF THE COMPONENTS txt1.setBounds(300,350,500,100); //SET POSITION AND SIZE OF THE COMPONENTS label_image1.setBounds(50,50,100,200); label_image2.setBounds(600,550,100,200); enter.setBorder(BorderFactory.createLineBorder(Color.red, 10)); //CREATE BORDER FOR ENTER BUTTON AS RED txt.setEditable(false); //SET TO UNEDITABLE txt1.setEditable(false); //SET TO UNEDITABLE setSize(800,600); //SET SIZE OF FRAME setVisible(true); jp.add(enter); setVisible(true); //ADDED ALL THE COMPONENTS TO FRAME/PANEL jp.add(txt); setVisible(true); jp.add(txt1); setVisible(true); jp.add(label_image1); setVisible(true); jp.add(label_image2); setVisible(true); }catch(Exception e){} } }
Do execute the code 4-5 times.. I have not sent the images.. It is supposed to diaplay 2 texts, 1 button and 2 images.

Last edited by JavaBean : 11-05-2007 at 10:14 AM. Reason: Code placed inside [code] tag.
Reply With Quote