?
Solved

Updating old depricated code

Posted on 2004-10-14
15
Medium Priority
?
447 Views
Last Modified: 2008-01-09
I'm trying to learn Java by attempting to expand a program to better fit my needs.  The software in question is located here:  http://emedia.engr.wisc.edu/pages/viewstation/remote.html.  I tried contacting the author, but emails bounced back

I decompiled the files using "DJ Java Decompiler" (text files copied and pasted below).  Before editing, I attempted to recompile the files using several java development packages.  My plan is to recompile the original code and get it working from text file to application, then start adjusting arguments and adding new pieces of code.  But I keep getting errors when I compile.  The command line compiler says it "uses or overrides a deprecated API."  Recompiling with the -Xlint argument shows several warnings.  

So, obviously this code is an old version of Java.  But I have no clue how to update it.  Any help?  If I could just get it working as is using something like NetBeans, I can deconstruct the code to add the options I need.

// Source File Name:   PControl.java

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Vector;
import javax.swing.*;
import javax.swing.text.JTextComponent;

public class PControl
    implements ActionListener
{

    public PControl()
    {
        socket = null;
        out = null;
        in = null;
        stop = null;
        pass_valid = false;
        pass_tried = false;
        p = null;
        d = null;
        hostname = null;
        host = null;
        text = null;
        dia = null;
        auto_on = false;
        auto = null;
        status_strings = new Vector(30);
        f = new JFrame("Polycom ViewStation FX Remote Control");
        f.setSize(362, 186);
        f.setResizable(false);
        Container container = f.getContentPane();
        get_password();
        while(!pass_valid) ;
        show_popup();
        f.setJMenuBar(menu_stuff());
        make_interface(container);
        f.setLocation(100, 100);
        f.show();
        f.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent windowevent)
            {
                try
                {
                    socket.close();
                }
                catch(Exception exception)
                {
                    System.out.println("Couldn't close socket");
                    System.exit(0);
                }
            }

        });
    }

    private void show_popup()
    {
        try
        {
            InetAddress inetaddress = InetAddress.getLocalHost();
            out.println("showpopup \"" + inetaddress.getHostName() + " 

Has Connected to Control This ViewStation Remotely.\"");
        }
        catch(Exception exception)
        {
            System.out.println("Exception in show_popup");
        }
    }

    private void get_password()
    {
        d = new JDialog(f, "ViewStation Password Prompt");
        Container container = d.getContentPane();
        container.setLayout(new GridLayout(3, 2));
        p = new JPasswordField(20);
        JButton jbutton = new JButton("OK");
        jbutton.addActionListener(this);
        jbutton.setActionCommand("passok");
        JButton jbutton1 = new JButton("Cancel");
        jbutton1.addActionListener(this);
        jbutton1.setActionCommand("passcancel");
        JLabel jlabel = new JLabel("Admin Pass");
        JLabel jlabel1 = new JLabel("Host Name");
        host = new JTextField(20);
        container.add(jlabel1);
        container.add(host);
        container.add(jlabel);
        container.add(p);
        container.add(jbutton);
        container.add(jbutton1);
        d.setSize(225, 100);
        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize

();
        Rectangle rectangle = d.getBounds();
        d.setLocation((dimension.width - rectangle.width) / 2,

(dimension.height - rectangle.height) / 2);
        d.setResizable(false);
        d.setVisible(true);
    }

    private void connect()
        throws IOException
    {
        try
        {
            socket = new Socket(hostname, 23);
            out = new PrintWriter(socket.getOutputStream(), true);
            in = new BufferedReader(new InputStreamReader

(socket.getInputStream()));
            out.println("stdout off");
        }
        catch(Exception exception)
        {
            JOptionPane.showMessageDialog(f, "Unknown Host, Try Again",

"Bad Host", 0);
            System.exit(0);
        }
    }

    private void exit()
    {
        System.out.println("Exiting...");
        try
        {
            socket.close();
        }
        catch(Exception exception)
        {
            System.out.println("Exception closing socket, forcing

exit...");
            System.exit(0);
        }
        System.exit(0);
    }

    private void validate_password()
    {
        try
        {
            String s = null;
            s = in.readLine();
            System.out.println(s);
            s = in.readLine();
            System.out.println(s);
            s = in.readLine();
            System.out.println(s);
            s = in.readLine();
            System.out.println("passin: " + s);
            System.out.println("pass: " + p.getPassword());
            s = in.readLine();
            System.out.println(s);
            out.println(p.getPassword());
            s = in.readLine();
            System.out.println(s);
            s = in.readLine();
            System.out.println("line: " + s);
            if(s.length() >= 0)
            {
                pass_valid = true;
                System.out.println("Password Accepted");
            } else
            {
                JOptionPane.showMessageDialog(f, "Incorrect Password, Try

Again", "Bad Password", 0);
            }
        }
        catch(Exception exception)
        {
            System.out.println("Exit!");
            System.exit(0);
        }
        d.setVisible(false);
        read_header();
    }

    private void read_header()
    {
        try
        {
            for(int i = 0; i < 17; i++)
                status_strings.add(in.readLine());

        }
        catch(Exception exception)
        {
            System.out.println("Exception in read_header()");
        }
        out.println("camera near move discrete");
    }

    private JMenuBar menu_stuff()
    {
        JMenuBar jmenubar = new JMenuBar();
        JMenu jmenu = new JMenu("File");
        JMenuItem jmenuitem = new JMenuItem("Exit");
        jmenuitem.addActionListener(this);
        jmenuitem.setActionCommand("exit");
        jmenu.add(jmenuitem);
        JMenu jmenu1 = new JMenu("Options");
        auto = new JCheckBoxMenuItem("Automatic Tracking", false);
        auto.addActionListener(this);
        auto.setActionCommand("auto");
        jmenu1.add(auto);
        JMenuItem jmenuitem1 = new JMenuItem("Text Input");
        jmenuitem1.addActionListener(this);
        jmenuitem1.setActionCommand("textin");
        jmenu1.add(jmenuitem1);
        JMenu jmenu2 = new JMenu("Help");
        JMenuItem jmenuitem2 = new JMenuItem("Status");
        jmenuitem2.addActionListener(this);
        jmenuitem2.setActionCommand("status");
        jmenu2.add(jmenuitem2);
        jmenubar.add(jmenu);
        jmenubar.add(jmenu1);
        jmenubar.add(jmenu2);
        return jmenubar;
    }

    private void make_interface(Container container)
    {
        JPanel jpanel = new JPanel(new BorderLayout());
        javax.swing.border.TitledBorder titledborder =

BorderFactory.createTitledBorder("Move Camera");
        jpanel.setBorder(titledborder);
        JButton jbutton = new JButton("Up");
        jbutton.addActionListener(this);
        jbutton.setActionCommand("up");
        jpanel.add(jbutton, "North");
        JButton jbutton1 = new JButton("Down");
        jbutton1.addActionListener(this);
        jbutton1.setActionCommand("down");
        jpanel.add(jbutton1, "South");
        JButton jbutton2 = new JButton("Left");
        jbutton2.addActionListener(this);
        jbutton2.setActionCommand("left");
        jpanel.add(jbutton2, "West");
        JButton jbutton3 = new JButton("Right");
        jbutton3.addActionListener(this);
        jbutton3.setActionCommand("right");
        jpanel.add(jbutton3, "East");
        stop = new JButton("Stop");
        stop.addActionListener(this);
        stop.setActionCommand("stop");
        stop.setEnabled(false);
        jpanel.add(stop, "Center");
        JPanel jpanel1 = new JPanel(new BorderLayout());
        JButton jbutton4 = new JButton("Zoom +");
        jbutton4.addActionListener(this);
        jbutton4.setActionCommand("zoomin");
        jpanel1.add(jbutton4, "North");
        JButton jbutton5 = new JButton("Zoom -");
        jbutton5.addActionListener(this);
        jbutton5.setActionCommand("zoomout");
        jpanel1.add(jbutton5, "South");
        JRadioButton jradiobutton = new JRadioButton("Discrete");
        jradiobutton.setActionCommand("discrete");
        jradiobutton.addActionListener(this);
        jradiobutton.setSelected(true);
        JRadioButton jradiobutton1 = new JRadioButton("Continuous");
        jradiobutton1.setActionCommand("continuous");
        jradiobutton1.addActionListener(this);
        ButtonGroup buttongroup = new ButtonGroup();
        buttongroup.add(jradiobutton);
        buttongroup.add(jradiobutton1);
        jpanel1.add(jradiobutton, "East");
        jpanel1.add(jradiobutton1, "West");
        container.add(jpanel, "West");
        container.add(jpanel1, "East");
    }

    private void toggle_auto()
    {
        try
        {
            out.println("button auto");
            if(auto_on)
            {
                out.println("button auto");
                auto_on = false;
            } else
            {
                auto_on = true;
            }
        }
        catch(Exception exception)
        {
            System.out.println("Exception in toggle_auto()");
        }
    }

    private void move_camera(String s)
    {
        try
        {
            out.println("camera near move " + s);
            in.readLine();
            in.readLine();
            in.readLine();
        }
        catch(Exception exception)
        {
            System.out.println("Exception in move_camera()");
            System.exit(0);
        }
    }

    private void set_continuous()
    {
        stop.setEnabled(true);
        try
        {
            out.println("camera near move continuous");
        }
        catch(Exception exception)
        {
            System.out.println("Exception in set_continuous()");
        }
    }

    private void set_discrete()
    {
        stop.setEnabled(false);
        try
        {
            out.println("camera near move stop");
            out.println("camera near move discrete");
        }
        catch(Exception exception)
        {
            System.out.println("Exception in set_discrete()");
        }
    }

    private void get_text_in()
    {
        dia = new JDialog(f, "Text Input");
        Container container = dia.getContentPane();
        text = new JTextField(20);
        JLabel jlabel = new JLabel("Text Input");
        JButton jbutton = new JButton("OK");
        JButton jbutton1 = new JButton("Cancel");
        jbutton.addActionListener(this);
        jbutton.setActionCommand("textok");
        jbutton1.addActionListener(this);
        jbutton1.setActionCommand("textcancel");
        container.setLayout(new GridLayout(2, 2));
        container.add(jlabel);
        container.add(text);
        container.add(jbutton);
        container.add(jbutton1);
        dia.setSize(170, 80);
        dia.setResizable(false);
        Point point = f.getLocation();
        dia.setLocation(point.x + 20, point.y + 20);
        dia.show();
    }

    private void send_text_in()
    {
        try
        {
            out.println("textinput \"" + text.getText() + "\"");
        }
        catch(Exception exception)
        {
            System.out.println("Exception in send_text_in()");
        }
        dia.setVisible(false);
    }

    private void show_status()
    {
        JDialog jdialog = new JDialog(f, "ViewStation Status");
        Container container = jdialog.getContentPane();
        JTextArea jtextarea = new JTextArea(10, 20);
        jtextarea.setEditable(false);
        jtextarea.setFont(new Font("Monospaced", 0, 12));
        for(int i = 3; i < status_strings.size(); i++)
            jtextarea.append((String)status_strings.get(i) + "\n");

        JScrollPane jscrollpane = new JScrollPane(jtextarea);
        container.add(jscrollpane, "Center");
        jdialog.setSize(400, 200);
        Point point = f.getLocation();
        jdialog.setLocation(point.x + 20, point.y + 20);
        jdialog.show();
    }

    private void call_status()
    {
        JDialog jdialog = new JDialog(f, "Call Status");
        Container container = jdialog.getContentPane();
        JTextArea jtextarea = new JTextArea(10, 20);
        jtextarea.setEditable(false);
        jtextarea.setFont(new Font("Monospaced", 0, 12));
        out.println("display call");
        try
        {
            for(String s = in.readLine(); !s.equals("display call"); s =

in.readLine())
                System.out.println(s);

            String s1 = in.readLine();
            System.out.println(s1);
            for(; !s1.equals(""); s1 = in.readLine())
            {
                System.out.println(s1);
                jtextarea.append(s1 + "\n");
            }

        }
        catch(Exception exception)
        {
            System.out.println("Exception in call_status()");
        }
        JScrollPane jscrollpane = new JScrollPane(jtextarea);
        container.add(jscrollpane, "Center");
        jdialog.setSize(400, 200);
        Point point = f.getLocation();
        jdialog.setLocation(point.x + 20, point.y + 20);
        jdialog.show();
    }

    public void actionPerformed(ActionEvent actionevent)
    {
        if(actionevent.getActionCommand().equals("passok"))
        {
            hostname = host.getText();
            try
            {
                connect();
            }
            catch(Exception exception)
            {
                System.out.println("Caught an exception in connect()");
                System.exit(0);
            }
            validate_password();
            pass_tried = true;
        }
        if(actionevent.getActionCommand().equals("passcancel"))
            System.exit(0);
        if(actionevent.getActionCommand().equals("exit"))
        {
            try
            {
                socket.close();
            }
            catch(IOException ioexception)
            {
                System.out.println("Couldn't close socket");
            }
            System.exit(0);
        }
        if(actionevent.getActionCommand().equals("auto"))
            toggle_auto();
        if(actionevent.getActionCommand().equals("textin"))
            get_text_in();
        if(actionevent.getActionCommand().equals("textok"))
            send_text_in();
        if(actionevent.getActionCommand().equals("textcancel"))
            dia.setVisible(false);
        if(actionevent.getActionCommand().equals("status"))
            show_status();
        if(actionevent.getActionCommand().equals("cstatus"))
            call_status();
        if(actionevent.getActionCommand().equals("continuous"))
            set_continuous();
        if(actionevent.getActionCommand().equals("discrete"))
            set_discrete();
        if(actionevent.getActionCommand().equals("up"))
            move_camera("up");
        if(actionevent.getActionCommand().equals("down"))
            move_camera("down");
        if(actionevent.getActionCommand().equals("right"))
            move_camera("right");
        if(actionevent.getActionCommand().equals("left"))
            move_camera("left");
        if(actionevent.getActionCommand().equals("zoomin"))
            move_camera("zoom+");
        if(actionevent.getActionCommand().equals("zoomout"))
            move_camera("zoom-");
        if(actionevent.getActionCommand().equals("stop"))
            move_camera("stop");
    }

    public static void main(String args[])
    {
        PControl pcontrol = new PControl();
    }

    private JFrame f;
    private Socket socket;
    private PrintWriter out;
    private BufferedReader in;
    private JButton stop;
    private boolean pass_valid;
    private boolean pass_tried;
    private JPasswordField p;
    private JDialog d;
    private String hostname;
    private JTextField host;
    private JTextField text;
    private JDialog dia;
    private boolean auto_on;
    private JCheckBoxMenuItem auto;
    private Vector status_strings;

}





// Source File Name:   PControl.java

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.PrintStream;
import java.net.Socket;

class PControl$1 extends WindowAdapter
{

    public void windowClosing(WindowEvent windowevent)
    {
        try
        {
            PControl.access$000(PControl.this).close();
        }
        catch(Exception exception)
        {
            System.out.println("Couldn't close socket");
            System.exit(0);
        }
    }

    PControl$1()
    {
    }
}
0
Comment
Question by:Heathicus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 3
  • +1
15 Comments
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 12310430
Hi Heathicus,

You don't need to update the deprecated code to get the application up and running.

Cheers!

\tt
0
 
LVL 1

Author Comment

by:Heathicus
ID: 12310701
Then how do I compile it?  I get errors everytime I try.  This is what I get when I try in NetBeans:

C:\...\Main.java:68: illegal start of expression
        private void show_popup() {
C:\...\Main.java:445: illegal start of expression
        private Socket socket;
C:\...\Main.java:446: illegal start of expression
        private PrintWriter out;
C:\...\Main.java:447: illegal start of expression
        private BufferedReader in;
C:\...\Main.java:448: illegal start of expression
        private JButton stop;
C:\...\Main.java:449: illegal start of expression
        private boolean pass_valid;
C:\...\Main.java:450: illegal start of expression
        private boolean pass_tried;
C:\...\Main.java:451: illegal start of expression
        private JPasswordField p;
C:\...\Main.java:452: illegal start of expression
        private JDialog d;
C:\...\Main.java:453: illegal start of expression
        private String hostname;
C:\...\Main.java:454: illegal start of expression
        private JTextField host;
C:\...\Main.java:455: illegal start of expression
        private JTextField text;
C:\...\Main.java:456: illegal start of expression
        private JDialog dia;
C:\...\Main.java:457: illegal start of expression
        private boolean auto_on;
C:\...\Main.java:458: illegal start of expression
        private JCheckBoxMenuItem auto;
C:\...\Main.java:459: illegal start of expression
        private Vector status_strings;
C:\...\Main.java:461: '}' expected
    }
17 errors
BUILD FAILED (total time: 0 seconds)

0
 
LVL 14

Accepted Solution

by:
Tommy Braas earned 400 total points
ID: 12310931
Heathicus,

The errors you are getting are related to the result of the decompilation, not deprecation.

If you want to learn Java I can recommend the following free book available online: http://mindview.net/Books/TIJ/DownloadSites

Trying to fix a poorly decompiled project without much Java knowledge is not conducive to learning the language.

\t
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 8

Expert Comment

by:kiranhk
ID: 12312133
If you are already familiar with the basics of Java and really want to continue on modifying a poorly decompiled code, then you can start looking at the errors one by one at the line number mentioned. Probably there is lot of mismatch of the braces, colon after each line of code........ then u can compile again to see if it gets fixed
0
 
LVL 1

Expert Comment

by:Mindbender
ID: 12333118
Just through looking quickly at the top error, there is what appears to be a syntax error in the lines above 'private void show_popup() {'. It's easy to spot.

Mindbender
0
 
LVL 8

Assisted Solution

by:kiranhk
kiranhk earned 400 total points
ID: 12339090
There is a problem in teh show_popup method,

InetAddress inetaddress = InetAddress.getLocalHost();
            out.println("showpopup \"" + inetaddress.getHostName() + " 

Has Connected to Control This ViewStation Remotely.\"");

modify this code like the following below

InetAddress inetaddress = InetAddress.getLocalHost();
 out.println("showpopup \"" + inetaddress.getHostName() +
" Has Connected to Control This ViewStation Remotely.\"");

Any string should always be enclosed within Quotes "Example String". The Quotes cannot be on a different line and the String on a different line.

Modify like this and compile it again, if u get same problems check out for other lines of code in the same fashion and modify it.

Hope this helps.

Kiran
0
 
LVL 1

Author Comment

by:Heathicus
ID: 12340695
I made the change you suggested, kiranhk.  And I believe I fixed the syntax error you alluded to, Mindbender (is that handle a GI Joe reference?).  Now I'm down to "2" errors.  

C:\...\Main.java:452:  'class' or 'interface' expected
}

