Posts

Showing posts from November, 2022

JFrame & JLable

 Code : -  // 1 - JFrame // 2 - JLabel // 3 - FlowLayout - basic JLabel background = new JLabel (); background . setLocation ( 150 , 150 ); background . setBackground ( Color . black ); background . setOpaque ( true ); background . setSize ( 250 , 250 ); JLabel heading = new JLabel ( "Details" ); // YOu can also use setText function for set Text heading . setForeground ( Color . black ); // Change the Text Color heading . setBackground ( Color . white ); heading . setOpaque ( true ); heading . setHorizontalAlignment ( JLabel . CENTER ); //heading.setText(); heading . setSize ( 250 , 40 );   //----------------------Name------------------- JLabel name = new JLabel (); name . setBackground ( Color . white ); name . setOpaque ( true ); name . setForeground ( Color . black ); name . setText ( "Name" ); name . setSize ( 50 , 20 ); name . setLocation ( 20 , 60 ); // Set Margin name . setHorizontalAlignment...

JFrame

How to use JFrame in java  Code : --  public class frame { public static void main ( String [] args ) { ImageIcon imageIcon = new ImageIcon ( "image2.jpeg" ); JFrame jFrame = new JFrame (); // Calling Class jFrame . setBounds ( 100 , 100 , 250 , 250 ); //jFrame.setSize(250,250); // Set Size of JFrame jFrame . setDefaultCloseOperation ( JFrame . EXIT_ON_CLOSE ); // For Exit jFrame . setLayout ( null ); //jFrame.setResizable(false); // For Resize of JFrame jFrame . setTitle ( "MyFrame" ); // SEt Title jFrame . setVisible ( true ); // For Showing jFrame . setIconImage ( imageIcon . getImage ()); //JFrame is a top-level container that provides a window on the screen //JFrame j =new JFrame(); //j.setSize(250,250); //j.setVisible(true); } }