الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

الية برمجة الانترفيس

مغلق
بدأه المارد01 في 17 مايو 2007 · 4 رد · 660 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم اخواني بدنا نبرمج الانترفيس سوا...

بدي افهم برمجة الانترفيس...

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;

public class Application 
{

  private JFrame form;
  private JPanel Main,P1,P2,P3,P4;
  private JLabel L2;
  public static  JTextField T1;
  public static  JComboBox G;
  public static  JRadioButton H1,H2,H3,H4;
  private ButtonGroup G1;
  public static  JButton B1;   
  public static  JList Lst;
  public static  Font F;

  private Actions Handler;  
 private Changes Change;
 private LIST LST;

  public static int FontSize=50;  
  public static int valBold = Font.PLAIN; 
  public static int valItalic = Font.PLAIN;	

  private void Form_Load()
  {
	  form=new JFrame("Formatting");
	  form.setSize(450,350);
	  form.setLocation(100,100);
	  form.setResizable(false);
	  form.setLayout(new BorderLayout());
	  JLabel L1=new JLabel("Formatting",JLabel.CENTER);
	  L1.setForeground(Color.red);
	  F=new Font("Serise",Font.BOLD,20);
	  L1.setFont(F);
   	form.add(L1,BorderLayout.NORTH);
   	B1=new JButton("Exit");
   	form.add(B1,BorderLayout.SOUTH);
  }



  private void Create_Panel1()
  {
	  T1=new JTextField("Test Data	   ");
	  P1=new JPanel();
	  T1.setEditable(false);
	  T1.setSize(100,30);
	  P1.setLayout(new FlowLayout());
	  F=new Font("TimesRoman",Font.PLAIN,FontSize);
	  T1.setFont(F);
	  P1.add(T1);
  }
  private  void Create_Panel2()
  {
	  P2=new JPanel();
	  P2.setLayout(new GridLayout(1,2,10,10));
	  JPanel Temp1,Temp2;

	  Temp1=new JPanel();
	  Temp2=new JPanel();


		String name[]={"Plain","Bold","Italic","Bold & Italic"};
		Temp1.setLayout(new GridLayout(3,1,10,10));
		JLabel L3=new JLabel("Select Style");
		JLabel L33=new JLabel("   ");
		G=new JComboBox(name);
		G.setMaximumRowCount(2);
		Temp1.add(L3);Temp1.add(G);Temp1.add(L33);


		Temp2.setLayout(new GridLayout(3,1,10,10));
		JLabel L5=new JLabel("Select Header Type");
		JLabel L55=new JLabel("   ");

		String size[];
		size=new String[5];
		for(int i=0;i<5;i++)
			size="H"+(i+1);
		Lst=new JList(size);	


		Temp2.add(L5);Temp2.add(new JScrollPane(Lst));Temp2.add(L55);

		P2.add(Temp1);P2.add(Temp2);




  }
  private  void Create_Panel3()
  {
	  P3=new JPanel();
	  P3.setLayout(new FlowLayout());
	  H1=new JRadioButton("Red",true);
	  H2=new JRadioButton("Green",false);
	  H3=new JRadioButton("Blue",false);
	  H4=new JRadioButton("White",false);
	  G1=new ButtonGroup();
	  JLabel L55=new JLabel("Select Color ");
	  G1.add(H1);	G1.add(H2);G1.add(H3);G1.add(H4);
	  P3.add(L55);P3.add(H1);P3.add(H2);P3.add(H3);P3.add(H4);

  }
  public void Main_Panel()
  {
	  Form_Load();
	  Create_Panel1();
	  Create_Panel2();
	  Create_Panel3();


	  Main=new JPanel();
	  Main.setLayout(new GridLayout(3,1));
   	Main.add(P1);
	  Main.add(P2);
	  Main.add(P3);


	  form.add(Main,BorderLayout.CENTER);

  }
  public void Run()
  {
	  Main_Panel();


	Actions Handler=new Actions();
	  B1.addActionListener(Handler);
	  Changes Change=new Changes();

	  H1.addItemListener(Change);
   	H2.addItemListener(Change);
	  H3.addItemListener(Change);
	  H4.addItemListener(Change);

	G.addItemListener(Change); 	
	LST=new LIST();	
	Lst.addListSelectionListener(LST);



   	form.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	  form.setVisible(true);

  }




  public static void main (String[] args) 
  {



	Application App=new Application(); 	

	App.Run();
	//form.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	  //form.setVisible(true);
  }


}
********************************
import javax.swing.event.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class Changes extends Application implements ItemListener
{

	private Font F;
   	public void itemStateChanged(ItemEvent e)
	  {



	  }


}
***********************
import java.awt.event.*;
import javax.swing.event.*;
import java.awt.*;
import javax.swing.*;

public class LIST extends Application implements ListSelectionListener
{
	public void valueChanged( ListSelectionEvent event )
		 {
		 	Object obj=Lst.getSelectedValue();
		 	 String st=obj.toString();

		 }


}			  
**************
import java.awt.event.*;
public class Actions implements ActionListener 
{
	  public void actionPerformed(ActionEvent e)
	  {
		  String command=e.getActionCommand();
		  if(command=="Exit")
			  System.exit(0);

	  }

}

تم تعديل هذه المشاركة بواسطة hazzoom في 17 مايو 2007 في 23:22 — السبب: code tags add by hazzoom

#2

please give us a specific question and use code tag

#3

أحسن طريقه للتعلم أن تقرأ بنفسك فالأمر أسهل ما يكون

#4

أخي حاولت ارفعه بس مازبط....

كيف ممكن ارفعه على شكل كود

#5

اين الردود بدي اتعلم

هذا الموضوع مغلق.

مواضيع مشابهة