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

تحويل من جافا نصي الى جرافيكال

مغلق
بدأه سيف المعاني في 24 أكتوبر 2007 · 5 رد · 825 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

اخواني اخواتي الاعزاء

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

SWING

AWT

ساعدوني تكفون يالنشاما

import java.io.*;
import java.net.*;

class Client1
{
		// main program for client for file transfer, gets data from host and sends it to server
		public static void main (String args[]) throws IOException
		{
				// get remoteIPaddress name either default local host or passed by command line parameter
				InetAddress remoteIPaddress = InetAddress.getByName("localhost");
				if (args.length > 0)
						remoteIPaddress = InetAddress.getByName(args[0]);   // get server host name
				System.out.println("\nClient: file transfer program using unrestricted simplex data link protcol");
				System.out.println("Local IP address " + InetAddress.getLocalHost().toString() +
														" Remote IP address " + remoteIPaddress.toString()  );
				FromHost fromHost = new FromHost();		// open a file to read from

				// open physical layer to send to remoteIPaddress on remotePort, receive on receivePort
				int remotePort  = 10000;												// port on server to send datagrams to
				int receivePort = 10001;												// local port to receive datagrams on

				PhysicalLayer phLayer = new PhysicalLayer(remoteIPaddress, remotePort, receivePort);
				PhysicalFrame Sframe  = new PhysicalFrame();	// holds frame to send
				PhysicalFrame Rframe  = new PhysicalFrame();	// holds frame to receive
				int event;										// event indicator

				// read HostFrames from from host until false (end of file), send data

				System.out.println("sending file - S indicates a frame transmitted");
				while (fromHost.get(Sframe.info))					   // loop reading frames from host until end of file
				{
						Sframe.kind =  PhysicalFrame.FRAME_DATA;		// set up data frame
						phLayer.sendFrame(Sframe);					  // send the frame
						System.out.println('S');						// display an 'S' every frame sent
				}
				phLayer.terminate();							// finished!
				System.out.println("Client terminating");
				System.exit(0);
		}
}
#2

ماذا تقصد بـ "التحويل من نص الى جرافيك " ؟؟

منقطع من حين لاخر

#3

يا اخي العزيز اقصد تحويل هذا البرنامج باستخدام SWING و AWT

يعني عند تنفيذه تظهر لوحة عليها ازارير ويتم تشغيل البرنامج عن طريق اللوحة والازارير.

#4

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

على العموم بما أن الكود فقط يقوم بالطباعه فقط ، فاستخدم مثلا

JOptionPane.showMessageDialog(null,"You Message","title of Dialog",JOptionPane.INFORMATION_MESSAGE);

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

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

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

#5

واستبدل الجملة التالية بجملة ادخال من الـ JOptionPane

 if (args.length > 0)
						remoteIPaddress = InetAddress.getByName(args[0]);   // get server host name

بـ

remoteIPaddress=InetAddress.getByName( JoptionPane.showInputDialog(null,"Enter Remote 
Host"));

كتبت الكود من دون مترجم تاكد منه !!

منقطع من حين لاخر

#6

اولا اشكركم جزيل الشكر على الردود والمساعدة

ثانيا كتبت الكود بالشكل التالي ولم يعمل معي :

import java.io.*;
import java.net.*;
import javax.swing.*;

class Client_1
{
		// main program for client for file transfer, gets data from host and sends it to server
		public static void main (String args[]) throws IOException
		{
				// get remoteIPaddress name either default local host or passed by command line parameter
				InetAddress remoteIPaddress = InetAddress.getByName("localhost");
				if (args.length > 0)
						remoteIPaddress=InetAddress.getByName( JOptionPane.showInputDialog(null,"Enter Remote Host"));


						remoteIPaddress = InetAddress.getByName(args[0]);   // get server host name


				JOptionPane.showMessageDialog( null,"\nClient: file transfer program using unrestricted simplex data link protcol",
												"unrestricted simplex data link protcol",JOptionPane.INFORMATION_MESSAGE );




				JOptionPane.showMessageDialog( null,"Local IP address" + InetAddress.getLocalHost().toString() +
														" Remote IP address " + remoteIPaddress.toString() ,
														"Local IP address",JOptionPane.INFORMATION_MESSAGE );

				FromHost fromHost = new FromHost();		// open a file to read from

				// open physical layer to send to remoteIPaddress on remotePort, receive on receivePort
				int remotePort  = 10000;												// port on server to send datagrams to
				int receivePort = 10001;												// local port to receive datagrams on

				PhysicalLayer phLayer = new PhysicalLayer(remoteIPaddress, remotePort, receivePort);
				PhysicalFrame Sframe  = new PhysicalFrame();	// holds frame to send
				PhysicalFrame Rframe  = new PhysicalFrame();	// holds frame to receive
				int event;										// event indicator

				// read HostFrames from from host until false (end of file), send data


				JOptionPane.showMessageDialog(null,"sending file - S indicates a frame transmitted","S Sending a Frame",JOptionPane.INFORMATION_MESSAGE);

				while (fromHost.get(Sframe.info))					   // loop reading frames from host until end of file
				{
						Sframe.kind =  PhysicalFrame.FRAME_DATA;		// set up data frame
						phLayer.sendFrame(Sframe);					  // send the frame					 
						JOptionPane.showMessageDialog(null,'S',"display an 'S' every frame sent",JOptionPane.INFORMATION_MESSAGE); // display an 'S' every frame sent
				}
				phLayer.terminate();							// finished!
				JOptionPane.showMessageDialog(null,"Client terminating","Warning",JOptionPane.INFORMATION_MESSAGE);
				System.exit(0);
		}
}

ما احل يا اخوان!!

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

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