jastig's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
8 (0.02 per day)
Joined:
15-March 12
Profile Views:
202
Last Active:
User is offline Aug 28 2012 09:24 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   jastig has not set their status

Posts I've Made

  1. In Topic: how to send joptionpane mesage to clients from server?

    Posted 26 Mar 2012

    thanks for your reply...it was helpful.
  2. In Topic: how to send joptionpane mesage to clients from server?

    Posted 19 Mar 2012

    hi... actually i tried it and know i am sending server and client programs...there is no error but iam not getting optionpane on client side..iam getting it on server side even after i made it a comment!would you please tell me what is wrong?thank you...server
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package org.me.myimageapp;
    
    
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.net.*;
    import java.lang.*;
    import java.lang.String;
    import java.io.*;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    
    public class server1{
    
    
    JButton button;
    public static final int PORT = 1028;
      Socket sock = null; 
        
    public static void main( String args[])throws IOException
    {
     ShowMessageDialog md = new ShowMessageDialog();
    
     ServerSocket sersock = null;
     Socket sock = null;
     System.out.println(" Wait !! ");
    
      sersock =  new ServerSocket(PORT);
                    
      System.out.println("Server Started  :"+sersock);
      sock = sersock.accept();
       System.out.println("Client Connected  :"+ sock);
       DataInputStream ins = new DataInputStream(sock.getInputStream());
       PrintStream ios = new  PrintStream(sock.getOutputStream());
       ios.println("hai client...");
    }
      
    public server1()
    {
      JFrame frame = new JFrame("***HRC***");
      button = new JButton("Start Betting");
      button.addActionListener(new MyAction());
      JPanel panel = new JPanel();
      panel.add(button);
      button = new JButton("Stop Betting");
      button.setActionCommand("Exit"); 
      button.addActionListener(new MyAction());
      panel.add(button);
      frame.add(panel);
      frame.setSize(400, 400);
      frame.setVisible(true);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      //return "string";
    // button.setActionCommand("Exit"); 
     //button.addActionListener(new MyAction()); 
      }
    
     class MyAction implements ActionListener 
     {
                
      public  void actionPerformed(ActionEvent ae){
      String str = ae.getActionCommand();
               
      if(str.equals("Start Betting")){
                    PrintStream ios = null;
                    try {
                        ios = new  PrintStream(sock.getOutputStream());
                        ios.println("Start Betting"); 
                                    
                                       
                     
                    } catch (IOException ex) {
                        Logger.getLogger(server1.class.getName()).log(Level.SEVERE, null, ex);
                    } finally {
                        ios.close();
                    }
                                    
    } 
      else if (str.equals("Exit")){
          PrintStream ios = null;
                    try {
                        ios = new  PrintStream(sock.getOutputStream());
                        ios.println("Stop Betting"); 
                             
                                     
                    
                    } catch (IOException ex) {
                       Logger.getLogger(server1.class.getName()).log(Level.SEVERE, null, ex);
                   // } finally {
                    //    ios.close();
                   // }
    
    System.exit(0); 
      }  
      }
       }  
     }
    }
    
    
      
          
     
     
    



    client
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package org.me.myimageapp;
    
    
     
    import java.lang.*;
    import java.io.*;
    import java.net.*;
    import java.net.InetAddress;
    import javax.swing.JOptionPane;
    
    
    class client1
    {
     public static void main(String args[])
     {
     Socket sock=null;
     DataInputStream dis=null;
     PrintStream ps=null;
     System.out.println(" Trying to connect");
                                       
     try 
     {
     
       String localhost="192.168.40.78";
      sock= new Socket(localhost,1028);
      ps= new PrintStream(sock.getOutputStream());
    // System.out.println(ps.writeLine());
      DataInputStream is = new DataInputStream(sock.getInputStream());
        System.out.println(is.readLine());
    
    
    
    DataInputStream s = new DataInputStream(sock.getInputStream());
        String str = s.readLine();
    
               
      if(str.equals("Start Betting")){
      JOptionPane.showMessageDialog(null, "Betting Has started", "HRC", 1);                 
    }
      else if(str.equals("Stop Betting")){
      JOptionPane.showMessageDialog(null, "Betting has stopped", "HRC", 1);
    System.exit(0); 
      }  
      
    
     
      }
      catch(IOException ie)
      {
       System.out.println(" Close Error   :" +    ie.getMessage());
      }               
      
                            
    } 
    }   
    
    
  3. In Topic: how to send joptionpane mesage to clients from server?

    Posted 19 Mar 2012

    View Postjastig, on 18 March 2012 - 10:59 PM, said:

    View Postpbl, on 16 March 2012 - 07:21 AM, said:

    You cannot just sent a JOptionPane in the wire
    You will have to establish a protocol between your Client and the Server
    When the Client receives a frame of a certain type it means: fire a JOptionPane with these options

    Happy coding

    hi,thanks for your reply...can you please send me an example for this?thanks...in advance.


    hi...actually i wrote this server program and iam getting error void type not allowed near joptionpane in if statement...can you please tell me what to write there or how to solve it...
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package org.me.myimageapp;
    
    /**
     *
     * @author cmc
     */
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.net.*;
    import java.lang.*;
    import java.lang.String;
    import java.io.*;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    //import J_OPTION_PANE;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    
    public class server1{
    
    //port number should be more than 1024
    JButton button;
    public static final int PORT = 1026;
     Socket sock = null;        
    public static void main( String args[])throws IOException
    {
     ShowMessageDialog md = new ShowMessageDialog();
     ServerSocket sersock = null;
     Socket sock = null;
     System.out.println(" Wait !! ");
    
     try
     {
      //  Initialising the ServerSocket
      sersock =  new ServerSocket(PORT);
                    
      // Gives the Server Details Machine name,   Port number
    
      System.out.println("Server Started  :"+sersock);
      sock = sersock.accept();
       System.out.println("Client Connected  :"+ sock);
    
       // Receive message from client i.e Request    from client
    
       DataInputStream ins = new DataInputStream(sock.getInputStream());
       // Send message to the client i.e Response
    
       PrintStream ios = new  PrintStream(sock.getOutputStream());
       ios.println("Hello from server");
       // ios.close();
    //sock.close();
     }
    catch(IOException e)
    	{
        System.out.println("Couldn't start "  ) ;    
       
        }               
     } 
      
                   
      
    public void ShowMessageDialog()
    {
      JFrame frame = new JFrame("***HRC***");
      button = new JButton("Start Betting");
      button.addActionListener(new MyAction());
      JPanel panel = new JPanel();
      panel.add(button);
      button = new JButton("Stop Betting");
      button.setActionCommand("Exit"); 
      button.addActionListener(new MyAction());
      panel.add(button);
      frame.add(panel);
      frame.setSize(400, 400);
      frame.setVisible(true);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //  return "str";
    // button.setActionCommand("Exit"); 
     //button.addActionListener(new MyAction()); 
      }
    
     class MyAction implements ActionListener 
     {
                   
      public  void actionPerformed(ActionEvent ae){
      String str = ae.getActionCommand();
               
      if(str.equals("Start Betting")){
         
                    try {
                    PrintStream  ios = new  PrintStream(sock.getOutputStream());
                      
           ios.println(JOptionPane.showMessageDialog(null, "Betting Has Been Started", "HRC", 1));
                                      
    } catch (IOException ex) {
                        Logger.getLogger(server1.class.getName()).log(Level.SEVERE, null, ex);
                    }}
      else if (str.equals("Exit")){
      JOptionPane.showMessageDialog(null, "Betting Has Been Stopped.", "HRC", 1);
    System.exit(0); 
      }  
      }
     }
     // System.out.println" Connection from :  " );
      }
          
     
     
    
  4. In Topic: how to send joptionpane mesage to clients from server?

    Posted 18 Mar 2012

    View Postpbl, on 16 March 2012 - 07:21 AM, said:

    You cannot just sent a JOptionPane in the wire
    You will have to establish a protocol between your Client and the Server
    When the Client receives a frame of a certain type it means: fire a JOptionPane with these options

    Happy coding

    hi,thanks for your reply...can you please send me an example for this?thanks...in advance.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

Comments

jastig has no profile comments yet. Why not say hello?