إعـــــــلان

تقليص
لا يوجد إعلان حتى الآن.

مساعدة في الجافا

تقليص
X
 
  • تصفية - فلترة
  • الوقت
  • عرض
إلغاء تحديد الكل
مشاركات جديدة

  • مساعدة في الجافا

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

  • #2
    السلام عليكم

    سوينا البرامج تبع لاب 2
    اول شي الحسابه

    وهذا كودها


    package calculator;

    import java.awt.Rectangle;

    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    import javax.swing.SwingConstants;

    public class CalculatorFrame extends JFrame {

    private static final long serialVersionUID = 1L;
    private JPanel jContentPane = null;
    private JTextField txtFirst = null;
    private JTextField txtResult = null;
    private JButton btnAdd = null;
    private JButton btnSubtract = null;
    private JLabel jLabel = null;
    private JLabel jLabel1 = null;
    private JTextField txtSecond = null;
    private JLabel lblResult = null;

    protected void btnAddClicked() {
    double num1 = Double.parseDouble(txtFirst.getText());
    double num2 = Double.parseDouble(txtSecond.getText());

    double result = num1 + num2;

    txtResult.setText(String.valueOf(result));
    }

    protected void btnSubtractClicked() {
    double num1 = Double.parseDouble(txtFirst.getText());
    double num2 = Double.parseDouble(txtSecond.getText());

    double result = num1 - num2;

    txtResult.setText(String.valueOf(result));
    }

    /**
    * This method initializes btnAdd
    *
    * @return javax.swing.JButton
    */
    private JButton getBtnAdd() {
    if (btnAdd == null) {
    btnAdd = new JButton();
    btnAdd.setBounds(new Rectangle(33, 137, 79, 24));
    btnAdd.setText("Add");
    btnAdd.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent e) {
    btnAddClicked();
    }
    });
    }
    return btnAdd;
    }

    /**
    * This method initializes btnSubtract
    *
    * @return javax.swing.JButton
    */
    private JButton getBtnSubtract() {
    if (btnSubtract == null) {
    btnSubtract = new JButton();
    btnSubtract.setBounds(new Rectangle(160, 139, 89, 20));
    btnSubtract.setText("Subtract");
    btnSubtract.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent e) {
    btnSubtractClicked();
    }
    });
    }
    return btnSubtract;
    }

    /**
    * This method initializes txtFirst
    *
    * @return javax.swing.JTextField
    */
    private JTextField getTxtFirst() {
    if (txtFirst == null) {
    txtFirst = new JTextField();
    txtFirst.setBounds(new Rectangle(141, 25, 143, 23));
    }
    return txtFirst;
    }

    /**
    * This method initializes jTextField1
    *
    * @return javax.swing.JTextField
    */
    private JTextField getTxtResult() {
    if (txtResult == null) {
    txtResult = new JTextField();
    txtResult.setBounds(new Rectangle(141, 89, 144, 23));
    }
    return txtResult;
    }

    /**
    * This method initializes txtSecond
    *
    * @return javax.swing.JTextField
    */
    private JTextField getTxtSecond() {
    if (txtSecond == null) {
    txtSecond = new JTextField();
    txtSecond.setBounds(new Rectangle(141, 57, 144, 23));
    }
    return txtSecond;
    }

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    CalculatorFrame thisClass = new CalculatorFrame();
    thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_ CLOSE);
    thisClass.setVisible(true);
    }
    });
    }

    /**
    * This is the default constructor
    */
    public CalculatorFrame() {
    super();
    initialize();
    }

    /**
    * This method initializes this
    *
    * @return void
    */
    private void initialize() {
    this.setSize(300, 200);
    this.setContentPane(getJContentPane());
    this.setTitle("JFrame");
    }

    /**
    * This method initializes jContentPane
    *
    * @return javax.swing.JPanel
    */
    private JPanel getJContentPane() {
    if (jContentPane == null) {
    lblResult = new JLabel();
    lblResult.setBounds(new Rectangle(90, 94, 43, 16));
    lblResult.setHorizontalAlignment(SwingConstants.RI GHT);
    lblResult.setText("Result:");
    jLabel1 = new JLabel();
    jLabel1.setBounds(new Rectangle(30, 61, 103, 16));
    jLabel1.setHorizontalAlignment(SwingConstants.RIGH T);
    jLabel1.setText("Second Number:");
    jLabel = new JLabel();

    jLabel.setBounds(new Rectangle(47, 28, 86, 16));
    jLabel.setHorizontalAlignment(SwingConstants.RIGHT );
    jLabel.setText("First Number:");
    jContentPane = new JPanel();
    jContentPane.setLayout(null);
    jContentPane.add(getTxtFirst(), null);
    jContentPane.add(getTxtResult(), null);
    jContentPane.add(getBtnAdd(), null);
    jContentPane.add(getBtnSubtract(), null);
    jContentPane.add(jLabel, null);
    jContentPane.add(jLabel1, null);
    jContentPane.add(getTxtSecond(), null);
    jContentPane.add(lblResult, null);
    }
    return jContentPane;
    }

    }



    وَمَا كَانَ رَبُّكَ نَسِيًّا

    تعليق


    • #3
      وهذا الــ dmain تبع الستودنت
      package gui;

      import javax.swing.SwingUtilities;
      import java.awt.BorderLayout;
      import javax.swing.JPanel;
      import javax.swing.JFrame;
      import java.awt.GridBagLayout;
      import javax.swing.JButton;
      import java.awt.GridBagConstraints;
      import javax.swing.JLabel;
      import javax.swing.JTextField;

      import domain.Student;
      import java.awt.Insets;
      import java.awt.Dimension;

      public class StudentFrame extends JFrame {

      private static final long serialVersionUID = 1L;
      private JPanel jContentPane = null;
      private JPanel jPanel = null;
      private JButton btnAdd = null;
      private JPanel jPanel1 = null;
      private JLabel jLabel = null;
      private JTextField txtStudentID = null;
      private JLabel jLabel1 = null;
      private JTextField txtName = null;

      protected void btnAddClicked() {
      String id = txtStudentID.getText();
      String name = txtName.getText();

      Student s = new Student(id, name);

      System.out.println(s);
      }

      /**
      * This method initializes jPanel
      *
      * @return javax.swing.JPanel
      */
      private JPanel getJPanel() {
      if (jPanel == null) {
      jPanel = new JPanel();
      jPanel.setLayout(new GridBagLayout());
      jPanel.add(getBtnAdd(), new GridBagConstraints());
      }
      return jPanel;
      }

      /**
      * This method initializes btnAdd
      *
      * @return javax.swing.JButton
      */
      private JButton getBtnAdd() {
      if (btnAdd == null) {
      btnAdd = new JButton();
      btnAdd.setText("Add");
      btnAdd.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent e) {
      btnAddClicked();
      }
      });
      }
      return btnAdd;
      }

      /**
      * This method initializes jPanel1
      *
      * @return javax.swing.JPanel
      */
      private JPanel getJPanel1() {
      if (jPanel1 == null) {
      GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
      gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
      gridBagConstraints3.gridy = 1;
      gridBagConstraints3.weightx = 1.0;
      gridBagConstraints3.gridx = 1;
      GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
      gridBagConstraints2.gridx = 0;
      gridBagConstraints2.anchor = GridBagConstraints.EAST;
      gridBagConstraints2.insets = new Insets(0, 0, 0, 5);
      gridBagConstraints2.gridy = 1;
      jLabel1 = new JLabel();
      jLabel1.setText("Student:");
      GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
      gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
      gridBagConstraints1.gridy = 0;
      gridBagConstraints1.weightx = 1.0;
      gridBagConstraints1.gridx = 1;
      GridBagConstraints gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.anchor = GridBagConstraints.EAST;
      gridBagConstraints.insets = new Insets(0, 0, 0, 5);
      gridBagConstraints.gridy = 0;
      jLabel = new JLabel();
      jLabel.setText("ID:");
      jPanel1 = new JPanel();
      jPanel1.setLayout(new GridBagLayout());
      jPanel1.add(jLabel, gridBagConstraints);
      jPanel1.add(getTxtStudentID(), gridBagConstraints1);
      jPanel1.add(jLabel1, gridBagConstraints2);
      jPanel1.add(getTxtName(), gridBagConstraints3);
      }
      return jPanel1;
      }

      /**
      * This method initializes txtStudentID
      *
      * @return javax.swing.JTextField
      */
      private JTextField getTxtStudentID() {
      if (txtStudentID == null) {
      txtStudentID = new JTextField();
      txtStudentID.setPreferredSize(new Dimension(200, 26));
      }
      return txtStudentID;
      }

      /**
      * This method initializes txtName
      *
      * @return javax.swing.JTextField
      */
      private JTextField getTxtName() {
      if (txtName == null) {
      txtName = new JTextField();
      txtName.setPreferredSize(new Dimension(200, 26));
      }
      return txtName;
      }

      /**
      * @param args
      */
      public static void main(String[] args) {
      // TODO Auto-generated method stub
      SwingUtilities.invokeLater(new Runnable() {
      public void run() {
      StudentFrame thisClass = new StudentFrame();
      thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_ CLOSE);
      thisClass.setVisible(true);
      }
      });
      }

      /**
      * This is the default constructor
      */
      public StudentFrame() {
      super();
      initialize();
      pack();
      }

      /**
      * This method initializes this
      *
      * @return void
      */
      private void initialize() {
      this.setSize(300, 200);
      this.setContentPane(getJContentPane());
      this.setTitle("Add New Student");
      }

      /**
      * This method initializes jContentPane
      *
      * @return javax.swing.JPanel
      */
      private JPanel getJContentPane() {
      if (jContentPane == null) {
      jContentPane = new JPanel();
      jContentPane.setLayout(new BorderLayout());
      jContentPane.add(getJPanel(), BorderLayout.SOUTH);
      jContentPane.add(getJPanel1(), BorderLayout.CENTER);
      }
      return jContentPane;
      }

      }
      وَمَا كَانَ رَبُّكَ نَسِيًّا

      تعليق


      • #4
        وهذا الـ gui تبع الستودنت

        package gui;

        import javax.swing.SwingUtilities;
        import java.awt.BorderLayout;
        import javax.swing.JPanel;
        import javax.swing.JFrame;
        import java.awt.GridBagLayout;
        import javax.swing.JButton;
        import java.awt.GridBagConstraints;
        import javax.swing.JLabel;
        import javax.swing.JTextField;

        import domain.Student;
        import java.awt.Insets;
        import java.awt.Dimension;

        public class StudentFrame extends JFrame {

        private static final long serialVersionUID = 1L;
        private JPanel jContentPane = null;
        private JPanel jPanel = null;
        private JButton btnAdd = null;
        private JPanel jPanel1 = null;
        private JLabel jLabel = null;
        private JTextField txtStudentID = null;
        private JLabel jLabel1 = null;
        private JTextField txtName = null;

        protected void btnAddClicked() {
        String id = txtStudentID.getText();
        String name = txtName.getText();

        Student s = new Student(id, name);

        System.out.println(s);
        }

        /**
        * This method initializes jPanel
        *
        * @return javax.swing.JPanel
        */
        private JPanel getJPanel() {
        if (jPanel == null) {
        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout());
        jPanel.add(getBtnAdd(), new GridBagConstraints());
        }
        return jPanel;
        }

        /**
        * This method initializes btnAdd
        *
        * @return javax.swing.JButton
        */
        private JButton getBtnAdd() {
        if (btnAdd == null) {
        btnAdd = new JButton();
        btnAdd.setText("Add");
        btnAdd.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
        btnAddClicked();
        }
        });
        }
        return btnAdd;
        }

        /**
        * This method initializes jPanel1
        *
        * @return javax.swing.JPanel
        */
        private JPanel getJPanel1() {
        if (jPanel1 == null) {
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints3.gridy = 1;
        gridBagConstraints3.weightx = 1.0;
        gridBagConstraints3.gridx = 1;
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.anchor = GridBagConstraints.EAST;
        gridBagConstraints2.insets = new Insets(0, 0, 0, 5);
        gridBagConstraints2.gridy = 1;
        jLabel1 = new JLabel();
        jLabel1.setText("Student:");
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.weightx = 1.0;
        gridBagConstraints1.gridx = 1;
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.insets = new Insets(0, 0, 0, 5);
        gridBagConstraints.gridy = 0;
        jLabel = new JLabel();
        jLabel.setText("ID:");
        jPanel1 = new JPanel();
        jPanel1.setLayout(new GridBagLayout());
        jPanel1.add(jLabel, gridBagConstraints);
        jPanel1.add(getTxtStudentID(), gridBagConstraints1);
        jPanel1.add(jLabel1, gridBagConstraints2);
        jPanel1.add(getTxtName(), gridBagConstraints3);
        }
        return jPanel1;
        }

        /**
        * This method initializes txtStudentID
        *
        * @return javax.swing.JTextField
        */
        private JTextField getTxtStudentID() {
        if (txtStudentID == null) {
        txtStudentID = new JTextField();
        txtStudentID.setPreferredSize(new Dimension(200, 26));
        }
        return txtStudentID;
        }

        /**
        * This method initializes txtName
        *
        * @return javax.swing.JTextField
        */
        private JTextField getTxtName() {
        if (txtName == null) {
        txtName = new JTextField();
        txtName.setPreferredSize(new Dimension(200, 26));
        }
        return txtName;
        }

        /**
        * @param args
        */
        public static void main(String[] args) {
        // TODO Auto-generated method stub
        SwingUtilities.invokeLater(new Runnable() {
        public void run() {
        StudentFrame thisClass = new StudentFrame();
        thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_ CLOSE);
        thisClass.setVisible(true);
        }
        });
        }

        /**
        * This is the default constructor
        */
        public StudentFrame() {
        super();
        initialize();
        pack();
        }

        /**
        * This method initializes this
        *
        * @return void
        */
        private void initialize() {
        this.setSize(300, 200);
        this.setContentPane(getJContentPane());
        this.setTitle("Add New Student");
        }

        /**
        * This method initializes jContentPane
        *
        * @return javax.swing.JPanel
        */
        private JPanel getJContentPane() {
        if (jContentPane == null) {
        jContentPane = new JPanel();
        jContentPane.setLayout(new BorderLayout());
        jContentPane.add(getJPanel(), BorderLayout.SOUTH);
        jContentPane.add(getJPanel1(), BorderLayout.CENTER);
        }
        return jContentPane;
        }

        }




        وَمَا كَانَ رَبُّكَ نَسِيًّا

        تعليق


        • #5
          يسلموا اخت جمانة على المساعدة بسير اراجعهم تشكراااااااااااات..

          تعليق

          يعمل...
          X