CyberCodes
[TUT] Create a Frame in Java with 2 Labels Welcome

Reminders sa mga rehistradong myembro:

•ang lengwahe na gagamitin ay pawang english at tagalog lamang

•Bawal po dito ang pakikipag away

•Bawal ang mga shorcut na mga words
Example: txt, Pwd, at iba pa

•Bawal mababastos at masasakit na salita o anu mang makakasakit
ng damdamin ng isang myembro ng forum na ito

•use the "like" button if the post of the following user you think are usefull



Join the forum, it's quick and easy

CyberCodes
[TUT] Create a Frame in Java with 2 Labels Welcome

Reminders sa mga rehistradong myembro:

•ang lengwahe na gagamitin ay pawang english at tagalog lamang

•Bawal po dito ang pakikipag away

•Bawal ang mga shorcut na mga words
Example: txt, Pwd, at iba pa

•Bawal mababastos at masasakit na salita o anu mang makakasakit
ng damdamin ng isang myembro ng forum na ito

•use the "like" button if the post of the following user you think are usefull

CyberCodes
Would you like to react to this message? Create an account in a few clicks or log in to continue.

[TUT] Create a Frame in Java with 2 Labels

Go down

[TUT] Create a Frame in Java with 2 Labels Empty [TUT] Create a Frame in Java with 2 Labels

Post by princeterror Sat Jul 21, 2012 2:19 am

making Frame/Form with 2 Labels with color on Java
we should use Eclipse Galileo Language

for main class

Code:
class Main {

   public static void main(String x[])
   {
      new Frame("MY FRAME TEST"); <-------Title ng Frame Naten :D
      
   }
}

for frame class

Code:
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;




class Frame extends JFrame
{
public Frame(String title)
{
   super(title);
   createtxt();
   toplabel();
   initialize();
   
}
public void initialize()
{
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   setSize(600,500);
   setLocationRelativeTo(null);
   setVisible(true);

}


private void createtxt()
{
   JLabel x=new JLabel("THIS IS LABEL 2");
   x.setToolTipText("Label2");
   x.setForeground(Color.MAGENTA);
   add(x,BorderLayout.CENTER);
   x.setHorizontalAlignment(SwingConstants.CENTER);
   
   
}


private void toplabel()
{

   JLabel y=new JLabel("THIS IS LABEL 1");
   y.setToolTipText("Label 1");
   y.setForeground(Color.BLACK);
   add(y,BorderLayout.BEFORE_FIRST_LINE);
   y.setHorizontalAlignment(SwingConstants.CENTER);
}



}
princeterror
princeterror
Universal Moderator
Universal Moderator

Posts : 272
Credits : 11465
Fame : 81
Join date : 2012-06-07
Age : 32

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum