Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Dynamically net send a messages to a remote PC. Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Dynamically net send a message 04-Aug-04
Category
Communication
Language
JBuilder All Versions
Views
469
User Rating
5
# Votes
1
Replies
0
Publisher:
Darley, F. Joe
Reference URL:
			
1 2 package samplecode; 3 4 import java.awt.*; 5 import java.awt.event.*; 6 import javax.swing.*; 7 8 /** 9 * <p>Title: Net Send </p> 10 * <p>Description: This program shows how to net send a message to a 11 * remote PC. It is useful to if your running a application on a 12 * remote PC and you need the application to send you information 13 * on its status </p> 14 * <p>Company: Developer's super Page.com</p> 15 */ 16 17 18 public class SampleFrame extends JFrame { 19 JPanel contentPane; 20 BorderLayout borderLayout1 = new BorderLayout(); 21 JPanel jpnlMain = new JPanel(); 22 JButton btnExecute = new JButton(); 23 JTextField txtPC = new JTextField(); 24 JTextArea txtMessage = new JTextArea(); 25 JLabel jLabel1 = new JLabel(); 26 JLabel jLabel2 = new JLabel(); 27 28 //Construct the frame 29 public SampleFrame() { 30 enableEvents(AWTEvent.WINDOW_EVENT_MASK); 31 try { 32 jbInit(); 33 } 34 catch(Exception e) { 35 e.printStackTrace(); 36 } 37 } 38 39 //Component initialization 40 private void jbInit() throws Exception { 41 contentPane = (JPanel) this.getContentPane(); 42 contentPane.setLayout(borderLayout1); 43 this.setSize(new Dimension(400, 300)); 44 this.setTitle("Net Send Application"); 45 jpnlMain.setLayout(null); 46 contentPane.setMinimumSize(new Dimension(300, 300)); 47 contentPane.setPreferredSize(new Dimension(300, 256)); 48 jpnlMain.setDebugGraphicsOptions(0); 49 jpnlMain.setMinimumSize(new Dimension(400, 256)); 50 jpnlMain.setPreferredSize(new Dimension(400, 256)); 51 btnExecute.setBounds(new Rectangle(135, 109, 103, 25)); 52 btnExecute.setText("SendMessage"); 53 btnExecute.addActionListener(new SampleFrame_btnExecute_actionAdapter(this)); 54 txtPC.setText("Home");//Name of the PC to send the message to 55 txtPC.setBounds(new Rectangle(109, 28, 99, 21)); 56 txtMessage.setBorder(BorderFactory.createLineBorder(Color.black)); 57 txtMessage.setToolTipText(""); 58 txtMessage.setText("Everything is Okay"); //The Message to give to the PC 59 txtMessage.setBounds(new Rectangle(77, 66, 243, 17)); 60 jLabel1.setText("Remote PC Name:"); 61 jLabel1.setBounds(new Rectangle(12, 27, 88, 16)); 62 jLabel2.setText("Message :"); 63 jLabel2.setBounds(new Rectangle(11, 63, 68, 18)); 64 contentPane.add(jpnlMain, BorderLayout.CENTER); 65 jpnlMain.add(txtPC, null); 66 jpnlMain.add(txtMessage, null); 67 jpnlMain.add(jLabel1, null); 68 jpnlMain.add(jLabel2, null); 69 jpnlMain.add(btnExecute, null); 70 } 71 72 //Overridden so we can exit when window is closed 73 protected void processWindowEvent(WindowEvent e) { 74 super.processWindowEvent(e); 75 if (e.getID() == WindowEvent.WINDOW_CLOSING) { 76 System.exit(0); 77 } 78 } 79 80 void btnExecute_actionPerformed(ActionEvent e) { 81 // This function net sends a message to a remote PC 82 try 83 { 84 //Sends a message to a PC 85 String sMessage ="Net Send "+txtPC.getText() +" "+txtMessage.getText(); 86 Runtime.getRuntime().exec(sMessage); 87 } 88 catch(Exception ioe) 89 { 90 //Display Error Message 91 JOptionPane Pane = new JOptionPane(); 92 Pane.showMessageDialog(null, ioe.toString(), 93 "Error", 94 JOptionPane.ERROR_MESSAGE); 95 } 96 97 } 98 } 99 100 class SampleFrame_btnExecute_actionAdapter implements java.awt.event.ActionListener 101 { 102 SampleFrame adaptee; 103 104 SampleFrame_btnExecute_actionAdapter(SampleFrame adaptee) { 105 this.adaptee = adaptee; 106 } 107 public void actionPerformed(ActionEvent e) { 108 adaptee.btnExecute_actionPerformed(e); 109 } 110 }
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC