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

[تنبيه - عنوان غير مناسب : ]استفسار لتصحيح الكوود

بدأه يارا... في 4 مارس 2011 · 1 رد · 234 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

حبيت اسال كيف اسوي البرامج هذي في برنامج واحد بحيث تسوي لي صفحه تسجيل في جامعه

يعني الطالب يدخل اسمه و السجل المدني ويحدد ذكر او انثى ويختار اكثر من تخصص

انا كتبت الاكواد هذي في 3 برامج وابيها في برنامج واحد

البرنامج الاول..

import java.awt.FlowLayout;

import java.awt.event.ActionListener;

import java.awt.event.ActionEvent;

import javax.swing.JFrame;

import javax.swing.JTextField;

import javax.swing.JPasswordField;

import javax.swing.JOptionPane;

public class TextFieldFrame extends JFrame

{

private JTextField textField1;

private JTextField textField2;

private JTextField textField3;

private JPasswordField passwordField; /

public TextFieldFrame()

{

super( "Testing JTextField and JPasswordField" );

setLayout( new FlowLayout() );

textField1 = new JTextField( 10 );

add( textField1 );

textField2 = new JTextField( "user name" );

add( textField2 );

textField3 = new JTextField( "Uneditable text field", 21 );

textField3.setEditable( false );

add( textField3 );

passwordField = new JPasswordField( "Hidden text" );

add( passwordField );

TextFieldHandler handler = new TextFieldHandler();

textField1.addActionListener( handler );

textField2.addActionListener( handler );

textField3.addActionListener( handler );

passwordField.addActionListener( handler );

}

private class TextFieldHandler implements ActionListener

{

public void actionPerformed( ActionEvent event )

{

String string = "";

if ( event.getSource() == textField1 )

string = String.format( "textField1: %s",

event.getActionCommand() );

else if ( event.getSource() == textField2 )

string = String.format( "textField2: %s",

event.getActionCommand() );

else if ( event.getSource() == textField3 )

string = String.format( "textField3: %s",

event.getActionCommand() );

else if ( event.getSource() == passwordField )

string = String.format( "passwordField: %s",

new String( passwordField.getPassword() ) );

JOptionPane.showMessageDialog( null, string );

}

}

}

import javax.swing.JFrame;

public class TextFieldTest

{

public static void main( String args[] )

{

TextFieldFrame textFieldFrame = new TextFieldFrame();

textFieldFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

textFieldFrame.setSize( 325, 100 );

textFieldFrame.setVisible( true );

}

}

البرنامج الثاني..

import java.awt.FlowLayout;

import java.awt.TextField;

import java.awt.event.ItemListener;

import java.awt.event.ItemEvent;

import javax.swing.JFrame;

import javax.swing.JTextField;

import javax.swing.JCheckBox;

public class CheckBoxFrame extends JFrame

{

private JTextField textField;

private JCheckBox maleJCheckBox;

private JCheckBox femaleJCheckBox;

public CheckBoxFrame()

{

super( "JCheckBox Test" );

setLayout( new FlowLayout() );

textField = new JTextField( "sex", 20 );

textField.setTextField( new Font( "Serif", textField.PLAIN, 14 ) );

add( textField );

boldJCheckBox = new JCheckBox( "male" );

italicJCheckBox = new JCheckBox( "female" );

add( maleJCheckBox );

add( femaleJCheckBox );

CheckBoxHandler handler = new CheckBoxHandler();

maleJCheckBox.addItemListener( handler );

femaleJCheckBox.addItemListener( handler );

}

private class CheckBoxHandler implements ItemListener

{

private int valmale = textField.PLAIN;

private int valfemale = textField.PLAIN;

public void itemStateChanged( ItemEvent event )

{

if ( event.getSource() == maleJCheckBox )

valmale =

maleJCheckBox.isSelected() ? textField.Male : textField.PLAIN;

if ( event.getSource() == femaleJCheckBox )

valfemale =

femaleJCheckBox.isSelected() ? textField.Famale : textField.PLAIN;

}

}

}

import javax.swing.JFrame;