That error is repeated twice.

Here's the complete code as it stands now.  Any suggestions would be appreciated:



package pcontrolnew;

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Vector;
import javax.swing.*;
import javax.swing.text.JTextComponent;

public class Main {
   
    public Main() {
        {
            socket = null;
            out = null;
            in = null;
            stop = null;
            pass_valid = false;
            pass_tried = false;
            p = null;
            d = null;
            hostname = null;
            host = null;
            text = null;
            dia = null;
            auto_on = false;
            auto = null;
            status_strings = new Vector(30);
            f = new JFrame("Polycom ViewStation FX Remote Control");
            f.setSize(362, 186);
            f.setResizable(false);
            Container container = f.getContentPane();
            get_password();
            while(!pass_valid) ;
            show_popup();
            f.setJMenuBar(menu_stuff());
            make_interface(container);
            f.setLocation(100, 100);
            f.show();
            f.addWindowListener(new WindowAdapter() {
               
                public void windowClosing(WindowEvent windowevent) {
                    try {
                        socket.close();
                    }
                    catch(Exception exception) {
                        System.out.println("Couldn't close socket");
                        System.exit(0);
                    }
                }
               
            });
        }
    }
        private void show_popup() {
            try {
                InetAddress inetaddress = InetAddress.getLocalHost();
                out.println("showpopup \"" + inetaddress.getHostName() +
                " Has Connected to Control This ViewStation Remotely.\"");
            }
            catch(Exception exception) {
                System.out.println("Exception in show_popup");
            }
        }
       
