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

[تنبيه - عنوان غير مناسب : ]ممكن مساعدة

بدأه ryoko في 21 نوفمبر 2008 · 5 رد · 554 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بســم الله الـرحمــن الرحيــم

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

ok will the question is that we have to write a program that has two buttons Start and stop

and a text area and a text field the text field is where we have to write a file name into the text field and look for it if the file does not exist an IOexception is thrown and has to be dealt with by displaying an error message and asking for another file name, if the file does exist the content of the file will be loaded into the text area. when the user push the start button the text will scroll along the box until the user press the stop button. i will need to use at least two threads, one to cope with listening for events (buttons being pressed) and one to display the text.

  1.  
  2.  
  3. import java.io.*;
  4. import java.awt.event.*;
  5. import javax.swing.*;
  6. import java.awt.*;
  7. public class Layout{
  8. private JFrame frame;
  9. private JTextField fileName;
  10. private JTextArea filename;
  11. private JButton button1;
  12. private JButton button2;
  13. String directory;
  14. public Layout(String filename) {
  15. this(NULL, filename);
  16. }
  17. public Layout(){
  18.  
  19. makeFrame();
  20.  
  21. }
  22.  
  23. public Layout(String directory, String filename){
  24. super();
  25.  
  26.  
  27. }
  28.  
  29. private void makeFrame(){
  30. frame = new JFrame("Assignment 1");
  31. fileName = new JTextField(20);
  32. filename = new JTextArea("", 24, 80);
  33. JScrollPane scrollingResult = new JScrollPane(filename);
  34. Container contentPane = frame.getContentPane();
  35. JButton button1 = new JButton("Start");
  36. button1.setActionCommand("Start");
  37. button1.addActionListener(start);
  38. JButton button2 = new JButton("Stop");
  39. button2.setActionCommand("Stop");
  40. button2.addActionListener(stop);
  41. contentPane.setLayout(new FlowLayout());
  42. contentPane.ADD(button1);
  43. contentPane.ADD(button2);
  44. contentPane.ADD(fileName);
  45. contentPane.ADD(filename);
  46. filename.setEditable(false);
  47. frame.setVisible(true);
  48. frame.setSize(300,300);
  49.  
  50. }
  51. public static void main(String[] args){
  52. Layout layout = new Layout();
  53.  
  54. }
  55. ActionListener start = new ActionListener() {
  56. public void actionPerformed(ActionEvent e) {
  57.  
  58. }
  59. };
  60. ActionListener stop = new ActionListener() {
  61. public void actionPerformed(ActionEvent e) {
  62.  
  63. }
  64. };
  65.  
  66. }
  67.  
  68.  
  69. ارجو المساعدة باسرع وقت ممكن لاني جربت كثير لي اسبوع وانا اجرب فيه
  70.  
  71.  
  72.  

uaekeys27.jpg
#2

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

هل بالامكان توضيح ماذا يحصل عند الضغط على start و stop ؟

بالتوفيق ،

http://informatic-ar.com منصة تعليمية عربية في علوم الحاسب والبرمجة

https://moalfat.com  للكتب الالكترونية والكورسات التعليمية

Everything we see now is just an engineering solution based on old science

#3

عند الضغط على ابدا يبدا البرنامج بال scroll through the text that is desplayed in textarea

عند الضغط على قف it stopes

uaekeys27.jpg
#4

استخدم اللغة العربية

تحياتي

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

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

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

728x90.png

#5

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

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

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

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

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

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

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

/index.php?showtopic=29343

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

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

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

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

728x90.png

#6

ما معني scroll through the text that is desplayed in textarea ؟ :)

مثلا كان الملف فيه سطر واحد ، وتم قرائته ووضعه في الText ، الأن عند الضغط على start ماذا يحصل :S ؟

بالتوفيق ،

http://informatic-ar.com منصة تعليمية عربية في علوم الحاسب والبرمجة

https://moalfat.com  للكتب الالكترونية والكورسات التعليمية

Everything we see now is just an engineering solution based on old science

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

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

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

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

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