Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: program execution with warnings

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Location
    kottayam, kerala, India
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default program execution with warnings

    can some1 please help with this warning when the program is compiled

    C:\java> javac JVNCclient.java

    Note: JVNCclient.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.

    C:\java> javac JVNCclient.java -Xlint
    JVNCclient.java:38: warning: [deprecation] resize(int,int) in java.awt.Component has been deprecated
    resize(WIDTH,HEIGHT-10);
    ^
    JVNCclient.java:181: warning: [deprecation] show() in java.awt.Window has been deprecated
    f.show();
    ^
    JVNCclient.java:17: warning: [serial] serializable class JVNCclient has no definition of serialVersionUID
    public class JVNCclient extends JFrame implements MouseWheelListener
    ^
    3 warnings
    //the main program is as follows
     
    import java.awt.Color;
    import java.awt.FlowLayout;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import java.awt.*;
    import javax.swing.JPanel;
    import java.awt.event.*;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import java.io.ObjectInputStream;
    import java.io.PrintWriter;
    import javax.swing.JOptionPane;
    import javax.swing.SwingUtilities;
     
     
    public class JVNCclient extends JFrame implements MouseWheelListener
    {
    	private JLabel screen;
    	private ObjectInputStream in;
    	private PrintWriter out;
    	private ScreenThread screenThread;
    	private ImageIcon i;
    	private Socket s;
    	private boolean stopped = false;
     
    	public JVNCclient()
    	{
    		int WIDTH = Toolkit.getDefaultToolkit().getScreenSize().width;
    	    int HEIGHT = Toolkit.getDefaultToolkit().getScreenSize().height;
     
    		setTitle("Remote Desktopcapture");
    		setBackground(Color.white);
    		screen = new JLabel();
    		getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));	
    		getContentPane().add(screen);
     
    		resize(WIDTH,HEIGHT-10);
     
    		addMouseListener(new MyMouseAdapter(this));
    		addMouseMotionListener(new MyMouseMotionAdapter(this));	
    		addKeyListener(new MyKeyAdapter(this));
     
    		addWindowListener(new WindowAdapter()
    		{
     
    			public void windowClosing(WindowEvent we)
    			{
    				stopped = true;
    				screenThread.stopRunning();
    				sendAndUpdate(JVNCconstant.CLOSE,0,0);
    				System.exit(0);  
    			}
     
    		});
     
     
    		String serverName =	JOptionPane.showInputDialog(this, "Enter Server name :", "Server", JOptionPane.INFORMATION_MESSAGE);
     
    		try
    		{
    			s = new Socket(serverName.trim(), 1166);
    			if (s==null)
    			{
    				System.out.println("No I/O");
    				System.exit(0);
    			}
    			else
    			{	
    				in = new ObjectInputStream(s.getInputStream());
    				out = new PrintWriter(s.getOutputStream());
     
    				screenThread = new ScreenThread();
    			}
    		}
     
    		catch (Exception ex)
    		{
    			JOptionPane.showMessageDialog(null,"Server not found on PORT number 1166");
    			System.exit(0);
    		}
     
    	}
     
    	public void updateScreen(final ImageIcon i)
    	{	
    		javax.swing.SwingUtilities.invokeLater(new Runnable()
    		{
    			public void run()
    			{
                    screen.repaint();
    				screen.setIcon(i);
    			}
    		});
    	}
     
     
    	private void sendAndUpdate(int type,int arg1, int arg2)
    	{
    		String s = "" + type + "|" + arg1 + "|" + arg2;
    		out.println(s);
    		out.flush();
    	}
     
     
     
    	class MyMouseAdapter extends MouseAdapter
    	{
    		JVNCclient jvnc;
     
    		public MyMouseAdapter(JVNCclient jvnc)
    		{
    			this.jvnc = jvnc;
    		}
    		public void mousePressed(MouseEvent e)
    		{
    			sendAndUpdate(JVNCconstant.MOUSE_PRESS, e.getX(),e.getY());
    		}
     
    		public void mouseReleased(MouseEvent e)
    		{
    			sendAndUpdate(JVNCconstant.MOUSE_RELEASE,0,0);
    		}
    	}
     
    	class MyMouseMotionAdapter extends MouseMotionAdapter
    	{
    		JVNCclient jvnc;
     
    		public MyMouseMotionAdapter(JVNCclient jvnc)
    		{
    			this.jvnc = jvnc;
    		}
     
    		public void mouseDragged(MouseEvent e)
    		{
    			sendAndUpdate(JVNCconstant.MOUSE_MOVE, e.getX(), e.getY());		
    		}
     
    		public void mouseMoved(MouseEvent e)
    		{
    			sendAndUpdate(JVNCconstant.MOUSE_MOVE,e.getX(), e.getY());
    		}
    	}
     
    	public void mouseWheelMoved(MouseWheelEvent e)
    	{
    		sendAndUpdate(JVNCconstant.MOUSE_WHEEL,e.getScrollAmount(),0);
    	}
     
     
     
    	class MyKeyAdapter extends KeyAdapter
    	{
    		JVNCclient jvnc;
     
    		public MyKeyAdapter(JVNCclient jvnc)
    		{
    			this.jvnc = jvnc;
    		}
     
    		public void keyPressed(KeyEvent ke)
    		{
    			int key; 
     
    			key = ke.getKeyCode();
     
    			if(key==ke.VK_ENTER)
    				sendAndUpdate(JVNCconstant.KEY_PRESS_EVENTS,ke.VK_ENTER,0);
    			else if(key==ke.VK_F1)
    				sendAndUpdate(JVNCconstant.KEY_PRESS_EVENTS,ke.VK_F1,0);
    			else if(key==ke.VK_ESCAPE)
    				sendAndUpdate(JVNCconstant.KEY_PRESS_EVENTS,ke.VK_ESCAPE,0);
    		}	
    	}
     
    	public static void main(String argv[])
    	{
    		JVNCclient f = new JVNCclient();
    		f.setVisible(true);
    		f.show();
    	}
     
    	private class ScreenThread implements Runnable
    	{
    		Thread t;
    		private  boolean keepRunning;
     
    		ScreenThread()
    		{
    			keepRunning = true;
    			t = new Thread(this,"Screen Thread");
    			t.start();
    		}
     
    		public void run()
    		{
    			while (keepRunning)
    			{
    				try
    				{		
    					if(stopped ==false)	
    					{
    					if((i = (ImageIcon)in.readObject())!=null)
    					{
    						updateScreen(i);		
    						Thread.sleep(1000);
    						i=null;
    					}
    					}
    					else
    					{
    						keepRunning = false;
    						in.close();
    					}
    				}
    				catch(InterruptedException e)
    				{
    					System.out.println("Thread Interrupted");
    				}
    				catch(OutOfMemoryError e)
    				{
    					e.toString();
    					JOptionPane.showMessageDialog(null,"JVM can not able to allocate Memory");
    					System.exit(0);
    				}
    				catch (ClassNotFoundException ex)
    				{
    					ex.printStackTrace();
    				}
    				catch (Exception ex)
    				{
    					ex.printStackTrace();
    					JOptionPane.showMessageDialog(null,"Server is stoped");
    					System.exit(0);
    				}
    			}
    		}
     
    		public void stopRunning()
    		{
    			keepRunning = false;
    		}
    	}
     
    }
    any sort of help will be greatly appreciated, thanks...
    Last edited by helloworld922; March 28th, 2010 at 03:56 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: program execution with warnings

    Look at the API for the components that are creating the error (Component and JFrame)
    Namely the methods that create the error. The deprecated methods in the API should refer you to the new methods to use ( for example setSize() instead of resize, and setVisible(true) instead of show(), etc...). The serialVersionUID refers to a specific variable that classes which implement the Serializeable interface should also contain a serialVersionUID variable (see Serializable). Hope this helps
    Last edited by copeg; March 28th, 2010 at 04:01 PM.

Similar Threads

  1. Java EE warnings while parsing wsdl
    By Idy in forum Web Frameworks
    Replies: 0
    Last Post: January 14th, 2010, 04:29 PM
  2. Not Looping? (do - while) bad execution!
    By chronoz13 in forum Loops & Control Statements
    Replies: 1
    Last Post: November 23rd, 2009, 08:51 PM