        private void get_password()
        {
            d = new JDialog(f, "ViewStation Password Prompt");
            Container container = d.getContentPane();
            container.setLayout(new GridLayout(3, 2));
            p = new JPasswordField(20);
            JButton jbutton = new JButton("OK");
            jbutton.addActionListener(this);
            jbutton.setActionCommand("passok");
            JButton jbutton1 = new JButton("Cancel");
            jbutton1.addActionListener(this);
            jbutton1.setActionCommand("passcancel");
            JLabel jlabel = new JLabel("Admin Pass");
            JLabel jlabel1 = new JLabel("Host Name");
            host = new JTextField(20);
            container.add(jlabel1);
            container.add(host);
            container.add(jlabel);
            container.add(p);
            container.add(jbutton);
            container.add(jbutton1);
            d.setSize(225, 100);
            Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
            Rectangle rectangle = d.getBounds();
            d.setLocation((dimension.width - rectangle.width) / 2, (dimension.height - rectangle.height) / 2);
            d.setResizable(false);
            d.setVisible(true);
        }
       
        private void connect()
        throws IOException {
            try {
                socket = new Socket(hostname, 23);
                out = new PrintWriter(socket.getOutputStream(), true);
                in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                out.println("stdout off");
            }
            catch(Exception exception) {
                JOptionPane.showMessageDialog(f, "Unknown Host, Try Again", "Bad Host", 0);
                System.exit(0);
            }
        }
       