public class CheckBoxTest

{

public static void main( String args[] )

{

CheckBoxFrame checkBoxFrame = new CheckBoxFrame();

checkBoxFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

checkBoxFrame.setSize( 275, 100 );

checkBoxFrame.setVisible( true );

}

}

البرنامج الثالث..

import java.awt.FlowLayout;

import java.awt.TextField;

import java.awt.event.ItemListener;

import java.awt.event.ItemEvent;

import javax.swing.JFrame;

import javax.swing.JTextField;

import javax.swing.JRadioButton;

import javax.swing.ButtonGroup;

public class RadioButtonFrame extends JFrame

{

private JTextField textField;

private text EngineeringText;

private text ComputerText;

private text MedicineText;

private text PharmaceuticalsText;

private JRadioButton EngineeringJRadioButton;

private JRadioButton ComputerJRadioButton;

private JRadioButton MedicineJRadioButton;

private JRadioButton PharmaceuticalsJRadioButton;

private ButtonGroup radioGroup;

public RadioButtonFrame()

{

super( "Disciplines" );

setLayout( new FlowLayout() );

textField = new JTextField( "Watch the Disciplines you want", 25 );

add( textField );

plainJRadioButton = new JRadioButton( "Engineering", true );

boldJRadioButton = new JRadioButton( "Computer", false );

italicJRadioButton = new JRadioButton( "Medicine", false );

boldItalicJRadioButton = new JRadioButton( "Pharmaceuticals", false );

add( EngineeringJRadioButton );

add(ComputerJRadioButton );

add( MedicineJRadioButton );

add(PharmaceuticalsJRadioButton );

radioGroup = new ButtonGroup();

radioGroup.add( EngineeringJRadioButton );

radioGroup.add( ComputerJRadioButton );

radioGroup.add( MedicineJRadioButton );

radioGroup.add(PharmaceuticalsJRadioButton );

EngineeringText = new textField( "Serif", textField.Engineering, 14 );

ComputerText = new textField( "Serif", textField.Computer, 14 );

MedicineText = new textField( "Serif", textField.Medicine, 14 );

PharmaceuticalsText = new textField( "Serif", textField.Pharmaceuticals, 14 );

textField.setFont( plainFont );

EngineeringJRadioButton.addItemListener(

new RadioButtonHandler( EngineeringText ) );

ComputerJRadioButton.addItemListener(

new RadioButtonHandler(ComputerText ) );

MedicineJRadioButton.addItemListener(

new RadioButtonHandler( MedicineText ) );

PharmaceuticalsJRadioButton.addItemListener(

new RadioButtonHandler( PharmaceuticalsText ) );

}

private class RadioButtonHandler implements ItemListener

{

private Disciplines disciplines;

public RadioButtonHandler( Disciplines D )

{

Disciplines=D;

}

public void itemStateChanged( ItemEvent event )

{

textField.setFont( Disciplines );

}

}

}

import javax.swing.JFrame;

public class RadioButtonTest

{

public static void main( String args[] )

{

RadioButtonFrame radioButtonFrame = new RadioButtonFrame();

radioButtonFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

radioButtonFrame.setSize( 300, 100 );

radioButtonFrame.setVisible( true );

}

}

ياليت احد يقدر يفيدني ;( لان لازم اسلمه يوم الاحد :(

#2

الأخ الكريم/الأخت الكريمة

السلام عليكم ورحمة الله وبركاته

مرحباً بكم في منتدى الفريق العربي للبرمجة

نود تنبيهك أن العنوان غير مناسب.

الرجاء اختيار عنوان مناسب أكثر في مواضيعك القادمة، وهذا بمثابة إشعار للأهمية.

وفي حال التكرار سيتعرض موضوعك للإغلاق والحذف!!!

قواعد المشاركة

/index.php?showtopic=29343

شاكرين لكم حُسن تعاونكم

حزمة المحرك الإصدارة 0.8

أي أحد يجد أني ظلمته فليراسلني

وبإذن الله لو كان له حق سيأخذه

728x90.png

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…