Why doesn't this code run?

I'm just experimenting with the JSR14 generics release, but am having problems. The code below is abstracted from my application. It compiles ok, but gives a runtime error:
import java.util.*;
class A {
     public static void main (String argv[]) {
          ArrayList<Boolean> B = new ArrayList<Boolean>(10);
          Iterator<Boolean> i = B.iterator();     
          boolean b = (i.next()).booleanValue();
The error is:
Exception in thread "main" java.lang.VerifyError: (class: A, method: main signature: ([Ljava/lang/String;)V) Incompatible object argument for function call
If I remove the generics code, and add the required cast, the error disappears. Anyone know what is causing this?
thanks,
Gareth                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

This is definitely a bug in the compiler. The bytecode generated for B.methodC() is:
Codeview "bytecode" for void B.methodC():
#3/Test.java:12 - new class java.util.ArrayList
#4/Test.java:12 - dup
#5/Test.java:12 - bipush (byte)10
#6/Test.java:12 - invokespecial public java.util.ArrayList(int)
#7/Test.java:12 - astore_1 lv_1
#8/Test.java:13 - aload_1 lv_1
#9/Test.java:13 - invokevirtual public java.util.Iterator java.util.AbstractList.iterator()
#10/Test.java:13 - astore_2 lv_2
#11/Test.java:14 - aload_2 lv_2
#12/Test.java:14 - invokeinterface public abstract java.lang.Object java.util.Iterator.next()
#13/Test.java:14 - invokevirtual public final boolean java.lang.Boolean.booleanValue()
#14/Test.java:14 - istore_3 lv_3
#15/Test.java:15 - return
and it's clear that between instruction #12 and instruction #14 a typecast is missing.
I'll add this to my list of known prototype compiler bugs at
http://cag.lcs.mit.edu/~cananian/Projects/GJ/

Similar Messages

  • Why doesn't this code work in my extension? Retrieving generator settings from meta data

    Using the code below in my host.jsx file within my html 5 extension this code doesnt work:
    $._photoshop.setDocumentData('project.isXUI','true');
    alert($._photoshop.getDocumentData('project.isXUI'));
    Here's the error I get:
    Error: The requested property does not exist.
    It works perfectly from ExtendScript but the same lines of code do not work when called via "window.__adobe_cep__.evalScript". What am I missing?
    $._photoshop = {
    setDocumentData: function(key,value)
            try
                var classProperty = charIDToTypeID('Prpr');
                var propNull = charIDToTypeID( 'null' );
                var classNull = charIDToTypeID( 'null' );
                var typeOrdinal = charIDToTypeID('Ordn');
                var enumTarget = charIDToTypeID('Trgt');
                var classDocument = charIDToTypeID('Dcmn');
                var classLayer = charIDToTypeID('Lyr ');
                var propProperty = stringIDToTypeID("property");
                var propGeneratorSettings = stringIDToTypeID("generatorSettings");
                var propProperty = stringIDToTypeID(key); //unique name for the setting
                var keyTo = charIDToTypeID( 'T   ' );
                var actionSet = charIDToTypeID( "setd" );
                //Make a property reference to generator settings for active layer.
                //(use classDocument for the active document)
                //NOTE: putProperty needs to come before putEnumerated
                var theRef = new ActionReference();
                theRef.putProperty(classProperty, propGeneratorSettings );
                theRef.putEnumerated(classDocument, typeOrdinal, enumTarget);
                //Build descriptor for your plugin settings, with 2 example settings, a boolean and a string
                var mySettingsDesc = new ActionDescriptor();
                mySettingsDesc.putString(propProperty,value);
                //Execute the set action, setting the descriptor into the property reference,
                //setting just the plugin's settings (propProperty == strMySettings)
                var setDescriptor = new ActionDescriptor();
                setDescriptor.putReference(propNull,theRef);
                setDescriptor.putObject(keyTo,classNull,mySettingsDesc);
                setDescriptor.putString(propProperty, "au.com.oddgames.xui");
                executeAction( actionSet, setDescriptor, DialogModes.NO );
                return true;
            catch (e)
                var exception = {};
                exception.target = "setDocumentdata";
                exception.message = e.toString();
                return exception;
        getDocumentData: function(key)
            try
                var classProperty = charIDToTypeID('Prpr');
                var propNull = charIDToTypeID( 'null' );
                var classNull = charIDToTypeID( 'null' );
                var typeOrdinal = charIDToTypeID('Ordn');
                var enumTarget = charIDToTypeID('Trgt');
                var classDocument = charIDToTypeID('Dcmn');
                var classLayer = charIDToTypeID('Lyr ');
                var propProperty = stringIDToTypeID("property");
                var propGeneratorSettings = stringIDToTypeID("generatorSettings");
                var propProperty = stringIDToTypeID(key); //unique name for the setting
                var actionGet = charIDToTypeID( "getd" );
                //Make a property reference to generator settings for active layer.
                //(use classDocument for the active document)
                //NOTE: putProperty needs to come before putEnumerated
                var theRef = new ActionReference();
                theRef.putProperty(classProperty, propGeneratorSettings );
                theRef.putEnumerated(classDocument, typeOrdinal, enumTarget);
                //Execute the get action, getting the descriptor for the property reference,
                //getting just the plugin's settings (propProperty == strMySettings)
                var getDescriptor = new ActionDescriptor();
                getDescriptor.putReference(propNull,theRef);
                getDescriptor.putString(propProperty, "au.com.oddgames.xui");
                var actionResult = executeAction( actionGet, getDescriptor, DialogModes.NO );
                //Extract the settings
                var mySettingsDesc = actionResult.getObjectValue(propGeneratorSettings);
                return mySettingsDesc.getString(propProperty);
            catch (e)
                var exception = {};
                exception.target = "getDocumentData";
                exception.message = e.toString();
                return exception

    Ok got it, I have to make sure I pull the descriptor back then save my settings over the top:
    $._photoshop = {
        setDocumentData: function(keys,values)
            try
                var classProperty = charIDToTypeID('Prpr');
                var propNull = charIDToTypeID( 'null' );
                var classNull = charIDToTypeID( 'null' );
                var typeOrdinal = charIDToTypeID('Ordn');
                var enumTarget = charIDToTypeID('Trgt');
                var classDocument = charIDToTypeID('Dcmn');
                var classLayer = charIDToTypeID('Lyr ');
                var propProperty = stringIDToTypeID("property");
                var propGeneratorSettings = stringIDToTypeID("generatorSettings");
                var strMySettings = "xui";
                var keyTo = charIDToTypeID( 'T   ' );
                var actionSet = charIDToTypeID( "setd" );
                var actionGet = charIDToTypeID( "getd" );
                var theRef = new ActionReference();
                theRef.putProperty(classProperty, propGeneratorSettings );
                theRef.putEnumerated(classDocument, typeOrdinal, enumTarget);
                var getDescriptor = new ActionDescriptor();
                getDescriptor.putReference(propNull,theRef);
                getDescriptor.putString(propProperty, strMySettings);
                var actionResult = executeAction( actionGet, getDescriptor, DialogModes.NO );
                var mySettingsDesc = actionResult.getObjectValue(propGeneratorSettings);
                if (keys.indexOf(",") > 0)
                    keys = keys.split(',');
                    values = values.split(',');
                else
                    keys = [keys];
                    values = [values];
                for (var x =0; x < keys.length; x ++)
                    var key = keys[x];
                    var value = values[x];
                    var propMyStringProperty = stringIDToTypeID(key);
                    mySettingsDesc.putString(propMyStringProperty,value);
                var setDescriptor = new ActionDescriptor();
                setDescriptor.putReference(propNull,theRef);
                setDescriptor.putObject(keyTo,classNull,mySettingsDesc);
                setDescriptor.putString(propProperty, strMySettings);
                executeAction( actionSet, setDescriptor, DialogModes.NO );
                return true;
            catch (e)
                var exception = {};
                exception.target = "setDocumentdata";
                exception.message = e.toString();
                return JSON.stringify(exception);
        getDocumentData: function(key)
            try
               var classProperty = charIDToTypeID('Prpr');
                var propNull = charIDToTypeID( 'null' );
                var classNull = charIDToTypeID( 'null' );
                var typeOrdinal = charIDToTypeID('Ordn');
                var enumTarget = charIDToTypeID('Trgt');
                var classDocument = charIDToTypeID('Dcmn');
                var classLayer = charIDToTypeID('Lyr ');
                var propProperty = stringIDToTypeID("property");
                var propGeneratorSettings = stringIDToTypeID("generatorSettings");
                var strMySettings = "xui"; //unique name for your settings/plugin
                var propMyStringProperty = stringIDToTypeID(key); //unique name for the setting
                var actionGet = charIDToTypeID( "getd" );
                var theRef = new ActionReference();
                theRef.putProperty(classProperty, propGeneratorSettings );
                theRef.putEnumerated(classDocument, typeOrdinal, enumTarget);
                var getDescriptor = new ActionDescriptor();
                getDescriptor.putReference(propNull,theRef);
                getDescriptor.putString(propProperty, strMySettings);
                var actionResult = executeAction( actionGet, getDescriptor, DialogModes.NO );
                var mySettingsDesc = actionResult.getObjectValue(propGeneratorSettings);
                return mySettingsDesc.getString(propMyStringProperty);
            catch (e)
                var exception = {};
                exception.target = "getDocumentData";
                exception.message = e.toString();
                return JSON.stringify(exception);

  • Why doesn't this update work?

    Why doesn't this update work? Can't I sum up two select count(*) in such a subquery?
    Thanks
    update sales T
    set T.field2 = ((select count(*)
    from sales t
    where t.field1 = trunc(sysdate)) + (select count((*)
    from sales t2
    where t2.field2 is null));
    I get
    ERROR at line 4:
    ORA-00907: missing right parenthesis
    with the * under the +
    In other words I want to run
    update sales set field = ((select count(*) ..... ) + (select count(*) ..... ))
    Edited by: Mark1970 on 26-mar-2010 1.37
    Edited by: Mark1970 on 26-mar-2010 1.38

    My problem is to undestand why I got a syntax error about parenthesis.Because you cannot perform arithmatic operation with a value coming from a subquery in a SET clause of UPDATE
    SQL> update emp
      2  set sal=(select 1 from dual)+1;
    set sal=(select 1 from dual)+1
    ERROR at line 2:
    ORA-00933: SQL command not properly ended
    SQL> select sal from emp
      2  where deptno=(select 10 from dual)+10;
           SAL
           800
          2975
          3000
          1100
          3000
    SQL>  select deptno,sal from emp
      2   where deptno=(select 10 from dual)+10;
        DEPTNO        SAL
            20        800
            20       2975
            20       3000
            20       1100
            20       3000Try such few examples..
    Twinkle

  • Please why doesn't some programs run on the osx mavericks the way it ran on the osx mountain lion, for example , the wizard 101 installer keeps freezing on maverick. Help me !!!

    please why doesn't some programs run on the osx mavericks

    Some apps require updating when a new operating system comes out. Check with the developers of the apps you're having problems with and see if they have an update or workaround.
    Regards.

  • Why doesn't this i phone (5c) give me automatic audible notice of an e mail ? audible

    Why doesn't this i phone (5c( give me automatic audible notice of an email ?

    Michele,
    Launch Settings / Notifications Center. There you can alter how the system notifies you. Then scroll down to Mail and adjust its specific notification type.
    Also make sure that the Alert sound is turned up in the Sounds portion of Settings.
    -Alan

  • Networking - Why Doesn't This Work?

    Hey all
    Just wondering if any of you have any ideas why this code isn't working properly - for the Client to connect the Server has to be restarted. Is there a solution to this problem?
    The Client Class:
    import java.awt.Container;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.FlowLayout;
    import java.awt.Dimension;
    import java.awt.GridBagLayout;
    import java.awt.GridBagConstraints;
    import java.awt.Insets;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JColorChooser;
    import javax.swing.ButtonGroup;
    import javax.swing.Box;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.BoxLayout;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.JLabel;
    import javax.swing.JComboBox;
    import javax.swing.JOptionPane;
    import javax.swing.JRadioButton;
    import java.io.*;
    import java.net.*;
    * This is the user class and holds all the details for the GUI. The gui contains listeners
    * ans it sends messages to the server and also recieves messages from the server. This class
    * works primarily with the ClienttoServer class.
    * Help was used to create this class, mainly from the Java GUI devlopment book by Varan Piroumian
    * as this hsowed the basic components needed to create a GUI and which imports were the most essential
    * in order to have an interactive interface for the chat application.
    public class Client extends JFrame implements ActionListener
         private static final long serialVersionUID = 1L;
         private JTextArea conversationDisplay;
         private JTextField createMsg, hostfield, portnumfd, usernamey;
         private JScrollPane scrolly;
         private JLabel hosty, portnum, convoLabel, msgLabel, netwrk, netwrk2, talk2urself, fonts, nickName, ustatus, econs;
         private JPanel lpanel, rpanel, lpanel1, lpanel2, lpanel3, lpanel4, lpanel5, rpanel1, rpanel2, rpanel3, rpanel4, rpanel5;
         private JButton sendMsgButton, colourButton, exitButton, connect, dropconnection;
         private JRadioButton talk2urselfOn, talk2urselfOff;
         private JComboBox fontcombiBox, statusbox, emoticons;
         private JColorChooser colourchoo;
         private Container theWholeApp;
         private String username;
         private PrintWriter writer;
         private Socket socky;
         //for the self comm button
         private boolean talktoself = true;
         //used as when a msg is sent to the server the name & msg are sent in 2 parts (\n function) i.e
         //2 different messages. So in self comm mode then the next message needs to be ignored
         private boolean ignoreyourself = false;
          * The Constructor or the class
         public Client()
              makeGUI();
              System.out.println("Loading the GUI....");
          * Creates the GUI for the user to see/use
         public void makeGUI()
              //create the whole window
              JFrame.setDefaultLookAndFeelDecorated(true);
              //set the title of the whole app
              this.setTitle("Welcome To Elliot's Chat Network...");
              //set the app window size
              this.setSize(600, 575);
              //create the outer container for the app
              theWholeApp = getContentPane();
              //make new gridbag layout
              GridBagLayout layoutgridbag = new GridBagLayout();
              //create some restraints for this...
              GridBagConstraints gbconstraints = new GridBagConstraints();
              //make the app use this gridbag layout
              theWholeApp.setLayout(layoutgridbag);
              //this is where elements are added into the application's window
              //creates and adds the convo label
              convoLabel = new JLabel("Your Conversation:");
              gbconstraints = new GridBagConstraints();
              gbconstraints.gridx = 0;
              gbconstraints.gridy = 0;
              gbconstraints.gridheight = 1;
              gbconstraints.gridwidth = 1;
              gbconstraints.weightx = 5;
              gbconstraints.weighty = 1;
              gbconstraints.anchor = GridBagConstraints.WEST;
              layoutgridbag.setConstraints(convoLabel, gbconstraints);
              theWholeApp.add(convoLabel);
              //create & add the exit button
              exitButton = new JButton("Exit");
              gbconstraints = new GridBagConstraints();
              gbconstraints.gridx = 10;
              gbconstraints.gridy = 0;
              gbconstraints.gridheight = 1;
              gbconstraints.gridwidth = 1;
              gbconstraints.weightx = 1;
              gbconstraints.weighty = 1;
              gbconstraints.anchor = GridBagConstraints.EAST;
              layoutgridbag.setConstraints(exitButton, gbconstraints);
              theWholeApp.add(exitButton);
              exitButton.addActionListener(this);
              //create & add the txt area
              conversationDisplay = new JTextArea(15,15);
              scrolly = new JScrollPane(conversationDisplay);
              gbconstraints = new GridBagConstraints();
              gbconstraints.gridx = 0;
              gbconstraints.gridy = 1;
              gbconstraints.gridheight = 4;
              gbconstraints.gridwidth = 11;
              gbconstraints.weightx = 10;
              gbconstraints.weighty = 20;
              gbconstraints.anchor = GridBagConstraints.WEST;
              gbconstraints.fill = GridBagConstraints.BOTH;
              gbconstraints.insets = new Insets(10, 10, 15, 15);
              //so the clients cant write in the display area...
              conversationDisplay.setEditable(false);
              layoutgridbag.setConstraints(scrolly, gbconstraints);
              theWholeApp.add(scrolly);
              //create & add the nick name area
              nickName = new JLabel("Your nick \nthis is required");
              gbconstraints = new GridBagConstraints();
              gbconstraints.gridx = 0;
              gbconstraints.gridy = 5;
              gbconstraints.gridheight = 1;
              gbconstraints.gridwidth = 1;
              gbconstraints.weightx = 5;
              gbconstraints.weighty = 1.5;
              gbconstraints.anchor = GridBagConstraints.WEST;
              gbconstraints.fill = GridBagConstraints.HORIZONTAL;
              gbconstraints.insets = new Insets(3, 10, 0, 0);
              layoutgridbag.setConstraints(nickName, gbconstraints);
              theWholeApp.add(nickName);
              //create & add the nick name box
              usernamey = new JTextField(10);
              gbconstraints = new GridBagConstraints();
              gbconstraints.gridx = 0;
              gbconstraints.gridy = 6;
              gbconstraints.gridheight = 1;
              gbconstraints.gridwidth = 1;
              gbconstraints.weightx = 1;
              gbconstraints.weighty = 1;
              gbconstraints.anchor = GridBagConstraints.WEST;
              gbconstraints.fill = GridBagConstraints.HORIZONTAL;
              gbconstraints.insets = new Insets(0, 10, 0, 0);
              layoutgridbag.setConstraints(usernamey, gbconstraints);
              theWholeApp.add(usernamey);
              //create & add the your message label
              msgLabel = new JLabel("Your Message:");
              gbconstraints = new GridBagConstraints();
              gbconstraints.gridx = 0;
              gbconstraints.gridy = 7;
              gbconstraints.gridheight = 1;
              gbconstraints.gridwidth = 1;
              gbconstraints.weightx = 1;
              gbconstraints.weighty = 1;
              gbconstraints.anchor = GridBagConstraints.WEST;
              gbconstraints.fill = GridBagConstraints.BOTH;
              gbconstraints.insets = new Insets(0, 10, 0, 0);
              layoutgridbag.setConstraints(msgLabel, gbconstraints);
              theWholeApp.add(msgLabel);
              //create & add the create message box
              createMsg = new JTextField(15);
              gbconstraints = new GridBagConstraints();
              gbconstraints.gridx = 0;
              gbconstraints.gridy = 8;
              gbconstraints.gridheight = 2;
              gbconstraints.gridwidth = 10;
              gbconstraints.weightx = 10;
              gbconstraints.weighty = 1;
              gbconstraints.anchor = GridBagConstraints.WEST;
              gbconstraints.fill = GridBagConstraints.HORIZONTAL;
              gbconstraints.insets = new Insets(3, 10, 0, 0);
              layoutgridbag.setConstraints(createMsg, gbconstraints);
              theWholeApp.add(createMsg);
              createMsg.addActionListener(this);
              createMsg.setActionCommand("Press Enter!");
              //create & add the send message button
              sendMsgButton = new JButton("Send Msg");
              gbconstraints = new GridBagConstraints();
              gbconstraints.gridx = 10;
              gbconstraints.gridy = 8;
              gbconstraints.gridheight = 1;
              gbconstraints.gridwidth = 1;
              gbconstraints.weightx = 1;
              gbconstraints.weighty = 1;
              gbconstraints.anchor = GridBagConstraints.EAST;
              layoutgridbag.setConstraints(sendMsgButton, gbconstraints);
              theWholeApp.add(sendMsgButton);
              sendMsgButton.addActionListener(this);
              //create & add the left panel
              lpanel = new JPanel();
              gbconstraints = new GridBagConstraints();
              gbconstraints.gridx = 0;
              gbconstraints.gridy = 10;
              gbconstraints.gridheight = 3;
              gbconstraints.gridwidth = 4;
              gbconstraints.weightx = 5;
              gbconstraints.weighty = 0;
              gbconstraints.anchor = GridBagConstraints.WEST;
              gbconstraints.insets = new Insets(0, 10, 0, 0);
              layoutgridbag.setConstraints(lpanel, gbconstraints);
              theWholeApp.add(lpanel);
              //create & add the right panel
              rpanel = new JPanel();
              gbconstraints = new GridBagConstraints();
              gbconstraints.gridx = 5;
              gbconstraints.gridy = 10;
              gbconstraints.gridheight = 3;
              gbconstraints.gridwidth = 4;
              gbconstraints.weightx = 5;
              gbconstraints.weighty = 0;
              gbconstraints.anchor = GridBagConstraints.EAST;
              layoutgridbag.setConstraints(rpanel, gbconstraints);
              theWholeApp.add(rpanel);
              //add to the left JPanel - set the layout for this
              lpanel.setLayout(new BoxLayout(lpanel, BoxLayout.Y_AXIS));
              //add panels into this left panel...
              lpanel1 = new JPanel();
              lpanel2 = new JPanel();
              lpanel3 = new JPanel();
              lpanel4 = new JPanel();
              lpanel5 = new JPanel();
              lpanel.add(lpanel1);
              lpanel.add(lpanel2);
              lpanel.add(lpanel3);
              lpanel.add(lpanel4);
              lpanel.add(lpanel5);
              //set FlowLyout for each of these panels
              lpanel1.setLayout(new FlowLayout(FlowLayout.LEFT));
              lpanel2.setLayout(new FlowLayout(FlowLayout.LEFT));
              lpanel3.setLayout(new FlowLayout(FlowLayout.LEFT));
              lpanel4.setLayout(new FlowLayout(FlowLayout.LEFT));
              lpanel5.setLayout(new FlowLayout(FlowLayout.LEFT));
              //add in the network items...
              netwrk = new JLabel("Network Details:");
              lpanel1.add(netwrk);
              //create and add instructions for this
              netwrk2 = new JLabel("Please enter the details for \nthe person you want to chat to...");
              lpanel2.add(netwrk2);
              //create/add the ip addy label
              hosty = new JLabel("Host:");
              lpanel3.add(hosty);
              lpanel3.add(Box.createRigidArea(new Dimension(5,0)));
              hostfield = new JTextField("Enter Hostname",10);
              lpanel3.add(hostfield);
              //port num next
              portnum = new JLabel("Port Number:");
              lpanel4.add(portnum);
              lpanel4.add(Box.createRigidArea(new Dimension(5, 0)));
              portnumfd = new JTextField("2250", 10);
              lpanel4.add(portnumfd);
              //create & add the connect butt
              connect = new JButton("Connect");
              lpanel5.add(connect);
              dropconnection = new JButton("Disconnect");
              lpanel5.add(dropconnection);
              connect.addActionListener(this);
              dropconnection.addActionListener(this);
              //start the creation of the right hand panel.
              rpanel.setLayout(new BoxLayout(rpanel, BoxLayout.Y_AXIS));
              //create the panels again
              rpanel1 = new JPanel();
              rpanel2 = new JPanel();
              rpanel3 = new JPanel();
              rpanel4 = new JPanel();
              rpanel5 = new JPanel();
              rpanel.add(rpanel1);
              rpanel.add(rpanel2);
              rpanel.add(rpanel3);
              rpanel.add(rpanel4);
              rpanel.add(rpanel5);
              rpanel1.setLayout(new FlowLayout(FlowLayout.LEFT));
              rpanel2.setLayout(new FlowLayout(FlowLayout.LEFT));
              rpanel3.setLayout(new FlowLayout(FlowLayout.LEFT));
              rpanel4.setLayout(new FlowLayout(FlowLayout.LEFT));
              rpanel5.setLayout(new FlowLayout(FlowLayout.LEFT));
         //now start putting things into them again
              //add in the font settings
              String[] fonty = {"Normal", "Bold", "Italic"};
              fonts = new JLabel("Set your text style:");
              fontcombiBox = new JComboBox(fonty);
              rpanel2.add(fonts);
              rpanel2.add(Box.createRigidArea(new Dimension(4,0)));
              rpanel2.add(fontcombiBox);
              //default text will be plain..
              fontcombiBox.setSelectedIndex(0);
              String[] userstatus = {"Online", "Away", "Be Right Back", "Busy", "Out To Lunch", "On The Phone"};
              ustatus = new JLabel("Select a status:");
              statusbox = new JComboBox(userstatus);
              rpanel2.add(ustatus);
              rpanel2.add(Box.createRigidArea(new Dimension(2,0)));
              rpanel2.add(statusbox);
              //add in some emotion to the conversations
              String[] emotion = {"Angry", "Happy", "Sad", "Crying", "Shocked", "Laughing", "Laughing My Ass Off!"};
              econs = new JLabel("Select an emoticon:");
              emoticons = new JComboBox(emotion);
              rpanel3.add(econs);
              rpanel3.add(Box.createRigidArea(new Dimension(3,0)));
              rpanel3.add(emoticons);
              //self comm options
              talk2urself = new JLabel("Set Self Communication Mode:");
              rpanel4.add(talk2urself);
              talk2urselfOn = new JRadioButton("On", true);
              rpanel4.add(talk2urselfOn);
              rpanel4.add(Box.createRigidArea(new Dimension(4, 0)));
              talk2urselfOff = new JRadioButton("Off", false);
              rpanel4.add(talk2urselfOff);
              //create a group that will hold both these buttons together
              ButtonGroup groupy = new ButtonGroup();
              //add them to the group
              groupy.add(talk2urselfOn);
              groupy.add(talk2urselfOff);
              //create and add the change backgrd button
              colourButton = new JButton("Alter Background");
              rpanel5.add(colourButton);
              //add in some listeners
              talk2urselfOn.addActionListener(this);
              talk2urselfOff.addActionListener(this);
              fontcombiBox.addActionListener(this);
              colourButton.addActionListener(this);
              statusbox.addActionListener(this);
              //add in the 'X' button in the top right corner of app
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              //put all elements together
              this.pack();
              //show the GUI for the user..
              this.show();
          * Creates a new client and GUI as its the main method
         public static void main(String args[])
              new Client();
          * This method listens for actions selected by the user and then performs the
          * necessary tasks in order for the correct events to take place...!
          * This method was mainly created thanks to the Developing Java GUI book which has already
          * been mentioned as it covers listeners and event handling...
         public void actionPerformed(ActionEvent event)
              //if the send button is clicked or if hard carriage return after message
              if((event.getSource() == (sendMsgButton)) || (event.getSource().equals(createMsg)))
                   //if theres no text dont send message
                   if(createMsg.getText().equals(""))
                        JOptionPane.showMessageDialog(this, "There's no text to send!");
                   else
                        String str  = createMsg.getText();
                        printMessage(str);
              //if the exit button is clicked
              if(event.getSource() == (exitButton))
                   //quit the chat app
                   JOptionPane.showMessageDialog(this, "Thanks For Using Elliot's Chat Network! \nSee You Again Soon!");
                   System.exit(0);
              //if the self comm option is turned on
              if(event.getSource() == (talk2urselfOn))
                   talktoself = true;
                   JOptionPane.showMessageDialog(this, "You have begun self communication \nmessages you send are now displayed");
              //if the self comm option is turned off
              if(event.getSource() == (talk2urselfOff))
                   talktoself = false;
                   JOptionPane.showMessageDialog(this, "You have stopped self communication \nmessages you send are no longer displayed");
              //for the normal font option
              if(fontcombiBox.getSelectedItem().equals("Plain"))
                   //makes a new font style plain...
                   conversationDisplay.setFont(new Font("simple", Font.PLAIN, 12));
                   createMsg.setFont(new Font("simple", Font.PLAIN, 12));
              //for the bold font option
              if(fontcombiBox.getSelectedItem().equals("Bold"))
                   conversationDisplay.setFont(new Font("simple", Font.BOLD, 12));
                   createMsg.setFont(new Font("simple", Font.BOLD, 12));
              //for the italic font option
              if(fontcombiBox.getSelectedItem().equals("Italic"))
                   conversationDisplay.setFont(new Font("simple", Font.ITALIC, 12));
                   createMsg.setFont(new Font("simple", Font.ITALIC, 12));
               *      //the status events if they didnt create null points...
              if(statusbox.getSelectedItem().equals("Online"))
                   String status = "<Online>";
                   printMessage(status);
              if(statusbox.getSelectedItem().equals("Away"))
                   String status = "<Away>";
                   printMessage(status);
              if(statusbox.getSelectedItem().equals("Be Right Back"))
                   String status = "<Be Right Back>";
                   printMessage(status);
              if(statusbox.getSelectedItem().equals("Busy"))
                   String status = "<Busy>";
                   printMessage(status);
              if(statusbox.getSelectedItem().equals("Out To Lunch"))
                   String status = "<Out To Lunch>";
                   printMessage(status);
              if(statusbox.getSelectedItem().equals("On The Phone"))
                   String status = "<On The Phone>";
                   printMessage(status);
              //the emoticons events...
              if(emoticons.getSelectedItem().equals("Angry"))
                   String status = "<Angry>";
                   printMessage(status);
              if(emoticons.getSelectedItem().equals("Sad"))
                   String status = "<Sad>";
                   printMessage(status);
              if(emoticons.getSelectedItem().equals("Shocked"))
                   String status = "<Shocked>";
                   printMessage(status);
              if(emoticons.getSelectedItem().equals("Happy"))
                   String status = "<Happy>";
                   printMessage(status);
              if(emoticons.getSelectedItem().equals("Crying"))
                   String status = "<Crying>";
                   printMessage(status);
              if(emoticons.getSelectedItem().equals("Laughing"))
                   String status = "<Laughing>";
                   printMessage(status);
              if(emoticons.getSelectedItem().equals("Laughing My Ass Off!"))
                   String status = "<Laughing My Ass Off!>";
                   printMessage(status);
              //if the colour button is clicked
              if(event.getSource() == colourButton)
                   //create a new colour chooser
                   colourchoo = new JColorChooser();
                   //create the dialog its shown in
                   JColorChooser.createDialog(colourButton, "Choose your background colour", true, colourchoo, this, this);
                   //now show the dialog
                   Color col = JColorChooser.showDialog(sendMsgButton, "Choose your background colour", Color.GRAY);
                   //when a colour is chosen it becomes the bg colour
                   theWholeApp.setBackground(col);
                   rpanel1.setBackground(col);
                   rpanel2.setBackground(col);
                   rpanel3.setBackground(col);
                   rpanel4.setBackground(col);
                   rpanel5.setBackground(col);
                   lpanel1.setBackground(col);
                   lpanel2.setBackground(col);
                   lpanel3.setBackground(col);
                   lpanel4.setBackground(col);
                   lpanel5.setBackground(col);
              //if the connect button is clicked
              if(event.getSource() == (connect))
                   //get the txt entered into ip addy field & port num fields with a text check...
                   if(hosty.getText().equals("") || portnumfd.getText().equals("") || nickName.getText().equals(""))
                        JOptionPane.showMessageDialog(this, "You cant connect! \nThis is because the either the \n0 - HostName\n 0 - Port Number \n0 - Your Nick \nIs Missing...");
                   else
                        //get details and connect
                        username = nickName.getText();
                        String ipay = hostfield.getText();
                        String porty = portnumfd.getText();
                        connectto(ipay,porty);
          * This method is similar to an append method in that it allows msgs recieved by the server to
          * be displayed in the conversation window. It also deals with the self comm mode as if its disabled
          * then no messages from the sender will be displayed.
         public void moveTextToConvo(String texty)
              //check
              if(ignoreyourself == true)
                   ignoreyourself = false;
              else
                   //If self comm is on the send message as normal
                   if(talktoself)
                        conversationDisplay.setText(conversationDisplay.getText() + texty);
                   else
                        //check message isnt sent by the current client - if it is ignore it!
                        if(texty.startsWith(nickName.getText()))
                             ignoreyourself = true;
                        else
                             conversationDisplay.setText(conversationDisplay.getText() + texty);
              //allows the scroll pane to move automatically with the conversation
              conversationDisplay.setCaretPosition(conversationDisplay.getText().length());
          * This method (connectto) is called if the button's clicked and also sets up a relation
          * between the client and clienttoserver class
         public void connectto(String ipa,String portNO)
              //portNO needs to be changed from string to int
              int portNum = new Integer(portNO).intValue();
              try
                   //creates a socket
                   socky = new Socket(ipa, portNum);
                   writer = new PrintWriter(socky.getOutputStream(), true);
                   ClienttoServer cts = new ClienttoServer(socky, this);
                   cts.runit();
                   //give user a prompt
                   JOptionPane.showMessageDialog(this, "You're now connected!");
              catch(UnknownHostException e)
                   System.err.println("Unknown host...");
                   //prompt the user
                   JOptionPane.showMessageDialog(this, "Failed to connect! \nPlease try again...");
              catch(IOException e)
                   System.err.println("Could Not Connect!");
                   //prompt user
                   JOptionPane.showMessageDialog(this, "Error! \nCould not connect - please try again!");
          * This method sends msgs from current client to server, sends username and then the message.
          * This is split into two different messages as the "\n" is used.
         public void printMessage(String mess)
              writer.println(usernamey.getText() + " says: \n" + mess);
              //then clear the text in the message creation area...
              createMsg.setText("");
          * Accessor method to retrieve userName
         public String getUName()
              return username;
          * Disconnect this user from the server so that they can no longer recieve/send messages
         public void dropconnection()
              try
                   //Start to close everything - informing user
                   writer.close();
                   socky.close();
                   //Give the user info on whats happening
                   JOptionPane.showMessageDialog(this, "You are now disconnected \nYou will no longer be able to \nsend and recieve messages");
                   System.out.println("A user has left the conversation...");
              catch (IOException e)
                   System.err.println("IOException " + e);
    The Server Class:
    import java.net.*;
    import java.io.*;
    * This class works in sync with the ServertoClient class in order to read
    * messages from clients and then send back out to all the active clients. Due to
    * the usage of threading multiple clients can use this server.
    * Once again some of this code is from Florians 2005 tutorial work.
    public class Server
         private ServerSocket server;
         private ServertoClient threads[];
         private static int portNo  = 2250;
         private static String Host = ""; //find method to retrieve ip
         private int maxPeeps = 20; //20 people can talk together but this can be altered
          * 1st Constructor - has no params
         public Server()
          * 2nd Constructor - allows for port number setting
         public Server(int portnumber)
              portNo = portnumber;
          * 3rd Constructor - allows for port number & max users
         public Server(int portnumber, int maxiusers)
              portNo = portnumber;
              maxPeeps = maxiusers;
          * This method is to constantly listen for possible messages from clients
         public void listener()
              //set the time out of method to just under a minute
              final int waitingTime = 500000000;
              //a boolean variable to keep it waiting
              boolean keepWait = true;
              //create a threads array of length maxpeeps
              threads = new ServertoClient[maxPeeps];
              //define a variable that will be used as a count of the no of threads
              int x = 0;
              try
                   //open a new socket on this port number
                   server = new ServerSocket(portNo);
              catch (IOException e)
                   System.err.println("IOException " + e);
                   return;
              //while the keepWait is true and the no. of threads is less than the max...
              while(keepWait && x < maxPeeps)
                   try
                        //set the timeout, this is the waitingTime (50 secs)
                        server.setSoTimeout(waitingTime);
                        //listen for connection to accept
                        Socket socky = server.accept();
                        System.out.println("A New User Has Connected");
                        //creates a new thread and adds it to array
                        threads[x] = new ServertoClient(this, socky);
                        //the thread begins
                        threads[x].start();
                   catch (InterruptedIOException e)
                        System.err.println("The Connection Timed Out...");
                        keepWait = false;
                   catch (IOException e)
                        System.err.println("IOException " + e);
                   x++; //increment no. of threads
              //if waitingTime is reached or there are too many threads then server closes
              try
                   server.close();
              catch(IOException e)
                   System.err.println("IOException " + e);
                   return;
          * This prints the string to all active threads
         public void printAll(String printy)
              for(int x = 0; x < threads.length; x++)
                   if(threads[x] !=null && threads[x].isAlive())
                        threads[x].sendMsg(printy);
          * Main method for the server, creates a new server and then continues to listen
          * for messages from different users
         public static void main(String[] args)
              Server chatsession = new Server();
              System.out.println("The Server Is Now Running on port NO: " + portNo);
              System.out.println("And IP Address: " + Host);
              chatsession.listener();
    [/code
    The ServertoClient Classimport java.lang.Thread;
    import java.net.*;
    import java.io.*;
    * This is the ClienttoServer class that acts as an intermediary between the server
    public class ClienttoServer extends Thread
         private Socket socky;
         private BufferedReader bready;
         private boolean active;
         private Client client;
         * This is the constructor to create a new client service
         public ClienttoServer(Socket socket, Client cli)
              socky = socket;
              active = false;
              client = cli;
              //try to read from the client
              try
                   bready = new BufferedReader(new InputStreamReader(socky.getInputStream()));
              catch (IOException e)
                   System.err.println("IOException " + e);
         * This method reads in from the client
         public void runit()
              active = true;
              while(active == true)
              {//continue to read in and then change the text in the conversation window
                   try
                        String message = bready.readLine();
                        client.moveTextToConvo(message + "\n");
                   catch (IOException e)
                        System.err.println("IOException " + e);
                        active = false;
    And finaly the servertoclient class
    import java.net.*;
    import java.io.*;
    import java.lang.Thread;
    * This clas provides the services that the server uses
    public class ServertoClient extends Thread
         private Socket socky;
         private Server server;
         private BufferedReader bready;
         private PrintWriter writer;
          * This constructor sets up the socket
         public ServertoClient(Server theServer, Socket theSocket)throws IOException
              socky = theSocket;
              server = theServer;
              //sets up the i/o streams
              writer = new PrintWriter(socky.getOutputStream(), true);
              bready = new BufferedReader(new InputStreamReader(socky.getInputStream()));
          * This method keeps listening until user disconnects
         public void run()
              boolean keepRunning = true;
              try
                   //keep listening 'til user disconnects
                   while(keepRunning = true)
                        final String tempmsg = bready.readLine();
                        //is there a message (if yes then print it!)
                        if(tempmsg == null)
                        else
                             server.printAll(tempmsg);
                   dropconnection();
              catch (IOException e)
                   System.err.println("IOException in thread " + Thread.currentThread() + ": " + e);
          * This method is for when a user disconnects from the server...
         public void dropconnection()
              try
                   bready.close();
                   writer.close();
                   socky.close();
              catch (IOException e)
                   System.err.println("IOException in thread " + Thread.currentThread() + ": " + e);
              System.out.println("A User Has Disconnected...");
          * This method prints the message
         public void sendMsg(String msg)
              writer.println(msg);
    }Thats it any help would be much appreciated
    Cheers.

    Like the previous poster indicated: try to find a minimal example that shows the error your experiencing.
    One thing that seems bogus is the Server.listener() method. For one thing, it can increment x even if no new connection has been established (e.g., x will be incremented if an exception is caught).

  • VirtualBox clipboard issue AKA why doesn't this restart script work?

    The host is Windows7, the guest is up-to-date Arch and everything I describe is for guest-to-host or host-to-guest copy and paste.  The clipboard within the guest never fails.  The VirtualBox Guest configuration has the clipboard set to 'bi-directional.'
    I'm starting the clipboard via .xinitrc which includes the following line
    VBoxClient-all &
    This is what gets launched
    oliver 211 1 0 15:33 ? 00:00:00 /usr/bin/VBoxClient --clipboard
    It all works perfectly for an indiscriminate amount of time, then suddenly, it stops updating the buffer.  If I try to copy/paste anything new, I get the last entry before it stopped working.  If I restart it (by killing the process and running VBoxClient --clipboard) it works again for an indiscriminate time.  Wash/rinse/repeat.
    I wrote a quick script to run from cron but it's having problems
    This is the script
    #!/usr/bin/bash
    PID="$(ps -ef|grep -i "[v]boxclient --clipboard" | awk '{print $2}')"
    kill $PID && /usr/bin/VBoxClient --clipboard
    exit 0
    I watched the cronjob and it appears to be doing what I want but a 'ps' doesn't show it running afterwards
    ++ grep -i '[v]boxclient --clipboard'
    ++ awk '{print $2}'
    ++ ps -ef
    + PID=3158
    + kill 3158
    + /usr/bin/VBoxClient --clipboard
    + exit 0
    I'm assuming cron runs the command in a shell that gets destroyed when the cronjob is done or something and this is tearing down the process.  I've tried modifying the command with nohup and ampersands to no avail.
    A fix for the underlying problem would be great but I'm assuming I'll be waiting on Oracle for that.  In the meantime, if I could restart this thing periodically it would help me out a bit.
    Any ideas?

    I have the same problem - VBoxClient stops working and restarting it from cron does not work.
    I run this from cron every 10 minutes:
    (killall VBoxClient && VBoxClient-all) || VBoxClient-all
    and VBoxClient is killed every time but is not launched again. How can you explain it?

  • WILL this code run and please explain

    package onlinetest;
    public class Animal {
    public static void main(String[] args) {
    Animal cat=new Animal();
    Plz explain the concept if the code runs, how come jvm is handling by creating a object of the same class in itself. It seems to be a loop...??
    Edited by: Jaguar on Apr 21, 2011 12:09 AM

    Jaguar wrote:
    Plz explain the concept if the code runs, how come jvm is handling by creating a object of the same class in itself. It seems to be a loop...??No it isn't, but this would be:public class Animal {
       private Animal animal = new Animal();
       public static void main(String[] args) {
          Animal cat=new Animal();
    }See the difference?
    Winston

  • Why is my update code running fine yet not actually updating the table?

    When I step through this, it runs fine - the call to Commit executes without dropping into the Rollback block. Yet, the grid (and the underlying table) are not updated.
    private void buttonUpdate_Click(object sender, EventArgs e)
    const int TICKETID_COLUMN = 0;
    String _ticketID = Convert.ToString(dataGridView1.CurrentRow.Cells[TICKETID_COLUMN].Value);
    UpdateRecord(
    _ticketID,
    textBoxTicketSource.Text,
    textBoxContactEmail.Text,
    textBoxAboutLLSID.Text,
    textBoxCategoryID.Text);
    private void UpdateRecord(string ATicketID, string ATicketSource, string AContactsEmail, string AAboutLLSID, string ACategoryID)
    try
    con = new OracleConnection(oradb);
    con.Open();
    String update = @"UPDATE LLS.INTERPRETERTICKETS
    SET TICKETSOURCE = :p_TICKETSOURCE,
    ABOUTLLSID = :p_ABOUTLLSID,
    CATEGORYID = :p_CATEGORYID,
    CONTACTEMAIL = :p_CONTACTEMAIL
    WHERE TICKETID = :p_TICKETID";
    cmd = new OracleCommand(update, con);
    cmd.CommandType = CommandType.Text;
    // TICKETSOURCE, ABOUTLLSID, CATEGORYID, CONTACTEMAIL, TICKETID
    OracleParameter p_TICKETSOURCE =
    new OracleParameter("p_TICKETSOURCE", OracleDbType.NVarchar2, ParameterDirection.Input);
    p_TICKETSOURCE.Size = 20;
    p_TICKETSOURCE.Value = ATicketSource;
    cmd.Parameters.Add(p_TICKETSOURCE);
    OracleParameter p_ABOUTLLSID =
    new OracleParameter("p_ABOUTLLSID", OracleDbType.Int32, ParameterDirection.Input);
    p_ABOUTLLSID.Value = AAboutLLSID;
    cmd.Parameters.Add(p_ABOUTLLSID);
    OracleParameter p_CATEGORYID =
    new OracleParameter("p_CATEGORYID", OracleDbType.Int32, ParameterDirection.Input);
    p_CATEGORYID.Value = ACategoryID;
    cmd.Parameters.Add(p_CATEGORYID);
    OracleParameter p_CONTACTEMAIL =
    new OracleParameter("p_CONTACTEMAIL", OracleDbType.NVarchar2, ParameterDirection.Input);
    p_CONTACTEMAIL.Size = 100;
    p_CONTACTEMAIL.Value = AContactsEmail;
    cmd.Parameters.Add(p_CONTACTEMAIL);
    OracleParameter p_TICKETID =
    new OracleParameter("p_TICKETID", OracleDbType.NVarchar2, ParameterDirection.Input);
    p_TICKETID.Size = 20;
    p_TICKETID.Value = ATicketID;
    cmd.Parameters.Add(p_TICKETID);
    try
    using (var transaction = con.BeginTransaction())
    cmd.Transaction = transaction;
    cmd.ExecuteNonQuery();
    transaction.Commit();
    catch (Exception ex)
    ot.Rollback();
    throw;
    MessageBox.Show("Apparent success");
    finally
    con.Close();
    con.Dispose();
    dataGridView1.Refresh();
    }

    It's hard to say with the limited information available. Nothing jumps out at me as being "wrong" in your code.
    What is the Records Affected return value from cmd.ExecuteQuery?
    I tested this and it worked fine for me:
    SQL
    ========
    SQL> create table interpretertickets (ticketsource nvarchar2(100),
      2  aboutllsid number,
      3  categoryid number,
      4  contactemail nvarchar2(100),
      5  ticketid nvarchar2(100));
    Table created.
    SQL>
    SQL> insert into interpretertickets values(null,null,null,null,1);
    1 row created.
    SQL> commit;
    Commit complete.
    /////////////// CODE //////////////////////
            private void button1_Click(object sender, EventArgs e)
                string constr = "data source=orcl;user id=scott;password=tiger";
                OracleConnection con = new OracleConnection(constr);
                con.Open();
                String update = @"UPDATE INTERPRETERTICKETS
    SET TICKETSOURCE = :p_TICKETSOURCE,
    ABOUTLLSID = :p_ABOUTLLSID,
    CATEGORYID = :p_CATEGORYID,
    CONTACTEMAIL = :p_CONTACTEMAIL
    WHERE TICKETID = :p_TICKETID";
                OracleCommand cmd = new OracleCommand(update, con);
                cmd.CommandType = CommandType.Text;
                // TICKETSOURCE, ABOUTLLSID, CATEGORYID, CONTACTEMAIL, TICKETID
                OracleParameter p_TICKETSOURCE =
                new OracleParameter("p_TICKETSOURCE", OracleDbType.NVarchar2, ParameterDirection.Input);
                p_TICKETSOURCE.Size = 20;
                p_TICKETSOURCE.Value = "newval1";
                cmd.Parameters.Add(p_TICKETSOURCE);
                OracleParameter p_ABOUTLLSID =
                new OracleParameter("p_ABOUTLLSID", OracleDbType.Int32, ParameterDirection.Input);
                p_ABOUTLLSID.Value = 123;
                cmd.Parameters.Add(p_ABOUTLLSID);
                OracleParameter p_CATEGORYID =
                new OracleParameter("p_CATEGORYID", OracleDbType.Int32, ParameterDirection.Input);
                p_CATEGORYID.Value = 456;
                cmd.Parameters.Add(p_CATEGORYID);
                OracleParameter p_CONTACTEMAIL =
                new OracleParameter("p_CONTACTEMAIL", OracleDbType.NVarchar2, ParameterDirection.Input);
                p_CONTACTEMAIL.Size = 100;
                p_CONTACTEMAIL.Value = "[email protected]";
                cmd.Parameters.Add(p_CONTACTEMAIL);
                OracleParameter p_TICKETID =
                new OracleParameter("p_TICKETID", OracleDbType.NVarchar2, ParameterDirection.Input);
                p_TICKETID.Size = 20;
                p_TICKETID.Value = 1;
                cmd.Parameters.Add(p_TICKETID);
                using (var transaction = con.BeginTransaction())
                    cmd.Transaction = transaction;
                    int recaff = cmd.ExecuteNonQuery();
                    MessageBox.Show("records affected: " + recaff);
                    transaction.Commit();
            }

  • Why doesn't this web-based SMS service let us send messages to short-code addresses or extra-long phone numbers?

    Hey, every SMS program that runs on a standard computer (I mean rather than a tablet computer) that I've ever seen won't let us send SMS text messages to short codes--such as a radio station at 57500 or whatever. My phone can do it, so why not here? So Verizon, will you please upgrade it so that it will do that?
    Also, the same question goes for international numbers (yes, the site would make our account pay for those, right?), where 011 and then a country code longer than 1 digit (like longer than our 1 here) are needed. My phone can do it, so why not here? So Verizon, will you please upgrade it so that it will do that, too?

    MaxxFordham wrote:
    Haha, OH! I didn't notice that whole "Verizon Wireless" limitation before. Huh.... Oh wait, so you're saying that sending them from the website is free then, huh? That's interesting.
    Yes, messaging done on the Verizon site does not go against your allowance.  The phone number you put in is so the recipient will know who it is from and can respond.  If they respond to your phone number, and you get the text on your phone, that would be charged to your phone. I believe if you use a nickname, it will be sent to [email protected] and not go through your phone number.

  • Why doesn't this applet  from Sams book run in IE browser?

    I am attaching a piece of code from Sams Teach Yourself Java 2 By Laura Lemay and Rogers Cadenhead. I get no compilation errors. When I run the applet in a browser I get the error
    java.lang.NoClassDefFoundError: PetePanel
    PetePanel is defined in the code below!! By the way I run the applet in a microsoft browser <applet code="PeteApplet.class" height=150 width=345> </applet>
    All the GIF files called by the applet are available. Thanks a bunch for your help.
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    public class PeteApplet extends JApplet {
    PetePanel pete = new PetePanel();
    public void init() {
    JPanel pane = new JPanel();
    pane.setLayout(new GridLayout(1, 1, 15, 15));
    pane.add(pete);
    setContentPane(pane);
    class PetePanel extends JPanel implements Runnable {
    Thread runner;
    Image petePics[] = new Image[6];
    Image back;
    int current = 0;
    int x = -10;
    int y = 30;
    PetePanel() {
    super();
    setBackground(Color.black);
    String peteSrc[] = { "right1.gif", "right2.gif",
    "right3.gif", "stop.gif", "blink.gif",
         "wave.gif" };
    Toolkit kit = Toolkit.getDefaultToolkit();
    for (int i=0; i < petePics.length; i++) {
    petePics[i] = kit.getImage(peteSrc);
    back = kit.getImage("backdrop.gif");
    if (runner == null) {
    runner = new Thread(this);
    runner.start();
    public void paintComponent(Graphics comp) {
    Graphics2D comp2D = (Graphics2D)comp;
    if (back != null)
    comp2D.drawImage(back, 0, 0, this);
    comp2D.setColor(Color.black);
    comp2D.fillRect(0, 30, 450, 30);
    if (petePics[current] != null)
    comp2D.drawImage(petePics[current], x, y, this);
    public void run() {
    while (true) {
    walk(-10, 275);
    look();
    blink(3);
    wave(4);
    walk(x, getSize().width + 10);
    pause(1500);
    public void walk(int start, int end) {
    int showpic = 0;
    for (int i = start; i < end; i += 5) {
    x = i;
    // swap images
    current = showpic;
    repaint();
    pause(150);
    showpic++;
    if (showpic > 2)
    showpic = 0;
    public void blink(int numtimes) {
    for (int i = numtimes; i > 0; i--) {
    current = 4;
    repaint();
    pause(200);
    current = 3;
    repaint();
    pause(1000);
    public void wave(int numtimes) {
    for (int i = numtimes; i > 0; i--) {
    current = 3;
    repaint();
    pause(600);
    current = 5;
    repaint();
    pause(1100);
    public void look() {
    current = 3;
    repaint();
    pause(1000);
    public void pause(int time) {
    try {
    Thread.sleep(time);
    } catch (InterruptedException e) { }

    Many thanks for not replying in this thread. The compiler on PeteApplet.java produced two class files: PeteApplet.class and PetePanel.class. Both the classes are required to run the applet. Of course there will be problems with GIF files (everything in Just Shit Pot is a problem) that'll be another thread.
    Regards

  • Why doesn't this cycle work?

    drain = true;
    onEnterFrame = function(){
        if(drain == true){water_mc.waterlv_mc._alpha -= 2;}
        if(water_mc.waterlv_mc._alpha < 3){water_mc.waterlv_mc._alpha += 2; drain = !true;}   
        if(water_mc.waterlv_mc._alpha > 97){drain = true;}
    the basic idea is simple, it empties and fills as the frames progress, but It seems to empty and stop when tested. What's going wrong?

    shintashi,
         When code performs in unexpected ways, your best bet is often to do a bit of troubleshooting.  One of the quickest, easiest ways to troubleshoot your code is to use the trace() function, which lets you "see" what's going on in your code.  For example, try adding the following trace statement to your existing code:
    drain = true;
    onEnterFrame = function() {
        trace(water_mc.waterlv_mc._alpha);
        if (drain == true) {
            water_mc.waterlv_mc._alpha -= 2;
        if (water_mc.waterlv_mc._alpha < 3) {
            water_mc.waterlv_mc._alpha += 2;
            drain = !true;
        if (water_mc.waterlv_mc._alpha > 97) {
            drain = true;
         When you test your movie again, you'll see the value of waterlv_mc's _alpha property in the Output panel, which might be an eye-opener for you.  First, you'll notice that the _alpha property doesn't decrement by 2s, which is one of the quirks of ActionScript 1.0/2.0.  The reason for this -- and this is just "one of those things" it's good to know -- is that the _alpha property is stored internally as a value from 0 to 256.  The _alpha property "translates" those internal values for you to a range of 0 to 100, which is why the values veer from perfect integers.
         This is a bit of a tangent, though, because the real reason waterlv_mc never "refills" is that your if() statements aren't actually set up to accomplish what you want them to.  Compare the original code with the following variation:
    var drain = true;
    onEnterFrame = function() {
        trace(water_mc.waterlv_mc._alpha);
        if (drain == true) {
            water_mc.waterlv_mc._alpha -= 2;
        } else {
            water_mc.waterlv_mc._alpha += 2;
        if (water_mc.waterlv_mc._alpha >= 100) {
            drain = true;
        if (water_mc.waterlv_mc._alpha <= 0) {
            drain = false;
         In this case, the first if() statement either decrements or increments (thanks to an else) all in the same statement, depending on the value of drain.  First and foremost, you're either decreasing or increasing the value of waterlv_mc's _alpha property.  After that, another set of if() statements determines the value of drain.  When _alpha is 100 (or higher!) you definitely want to "drain the water," so the drain variable is set to true.  On the other hand, when _alpha is 0 (or lower), you want to "refill," so drain is set to false.
         Let me know if this makes sense to you! 
    David Stiller
    Contributor, How to Cheat in Adobe Flash CS4
    http://tinyurl.com/dpsCheatFlashCS4
    "Luck is the residue of good design."

  • Why won't this script run in task scheduler properly?

    Hello,
    I've created a script find all opened windows applications on the local computer.  The script creates an html outfile to report the opened windows and who is logged in. 
    When I run this script from the Powershell ISE or from Powershell command line it works fine.  When I schedule this script to run in windows Task Scheduler (either in Windows 7 or on Windows Server 2008) and I use 'Run only when user is logged in' the
    script again runs fine and reports in the html file the opened windows.
    But when I am logged into the server and I schedule this script to run in windows Task Scheduler (either in Windows 7 or on Windows Server 2008) and I use 'Run whether user is logged in or not' the script will run without error, it creates the html report,
    but it does not list the opened windows applications  That part of the report is missing.
    Why would this happen?  Do I need to change something in my script to make this script work whether or not someone is logged in?
    Here is the script:
    $a = "<style>"
    $a = $a + "BODY{background-color:peachpuff;}"
    $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
    $a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
    $a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
    $a = $a + "</style>"
    get-wmiobject Win32_ComputerSystem | ConvertTo-HTML -head $a -body "<H2>Logged in UserID</H2>" -property username | Out-File C:\Powershell_Scripts\Test.htm ; Get-Process |where {$_.mainWindowTItle} |Select-Object name,mainwindowtitle | ConvertTo-HTML -head $a -body "<H2>Open Applications</H2>" | Out-File C:\Powershell_Scripts\Test.htm -Append
    Thank you.

    Its hard to get a full grasp of the errors from task scheduler.  Try rewriting the Action portion of the Scheduled Task in a cmd prompt (with or without the elevated credentials). When the cmd line runs, the cmd host will convert to a black
    powershell host and you will be able to read the errors.
    C:\> powershell.exe -command { update-help }
    or
    C:\> powershell.exe -noprofile -file c:\scripts\dosomething.ps1
    I solved a similar problem this week.  When I ran my script from within powershell, all the required modules are normally present and the script ran fine.  It was pretty clear which module I forgot to load at the beginning of the script once I could
    watch it from start to finish
    or, your script could dump the Error logs to a text file.
    $Error | select * | out-file c:\errors.txt
    Not the point.  Look at the task scheduler history first.  If the history is not enabled enable it. If it shows no error code then the script ran successfully but had an internal error.
    There is only one place that an error can occur. This will trap it and set the exit code which will be visible in the event history:
    $a=@'
    <style>
    BODY{
    background-color:peachpuff;
    TABLE{
    border-width: 1px;
    border-style: solid;
    border-color: black;
    border-collapse: collapse;
    TH{
    border-width: 1px;
    padding: 0px;
    border-style: solid;
    border-color: black;
    background-color:thistle;
    TD{
    border-width: 1px;
    padding: 0px;
    border-style: solid;
    border-color: black;
    background-color:PaleGoldenrod
    </style>
    Try{
    $username=get-wmiobject Win32_ComputerSystem |%{$_.username}
    $precontent="<H2>Logged in User: $username</H2><br/><H2>Open Applications</H2><br/>"
    $html=Get-Process |where {$_.mainWindowTItle} -ErorAction Stop|
    Select-Object name,mainwindowtitle |
    ConvertTo-HTML -cssuri c:\scripts\style.css -preContent $precontent -body "<body bgcolor='peachpuff'/>"
    $html | Out-File C:\Scripts\Test.htm -ErrorAction Stop
    Catch{
    exit 99
    This is really an exercise in how to manage background tasks.
    Using an error log is good assuming it is not the file system that you are having an issue with
    ¯\_(ツ)_/¯

  • Why doesn't this simple applescript work any more in ML mail.app (as a rule)

    It works only when you right click on the mail message and choose "run rules", but not on incoming messages (without interaction).
    The first dialog is shown both when incoming or running manually, but the second dialog (with the id) is only shown when running manually. Nothing is shown in console.log
    Any ideas?
    using terms from application "Mail"
        on perform mail action with messages theMessages for rule theRule
            tell application "Mail"
                repeat with theMessage in theMessages
                    display dialog "inside"
                    set theId to id of theMessage
                    display dialog "the id is " & theId
                end repeat
            end tell
        end perform mail action with messages
    end using terms from

    Might it be that any incoming message doesn't have an ID yet ?
    Try this:
    using terms from application "Mail"
        on perform mail action with messages theMessages for rule theRule
            tell application "Mail"
                repeat with theMessage in theMessages
                    display dialog "inside"
                    set theTest to (exists id of theMessage)
                    display dialog theTest
                end repeat
            end tell
        end perform mail action with messages
    end using terms from

  • Why doesn't this insert into XMLTYPE work?

    Hi again. Hopefully I'll be answering questions soon, but meanwhile I've got another one.
    I'm working in this environment...
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    The encoding for the database is WE8ISO8859P1.
    in SQL Plus. I created a table with an XMLTYPE column stored as binary. Here's the desc...
    PS: BWDSTG> desc bwddoc;
    Name Null? Type
    SUNAME VARCHAR2(100)
    SOURCE_DOC_TEXT CLOB
    DOC_TEXT SYS.XMLTYPE STORAGE BINARY
    LAST_UPDATE_DATE DATE
    PS: BWDSTG>
    The following error also occurred when I created the same table with a storage type of CLOB for DOC_TEXT. Here's the error I can't figure out...
    PS: BWDSTG> insert into bwddoc (doc_text) values ('<?xml version="1.0" encoding="UTF-8"?>
    2 <a>&#8211;</a>
    3 ');
    insert into bwddoc (doc_text) values ('<?xml version="1.0" encoding="UTF-8"?>
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00217: invalid character 8211 (U+2013)
    Error at line 2
    It accepts the command if I replace the &#8211; with plain text. Why does it care what the character entity reference is? It's changing the encoding pseudoattribute in the xml declaration to US-ASCII anyway, and this character entity should be perfectly acceptable. I'd appreciate it if anyone knows the reason for this (or what I'm not understanding, which as always is a distinct possibility).

    Sorry, let me try again. SQLPlus doesn't have a problem with the multiple lines, so I'm just trying to insert the XML.
    PS: BWDSTG> insert into bwddoc (doc_text) values (xmltype('<?xml version="1.0" encoding="US-ASCII"?>
    2 <a>&#8212;</a>
    3 '));
    insert into bwddoc (doc_text) values (xmltype('<?xml version="1.0" encoding="US-ASCII"?>
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00217: invalid character 8212 (U+2014)
    Error at line 2
    ORA-06512: at "SYS.XMLTYPE", line 310
    ORA-06512: at line 1
    My problem is that...
    <?xml version="1.0" encoding="US-ASCII"?>
    <a>&#8212;</a>
    should be perfectly good HTML. libxml2 and expat both have no problem parsing it. They just leave &#8212; (which is some kind of a dash) alone. But Oracle XMLType doesn't like it for some reason. I need to load a lot of data that has numeric character entities like this but I can't 'til I get this resolved.

Maybe you are looking for

  • Skype 7.0 is not picking up my voice after a black...

    So basically what happened was I was skyping with my friend fine and suddenly PC got shut off due to a blackout. After a restart, my Skype (7.0) won't pick up my voice anymore. Only Skype won't pick up my voice. Steam, GTalk, Windows Setting all can

  • Optional fields in sender FCC

    Hi All, my source file is a flat csv file, ex:  10,20,30,40,50        11,21,31,41,51 five fields in source structure. fields 3 and 4 are optional . in this case, when both the fields values are not coming ,how my source file looks like? wat i mean is

  • Deployment Rule Set broken with Java 7u55

    Hello! I'm using Deployment Rule Set in my company environment, its signed by code signing certificate that is given out by internal CA. After I upgraded to Java 7u55, the Deployment Rule Set does not recognize older statically installed Java version

  • Pagination and Reset Pagination

    I do not understand what pagination means and what "reset pagination" does. I think I need an example where I can observe the difference between using or omitting a pagination reset. I created a page with a report and a search tool. Apex created auto

  • In Safari (in Gmail), plain text pasted in doesn't adopt the existing font

    When pasting plain text into Safari (Gmail), it shows up as Ariel instead of the current font in use in the e-mail (happens to be Trebuchet). It doesn't happen in Chrome.