        private void exit() {
            System.out.println("Exiting...");
            try {
                socket.close();
            }
            catch(Exception exception) {
                System.out.println("Exception closing socket, forcing exit...");
                System.exit(0);
            }
            System.exit(0);
        }
       
        private void validate_password() {
            try {
                String s = null;
                s = in.readLine();
                System.out.println(s);
                s = in.readLine();
                System.out.println(s);
                s = in.readLine();
                System.out.println(s);
                s = in.readLine();
                System.out.println("passin: " + s);
                System.out.println("pass: " + p.getPassword());
                s = in.readLine();
                System.out.println(s);
                out.println(p.getPassword());
                s = in.readLine();
                System.out.println(s);
                s = in.readLine();
                System.out.println("line: " + s);
                if(s.length() >= 0) {
                    pass_valid = true;
                    System.out.println("Password Accepted");
                } else {
                    JOptionPane.showMessageDialog(f, "Incorrect Password, Try Again", "Bad Password", 0);
                }
            }
            catch(Exception exception) {
                System.out.println("Exit!");
                System.exit(0);
            }
            d.setVisible(false);
            read_header();
        }
       
        private void read_header() {
            try {
                for(int i = 0; i < 17; i++)
                    status_strings.add(in.readLine());
               
            }
            catch(Exception exception) {
                System.out.println("Exception in read_header()");
            }
            out.println("camera near move discrete");
        }
       
        private JMenuBar menu_stuff() {
            JMenuBar jmenubar = new JMenuBar();
            JMenu jmenu = new JMenu("File");
            JMenuItem jmenuitem = new JMenuItem("Exit");
            jmenuitem.addActionListener(this);
            jmenuitem.setActionCommand("exit");
            jmenu.add(jmenuitem);
            JMenu jmenu1 = new JMenu("Options");
            auto = new JCheckBoxMenuItem("Automatic Tracking", false);
            auto.addActionListener(this);
            auto.setActionCommand("auto");
            jmenu1.add(auto);
            JMenuItem jmenuitem1 = new JMenuItem("Text Input");
            jmenuitem1.addActionListener(this);
            jmenuitem1.setActionCommand("textin");
            jmenu1.add(jmenuitem1);
            JMenu jmenu2 = new JMenu("Help");
            JMenuItem jmenuitem2 = new JMenuItem("Status");
            jmenuitem2.addActionListener(this);
            jmenuitem2.setActionCommand("status");
            jmenu2.add(jmenuitem2);
            jmenubar.add(jmenu);
            jmenubar.add(jmenu1);
            jmenubar.add(jmenu2);
            return jmenubar;
        }
       
        private void make_interface(Container container) {
            JPanel jpanel = new JPanel(new BorderLayout());
            javax.swing.border.TitledBorder titledborder = BorderFactory.createTitledBorder("Move Camera");
            jpanel.setBorder(titledborder);
            JButton jbutton = new JButton("Up");
            jbutton.addActionListener(this);
            jbutton.setActionCommand("up");
            jpanel.add(jbutton, "North");
            JButton jbutton1 = new JButton("Down");
            jbutton1.addActionListener(this);
            jbutton1.setActionCommand("down");
            jpanel.add(jbutton1, "South");
            JButton jbutton2 = new JButton("Left");
            jbutton2.addActionListener(this);
            jbutton2.setActionCommand("left");
            jpanel.add(jbutton2, "West");
            JButton jbutton3 = new JButton("Right");
            jbutton3.addActionListener(this);
            jbutton3.setActionCommand("right");
            jpanel.add(jbutton3, "East");
            stop = new JButton("Stop");
            stop.addActionListener(this);
            stop.setActionCommand("stop");
            stop.setEnabled(false);
            jpanel.add(stop, "Center");
            JPanel jpanel1 = new JPanel(new BorderLayout());
            JButton jbutton4 = new JButton("Zoom +");
            jbutton4.addActionListener(this);
            jbutton4.setActionCommand("zoomin");
            jpanel1.add(jbutton4, "North");
            JButton jbutton5 = new JButton("Zoom -");
            jbutton5.addActionListener(this);
            jbutton5.setActionCommand("zoomout");
            jpanel1.add(jbutton5, "South");
            JRadioButton jradiobutton = new JRadioButton("Discrete");
            jradiobutton.setActionCommand("discrete");
            jradiobutton.addActionListener(this);
            jradiobutton.setSelected(true);
            JRadioButton jradiobutton1 = new JRadioButton("Continuous");
            jradiobutton1.setActionCommand("continuous");
            jradiobutton1.addActionListener(this);
            ButtonGroup buttongroup = new ButtonGroup();
            buttongroup.add(jradiobutton);
            buttongroup.add(jradiobutton1);
            jpanel1.add(jradiobutton, "East");
            jpanel1.add(jradiobutton1, "West");
            container.add(jpanel, "West");
            container.add(jpanel1, "East");
        }
       
        private void toggle_auto() {
            try {
                out.println("button auto");
                if(auto_on) {
                    out.println("button auto");
                    auto_on = false;
                } else {
                    auto_on = true;
                }
            }
            catch(Exception exception) {
                System.out.println("Exception in toggle_auto()");
            }
        }
       
        private void move_camera(String s) {
            try {
                out.println("camera near move " + s);
                in.readLine();
                in.readLine();
                in.readLine();
            }
            catch(Exception exception) {
                System.out.println("Exception in move_camera()");
                System.exit(0);
            }
        }
       
        private void set_continuous() {
            stop.setEnabled(true);
            try {
                out.println("camera near move continuous");
            }
            catch(Exception exception) {
                System.out.println("Exception in set_continuous()");
            }
        }
       
        private void set_discrete() {
            stop.setEnabled(false);
            try {
                out.println("camera near move stop");
                out.println("camera near move discrete");
            }
            catch(Exception exception) {
                System.out.println("Exception in set_discrete()");
            }
        }
       
        private void get_text_in() {
            dia = new JDialog(f, "Text Input");
            Container container = dia.getContentPane();
            text = new JTextField(20);
            JLabel jlabel = new JLabel("Text Input");
            JButton jbutton = new JButton("OK");
            JButton jbutton1 = new JButton("Cancel");
            jbutton.addActionListener(this);
            jbutton.setActionCommand("textok");
            jbutton1.addActionListener(this);
            jbutton1.setActionCommand("textcancel");
            container.setLayout(new GridLayout(2, 2));
            container.add(jlabel);
            container.add(text);
            container.add(jbutton);
            container.add(jbutton1);
            dia.setSize(170, 80);
            dia.setResizable(false);
            Point point = f.getLocation();
            dia.setLocation(point.x + 20, point.y + 20);
            dia.show();
        }
       
        private void send_text_in() {
            try {
                out.println("textinput \"" + text.getText() + "\"");
            }
            catch(Exception exception) {
                System.out.println("Exception in send_text_in()");
            }
            dia.setVisible(false);
        }
       
        private void show_status() {
            JDialog jdialog = new JDialog(f, "ViewStation Status");
            Container container = jdialog.getContentPane();
            JTextArea jtextarea = new JTextArea(10, 20);
            jtextarea.setEditable(false);
            jtextarea.setFont(new Font("Monospaced", 0, 12));
            for(int i = 3; i < status_strings.size(); i++)
                jtextarea.append((String)status_strings.get(i) + "\n");
           
            JScrollPane jscrollpane = new JScrollPane(jtextarea);
            container.add(jscrollpane, "Center");
            jdialog.setSize(400, 200);
            Point point = f.getLocation();
            jdialog.setLocation(point.x + 20, point.y + 20);
            jdialog.show();
        }
       
        private void call_status() {
            JDialog jdialog = new JDialog(f, "Call Status");
            Container container = jdialog.getContentPane();
            JTextArea jtextarea = new JTextArea(10, 20);
            jtextarea.setEditable(false);
            jtextarea.setFont(new Font("Monospaced", 0, 12));
            out.println("display call");
            try {
                for(String s = in.readLine(); !s.equals("display call"); s = in.readLine())
                    System.out.println(s);
               
                String s1 = in.readLine();
                System.out.println(s1);
                for(; !s1.equals(""); s1 = in.readLine()) {
                    System.out.println(s1);
                    jtextarea.append(s1 + "\n");
                }
               
            }
            catch(Exception exception) {
                System.out.println("Exception in call_status()");
            }
            JScrollPane jscrollpane = new JScrollPane(jtextarea);
            container.add(jscrollpane, "Center");
            jdialog.setSize(400, 200);
            Point point = f.getLocation();
            jdialog.setLocation(point.x + 20, point.y + 20);
            jdialog.show();
        }
       
        public void actionPerformed(ActionEvent actionevent) {
            if(actionevent.getActionCommand().equals("passok")) {
                hostname = host.getText();
                try {
                    connect();
                }
                catch(Exception exception) {
                    System.out.println("Caught an exception in connect()");
                    System.exit(0);
                }
                validate_password();
                pass_tried = true;
            }
            if(actionevent.getActionCommand().equals("passcancel"))
                System.exit(0);
            if(actionevent.getActionCommand().equals("exit")) {
                try {
                    socket.close();
                }
                catch(IOException ioexception) {
                    System.out.println("Couldn't close socket");
                }
                System.exit(0);
            }
            if(actionevent.getActionCommand().equals("auto"))
                toggle_auto();
            if(actionevent.getActionCommand().equals("textin"))
                get_text_in();
            if(actionevent.getActionCommand().equals("textok"))
                send_text_in();
            if(actionevent.getActionCommand().equals("textcancel"))
                dia.setVisible(false);
            if(actionevent.getActionCommand().equals("status"))
                show_status();
            if(actionevent.getActionCommand().equals("cstatus"))
                call_status();
            if(actionevent.getActionCommand().equals("continuous"))
                set_continuous();
            if(actionevent.getActionCommand().equals("discrete"))
                set_discrete();
            if(actionevent.getActionCommand().equals("up"))
                move_camera("up");
            if(actionevent.getActionCommand().equals("down"))
                move_camera("down");
            if(actionevent.getActionCommand().equals("right"))
                move_camera("right");
            if(actionevent.getActionCommand().equals("left"))
                move_camera("left");
            if(actionevent.getActionCommand().equals("zoomin"))
                move_camera("zoom+");
            if(actionevent.getActionCommand().equals("zoomout"))
                move_camera("zoom-");
            if(actionevent.getActionCommand().equals("stop"))
                move_camera("stop");
        }
       
        public static void main(String args[]) {
            PControl pcontrol = new PControl();
        }
       
        private JFrame f;
        private Socket socket;
        private PrintWriter out;
        private BufferedReader in;
        private JButton stop;
        private boolean pass_valid;
        private boolean pass_tried;
        private JPasswordField p;
        private JDialog d;
        private String hostname;
        private JTextField host;
        private JTextField text;
        private JDialog dia;
        private boolean auto_on;
        private JCheckBoxMenuItem auto;
        private Vector status_strings;
        }
}
0
 
LVL 8

Expert Comment

by:kiranhk
ID: 12341751
ok, just delete the last closing brace and u will be ok

Kiran
0
 
LVL 8

Expert Comment

by:kiranhk
ID: 12341757
i meant the
      private JTextField text;
        private JDialog dia;
        private boolean auto_on;
        private JCheckBoxMenuItem auto;
        private Vector status_strings;
        }
}

instead of the above just have

      private JTextField text;
        private JDialog dia;
        private boolean auto_on;
        private JCheckBoxMenuItem auto;
        private Vector status_strings;
        }
0
 
LVL 1

Author Comment

by:Heathicus
ID: 12341844
I did that.  Now I get the following when trying to compile.

C:\...\Main.java:75: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jbutton.addActionListener(this);
C:\...\Main.java:78: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jbutton1.addActionListener(this);
C:\...\Main.java:173: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jmenuitem.addActionListener(this);
C:\...\Main.java:178: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            auto.addActionListener(this);
C:\...\Main.java:182: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jmenuitem1.addActionListener(this);
C:\...\Main.java:187: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jmenuitem2.addActionListener(this);
C:\...\Main.java:201: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jbutton.addActionListener(this);
C:\...\Main.java:205: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jbutton1.addActionListener(this);
C:\...\Main.java:209: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jbutton2.addActionListener(this);
C:\...\Main.java:213: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jbutton3.addActionListener(this);
C:\...\Main.java:217: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            stop.addActionListener(this);
C:\...\Main.java:223: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jbutton4.addActionListener(this);
C:\...\Main.java:227: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jbutton5.addActionListener(this);
C:\...\Main.java:232: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jradiobutton.addActionListener(this);
C:\...\Main.java:236: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jradiobutton1.addActionListener(this);
C:\...\Main.java:302: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jbutton.addActionListener(this);
C:\...\Main.java:304: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (pcontrolnew.Main)
            jbutton1.addActionListener(this);
C:\...\Main.java:432: cannot find symbol
symbol  : class PControl
location: class pcontrolnew.Main
            PControl pcontrol = new PControl();
C:\...\Main.java:432: cannot find symbol
symbol  : class PControl
location: class pcontrolnew.Main
            PControl pcontrol = new PControl();
Note: C:\...\Main.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\...\Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
19 errors
BUILD FAILED (total time: 0 seconds)
0
 
LVL 1

Author Comment

by:Heathicus
ID: 12341993
Maybe I'm getting closer...   I changed

public class Main
     {

to

public class Main implements ActionListener
     {

Now when I compile, I get the following:

C:\...\Main.java:433: cannot find symbol
symbol  : class PControl
location: class pcontrolnew.Main
            PControl pcontrol = new PControl();
C:\...\Main.java:433: cannot find symbol
symbol  : class PControl
location: class pcontrolnew.Main
            PControl pcontrol = new PControl();
Note: C:\...\Main.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\...\Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
BUILD FAILED (total time: 0 seconds)

Line 433 is the line referred to in the errors.  Below is like 432 through 434

     public static void main(String args[]) {
          PControl pcontrol = new PControl();
     }

0
 
LVL 8

Expert Comment

by:kiranhk
ID: 12342312
where is the PControl class.
You need to have this class compiled first before u compile the Main class
0
 
LVL 1

Assisted Solution

by:Mindbender
Mindbender earned 400 total points
ID: 12344711
No, it's a crappy nickname I chose when I was newer to the web community and I have about 8000 points under it ;) Mostly time accumulated. I have been floating around here for years.

As for your latest problems, I haven't really got time right now to look properly - have you made a new source file or class with the better code in it? Ah, Main is what it is called now?

Main pcontrol = new Main();

Main probably isn't the best name for it.

Mindbender
0
 
LVL 1

Author Comment

by:Heathicus
ID: 12417868
Time to clean this up.  Thanks for all the help guys.  I did get my problems figured out, have learned a lot, am still learning a lot, but still have a lot to learn.  But it's fun and I've made great progress!

I'm increasing the points and spreading them around to everyone who contributed because each of you helped add a missing piece to the puzzle.
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 12418161
=-)
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question