GUI problem with UNIX

 

Hi Vasundhara,
Try grouping the widgets in to a panel.
Thanks,
Madhu
-----Original Message-----
From: vasundhara [mailto:[email protected]]
Sent: Wednesday, April 25, 2001 9:15 AM
To: [email protected]; Joseph Mirwald
Subject: Re: (forte-users) GUI problem with UNIX
Hi Joseph
We are using Forte 3.0 M2 on Solaris 5.8 The problem is with the push
buttons, After we grid the controls and they look intact in the NT
environment, but when we open the same window in SOlaris the controls are
far apart.Do you have any idea about this?
Regards
Vasundhara
----- Original Message -----
From: Joseph Mirwald <mailto:[email protected]>
To: vasundhara <mailto:[email protected]> ;
[email protected] <mailto:[email protected]>
Sent: Wednesday, April 25, 2001 10:13 AM
Subject: Re: (forte-users) GUI problem with UNIX
Hello vashundara,
please say which Version of Forte and which kind/version your UNIX OS is.
There are some problems on AIX V4.3.x (Motif 2.x) and older releasese of
Forte (up to Forte 3.M.x) and so on and it is necessary to look what it is.
Maybe it is possible for you to say which widgets are the problem.
Thanks forward
Joseph Mirwald
At 15:25 23.04.01 +0530, vasundhara wrote:
Hi
We are facing a strange problem when we try to port our application from NT
to UNIX. The problem is that the GUI doesnt come properly. As per my
knowledge gridding all the controls on the GUI shouldnot create this
problem, but inspite of this we are facing it. Did anyone comeacross this
situation?
Thanks in advance
Regards
Vasundhara N.C
Wisor Telecom Pvt Ltd
Bangalore
India

Similar Messages

  • Problem with unix "foreach" command

    Hi,
    I am facing a problem with unix command "foreach". I trying to process files using unix foreach command. When running the script with 500 or 1000 files. It is running fine. But when I am trying to the script with 2000+ files. Its throwing an error "Arguments too long".
    below is the syntax I am using in the script:
    foreach name (*)
    end
    Could anybody help me on this issue.
    Thanks in Advance.
    Manasa.

    UNIX/Linux systems expand wildcards onto the command line before invoking the
    individual commands. In effect, the shell rewrites the command line you give
    substituting the wildcard expansion. There is a limit to how long this command
    line can get.
    For example, suppose you have two files ("foo" and "bar") in your directory.
    The line:
    foreach name (*)
      echo $name
    endgets rewritten to:
    foreach name (foo bar)
      echo $name
    endand then the shell starts interpreting your script. So if you have many, many
    files, the rewritten line becomes:
    foreach name (f1 f2 f3 ... f10927)
      echo $name
    endso chances are the "foreach" line simply gets too long. To avoid problems do
    it this way; it avoids any problems based on how many files you have:
    ls | while read name
    do
      echo $name
    doneThis way the shell never exceeds its line length limitations because the
    wildcard is never expanded.
    Cheers

  • GUI - Problem with GridBag

    Hi everyone,
    I have been trying to get this GUI built from the ground up and I have encountered a problem with the GridBag(exception error that the fields being added can not be done. Also, my method main seems to be off track, I have a working program which the display fields have been modified to display object and everything else is the same except that I can not get the GUI to run.
    The following is the code and any suggestions as to what I can do to get this going will be appreciated. Thank you.
    import javax.swing.JLabel; /* displays text and images*/
    import javax.swing.SwingConstants; /* common constants used with Swing*/
    import javax.swing.Icon; /* interface used to manipulate images*/
    import javax.swing.ImageIcon; /* loads images*/
    import javax.swing.JOptionPane;
    import java.util.*;
    import java.io.PrintStream;
    import java.text.DecimalFormat;
    import java.text.NumberFormat;
    import java.text.*;     
    import javax.swing.JFrame;/* provides basic window features*/     
    import java.util.Arrays;
    import javax.swing.ImageIcon.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    public class FinalInventoryGUI extends JFrame
    {//Private variables.
    private GridBagLayout layout = new GridBagLayout();
    private GridBagConstraints constraints = new GridBagConstraints();
    //Private data from main program
    private String productName;
    private String itmeNumber;
    private double unitPrice;
    private int unitStock;
    private double productValue;
    private double inventoryValue;
    private double reStkfee;
    //Declaration of the JLabels.
    private JLabel logoLabel;
    private JLabel productNameLabel;
    private JLabel itemNumberLabel;
    private JLabel unitPriceLabel;
    private JLabel unitStockLabel;
    private JLabel productValueLabel;
    private JLabel InventoryValueLabel;
    private JLabel reStkfeeLabel;
    //Declaration of the text Fields for data Entry.     
    private JTextField productNameText;
    private JTextField itemNumberText;
    private JTextField unitPriceText;
    private JTextField unitStockText;
    private JTextField productValueText;
    private JTextField inventoryValueText;
    private JTextField reStkfeeText;
    private JTextField titleText;
    //Declaration of the JButtons for user interface.
    private JButton first;//To move to first element in the array.
    private JButton next;//To move to next element in the array.
    private JButton previous;//To move to next element in the array.
    private JButton lastButton;//To move to the first element in the array.
    private JButton addButton;//To add a product to the array.
    private JButton modifyButton;//To modify an element in the array.
    private JButton deleteButton;//To remove a product from the array.
    private JButton saveButton;//To save the array elements to C:\.
    private JButton searchButton;//To search for an element in the array.
    private Product products[];//Declaration of array product[] for storing entries.
    private int NumOfProducts;//Declaration of the variable defining the number of products.
    private int Index=0;//Setting the counter index to initiate at "0".
    //Constants
    private final static int LOGO_WIDTH  = 4;
    private final static int LOGO_HEIGHT = 4;
    private final static int LABEL_WIDTH  = 1;
    private final static int LABEL_HEIGHT = 1;
    private final static int TEXT_WIDTH  = LOGO_WIDTH-LABEL_WIDTH;
    private final static int TEXT_HEIGHT = 1;
    private final static int BUTTON_WIDTH  = 1;
    private final static int BUTTON_HEIGHT = 1;
    private final static int LABEL_START_ROW = LABEL_HEIGHT+LABEL_WIDTH+1;
    private final static int LABEL_COLUMN = 0;
    private final static int TEXT_START_ROW = LABEL_START_ROW;
    private final static int TEXT_COLUMN = LABEL_WIDTH+1;
    private final static int BUTTON_START_ROW = LABEL_START_ROW+9*LABEL_HEIGHT;
    private final static int BUTTON_COLUMN = LABEL_COLUMN;
    private final static int SEARCH_START_ROW = BUTTON_START_ROW+3;
    final static String EMPTY_ARRAY_MESSAGE = "Hit ADD to add a new PRODUCT";
    //Constructor-New instance of the JLabelTextFieldView.
    public FinalInventoryGUI( Product productsIn)
        {//Passing the frame title to JFrame, set the IconImage.
             super("Welcome To The Inventory Program");
             setLayout(layout);
             //Copy the input array(products).
             setProduct(productsIn);//maybe the title?????
             //Start the display with the first element of the array.
             index = 0;
             //Build the GUI
             buildGUI();
             //Values
             updateAllTextFields();
             }//End of the constructor for building the GUI.
             //Methods for copying the input of Product array to the GUIs private array
             //variable
             private void setInventoryArray(Product productsIn[])
                  products = new Product[productIn.length];
                  for (int i = 0; i<products.length; i++)
                  {//Creates A Product array element from the input array.
                       prodcuts[i] = new Product(productIn);
                   products[i] = new Product(productIn[i].productName(), productIn[i].itemNumber(),
                                                      productIn[i].unitStock(), productIn[i].unitPrice());
              //System prints out a ineof the productsIn array to a string.
         }//End of the for statment.
         }//End for copying the array.
         //A method for updating each of the GUIs fields.
         private void updateAllTextFields()
              if(products.length > 0)//Then update the JTextField display.
              {// Update the product name text field.
              productNameText.setText(products[index].productName());
              //Update the Update the itemNumber text field.
              itemNumberText.set(String.format("%d", products[index].itemNumber()));
              //Update the title text field.
              titleText.setText(dvd[index].title());
              //Update the unitStock text field.
              unitStockText.setText(String.format("%d",products[index].unitStock()));
              //Update the unit price textField.
              unitPriceText.setText(String.format("$%.2f",products[index].unitPrice()));
              //Update the productValue textField.
              productValueText.setText(String.format("$%.2f", products[index].productValue()));
              //Update the restocking fee text field.
              reStkfeeText.setText(String.format("$%.2f",reStkfee()));
              //Update the total value of the inventory text field.
              inventoryValueText.setText(String.formtat("$%.2f",Product.productValue(products)));
              }//End of the if statement.
              else//Put a special message in the fields.
              {//Update the productName textField.
              productNameText.setText(EMPTY_ARRAY_MESSAGE);
              //Update the itemNumber textField
              itemNumberText.setText(EMPTY_ARRAY_MESSAGE);
              //Update the title textField.
              titleText.setText(EMPTY_ARRAY_MESSAGE);
              //Update the units in stock textField.
              unitStockText.setText(EMPTY_ARRAY_MESSAGE);
              //Update the unitPrice textFied.
              unitPriceText.setText(EMPTY_ARRAY_MESSAGE);
              //Update the productValue textField.
              productValueText.setText(EMPTY_ARRAY_MESSAGE);
              //Update the restocking fee textField.
              reStkfeeText.setText(EMPTY_ARRAY_MESSAGE);
              //Update the totatl inventoryValue textField.
              inventoryValueText.setText(EMPTY_ARRAY_MESSAGE);
              }//End else
         }//Set the appropriate fields editable or uneditable.
         private void setModifiableTextFieldsEnabled(Boolean state)
         {//The fields of the product name, item number, unit price,
         // and stock can be editable or non editable.
         itemNumber.setEditable(state);
         productName.setEditable(state);
         unitPrice.setEditable(state);
         unitStock.setEditable(state);
         }//End setting of the modifiable textFields.
         //Methods for the JButton methods.
         private class ButtonHandler implements ActionListener
              public void actionPerformed(ActionEvent event)
              {//This is the first button being pressed by the user.
                   if(event.getSource()==firstButton)
                        handleFirstButton();
                   }//End if
                   else if(event.getSource()==previousButton)//Button previous is pressed by user.
                        handlePreviousButton();
                   }//End else if
                   else if (event.getSource()==nextButton)//Button next is pressed by user.
                        handleNextButton();
                   }//End else if.
                   else if (event.getSource()==lastButton)//Button last is pressed by the user.
                        handleLastButton();
                   }//End else if.
                   else if(event.getSource()==firstButton)
                        handleFirstButton();
                   }//End else if.
         }//End metod of actionPeformed.
         }//End class ButtonHandler
         //Displaying the first element of the Product array
         private void handlerFirstButton()
         {//Setting the index to the first element in the array.
              index = 0;
         //Update and disable modification
         updateAllFields();
         setModifiableTextFieldsEnabled(false);
         }//End method for handling the first button.
         //Displaying the next element of the products array or wrap to the first.
         private void handleNextButton()
         {//Incrementation of the index.
         index++;
         //If the index exceeds the last valid array element, wrap around to the first
         //element of the array.
         if(index > products.length-1)
              index = 0;
         }//End if statment.
         //Update and disable the modification.
         updateAllFields();
         setModifiableTextFieldsEnabled(false);
         }//End method of handleNextButton.     
         private void handlePreviousButton()
              index--;
              if(index < 0)
                   index = products.length -1;
              }//End if statment.
              //Update and disabe modification.
              updateAllTextFields();
              setModifiableTextFieldsEnabled(false);
         }//End method of handlePreviousButton.
         private void handleLastButton()
              index--;
              if(index < products.length -1)
                   index = 2;
              }//End if statment.
              updateAllTextFields();
              setMdifiableTextFieldsEnabled(false);
              }//End method for handleLatButton
         //The textFieldHandler class - handling the events of the buttonsmethods
         private class TextFieldHandler implements ActionListener
              public void actionPerformed(ActionEvent event)
              {//The user pressed "ENTER" in the JTextField "title" text.
              if(event.getSource() == itemNumber)
                   //HandleItemNumberTextField()is fired.
              }//End the if statement.
              //The user pressed "ENTER" in the JTextField "title" text.
              else if (event.getSource() == titleText)
                   //HandleTitleTextField() is fired.
              }//End the if statement.
         //The user pressed "ENTER" in the JTextField "unitStoc" text.
              else if(event.getSource() == unitStockText)
                   //HandleUnitStockTextField() is fired.
              }//End the if statment
              //The user pressed "ENTER" in the JtextField "unitPrice" text.
              else if (event.getSource() == unitPriceText)
                   //HandleUnitPriceTextField() is fired.
              }//End the if statment.
         //The user pressed "ENTER" in the JTextField "Search" text.
         else if(event.getSource() == searchText)
              //HandleSearchTextField() is fired.
         }//End the if statment.
              }//End the method actionPerformed.
         }//End the inner class TextFieldhandler.
              //The GUI methods.
              //Building the GUI.
              private void BuildGUI()
              {//Mthod for adding the LOGO.
              buildLogo();
              //Add the text fields and their labels.
              buildLabels();
              buildTextFields();
              //Add the navigation and other buttons.
              buildMainButtons();
              //Provide value to the Fields.
              updateAllTextFields();
              //provide some setup to the frame.
                        setSize(FRAME_LENGTH, FRAME_WIDTH);
                        setLocation(FRAME-XLOC, FRAME_YLOC);
                        setResizable(false);
                        //PACK(); IS THIS NOT PART OF THE GUI ADDED AT THE END OR IS WHAT
                        //FOLLOWS THE SAME AS SAYING ".PACK()".
                        setDefaultCloseOperation(EXIT_ON_CLOSE);//DOES IT MATTER WHERE THIS LINE FALLS?
                        //WHEN I TRIED TO USE IT IN THE MAIN I RECEIVED AN ERROR AND THE SAME WHEN I
                        //PLACED IT IN THE CONSTRUCTOR--WHY?.
                        setVisible(true);
              }//End of building the GUI.
              //Addin the LOGO to the Frame.
              private void buildLogo()
                   constraints.weightx = 2;
                   constraints.weigthy = 1;
                   logoLabel = new JLabel(new ImageIcon("O2K.jpg"));
                   logoLabel.setText("Products Inventory");
                   constraints.fill = GridBagConstraints.BOTH;
                   addToGridbag(logoLabel,2,2,LOGO_WIDTH, LOGO_HEIGHT);
                   //Creating a vertical space.
                   addToGridBag(new JLabel(""),LOGO_HEIGHT+1,0, LOGO_WIDTH, LABEL_WIDTH);
              }//End the method with building the LOGO.
                   //Build the panel just containing the text.
                   private void buildLabels()
                   {//Set up if for readability).
                   int rows = 0;
                   int column = 0;
                   int width = 0;
                   int height = 0;
              column = LABEL_COLUMN;
              width = LABEL_WIDTH;
              height = LABEL_HEIGHT;
                   constraints.weightx = 1;
                   constraints.weighty = 0;
                        constraints.fill = GridbagConstraints.Both;
                        //Create the name labes and name the TextFields.
                        productNameLabel = new JLabel("Product Name:");
                        productnamelabel.setLabelfor(productNameField);
                        productNameLabel.setLabelFor(productNameText);
                        productNameLabel.setToolTipText("Enter The Product Name Here");
                        row = Label_START_ROW;          
                        addToGridBag(productNameLabel, row, column, width, height);
                        //Create the itemNumberLabel and TextField.
                        itemNumberLabel = new JLabel("Product Id:");
                        itemNumberLabel.setLabelFor(itemNumberText);
                        row += LABEL_HEIGHT;
                        addToGridBag(itemNumber, row, column, width, height);
                        //Create the title label for the Product and the title text field.
                        titleLabel = new JLabel("Inventory Of Products:");
                        titleLabel.setLabelFor(titleText);
                        row += LABEL_HEIGHT;
                        addToGridBag(titleLabel,row,column,width,height);
                        //Create the unitStock label and textField.
                        unitStockLabel = new JLabel("Units In Stock:");
                        unitStockLabel.setLabelFor(unitStockLabel);
                        row += LABEL_HEIGHT;
                        addToGridBag(unitStocklabel, row, column, height);
                        //Creat the unitPrice label and textField.
                        unitPriceLabel = new JLabel("Unit Price");
                        unitPriceLabel.setLabelFor(unitPriceLabel);
                        unitPriceLabel.setToolTipText("The Cost Of The Product");
                        row += LABEL_HEIGHT;
                        addToGridBag(unitPriceLabel, row, column, height);
                        //Create the productValue label and textField.
                        productValueLabel = new JLabel("Total Product Value:");          
                        productValueLabel.setLabelFor(productValueLabel);
                        row += LABEL_HEIGHT;
                        addToGridBag(productValue, row, column, height);
                        //Create the restocking fee of 1.05% Label and textField.
                        reStkfeeLabel = new JLabel("Product Restock Fee:");
                        reStkfeeLabel.setLabelFor(reStkfeeLabel);
                        row+= LABEL_HEIGHT;
                        addToGridBag(reStkfee, row, column, height);
                        //Create a vertical space.
                        row += LABEL_HEIGHT;
                        //Create the Total Inventory Value label and textField.
                        inventoryValueLabel = new JLabel("Total Inventory Value:");
                        inventoryValueLabel.setLabelFor(inventoryValueLabel);
                        row += LABEL_HEIGHT;
                        addToGridBag(inventoryValue, row, column, height);
              }//End the method for building the labels
                        //Build the methods for the TextFields.
                        private void buildTextFields()
                             {//Defining the variables
                             int row = 0;
                             int column = 0;
                             int width = 0;
                             int height = 0;
                             column = TEXT_COLUMN;
                             width = TEXT_WIDTH;
                             height = TEXT_HEIGHT;
                             constraints.fill = GridBagConstraints.BOTH;
                             constraints.weightx = 1;                    
                             TextFieldHandler handler = new TextFieldHandler();
                             productNameText = new JTextField("Product Name");
                             productNameText.setEditable(false);
                             row = TEXT_START_ROW;
                             addToGridBag(productNameText, row, column, height);
                        itemNumberText = new JTextField("Product Id");
                        itemNumberText.setEditable(false);
                        row = TEXT_START_ROW;
                        addToGridBag(itemNumberText, row, column, height);
                        titleText = new JTextField("Title");
                        titleText.addActionListener(handler);
                        titleText.setEditable(false);
                        row += TEXT_HEIGHT;
                        addToGridBag(titleText, row, column, height);
                        unitPriceText = new JTextField("Unit Price");
                        unitPriceText.addActionListener(handler);
                        unitPrice.setEditable(false);
                        row += TEXT_START_ROW;
                        addToGridBag(unitPriceText, row, column, height);
                        unitStockText = new JTextField("Units In Stock");
                        unitStockText.addActionListener(handler);
                        unitStockText.setEditable(false);
                        row += TEXT_START_ROW;
                        addToGridBag(unitStockText, row, column, height);
                        productValueText =new TextField("Product Value");
                        productValueText.addActionListener(handler);
                        productValueText.setEditable(false);
                        row += TEXT_START_ROW;
                        addToGridBag(productValueText, row, cloumn, height);
                             reStkfeeText =new JTextField("Restock Fee");
                        reStkfeeText.addActionListener(handler);
                        reStkfeeText.setEditable(false);
                        row += TEXT_START_ROW;
                        addToGridBag(reStkfeeText, row, cloumn, height);
                        //Creat vertical space.
                        row += TEXT_HEIGHT;
                        addToGridBag(new JLabel(""),row, column, height);
                        inventoryValueText =new TextField("Inventory Value");
                        inventoryValueText.addActionListener(handler);
                        inventoryValueText.setEditable(false);
                        row += TEXT_START_ROW;
                        addToGridBag(inventoryValueText, row, cloumn, height);
                        }//End the methods for building the TextFields.
                             //Add the main buttons to the frame.
                   private void buildMainButtons()
                             {//Declaraing the variables.
                             int row = 0;
                             int column = 0;
                             int width = 0;
                             int height = 0;                         
                             row =BUTTON_START_ROW;
                             column = BUTTON_COLUMN;
                             width = BUTTON_WIDTH;
                             height = BUTTON_HEIGHT;
                             constraints.weightx = 1;
                             constraints.weighty = 0;                         
                             //The constraints.fill = GridBagConstraints.HORIZONTAL;
                             ButtonHandler handler = new ButtonHandler();
                             //Creat a veritical space.
                             addToGridbag(new JLabel(""), row, column, width, height);
                             firstButton = new JButton("First");
                             firstButton.addActionListener(handler);
                             row += LABEL_HEIGHT;
                             addToGridBage(firstButton, row, column, width, height);                         
                             previousButton = new JButton("Previous");
                             previousButton.addActionListener(handler);
                             row += LABEL_HEIGHT;
                             addToGridBage(previousButton, row, column, width, height);     
                             nextButton = new JButton("Next");
                             nextButton.addActionListener(handler);
                             row += LABEL_HEIGHT;
                             addToGridBage(nextButton, row, column, width, height);     
                             lastButton = new JButton("Last");
                             lastButton.addActionListener(handler);
                             row += LABEL_HEIGHT;
                             addToGridBage(lastButton, row, column, width, height);     
                             addButton = new JButton("Add");
                             addButton.addActionListener(handler);
                             row += LABEL_HEIGHT;
                             addToGridBage(addButton, row, column, width, height);                         
                             deleteButton = new JButton("Delete");
                             deleteButton.addActionListener(handler);
                             row += LABEL_HEIGHT;
                             addToGridBage(deleteButton, row, column, width, height);
                             saveButton = new JButton("Save");
                             saveButton.addActionListener(handler);
                             row += LABEL_HEIGHT;
                             addToGridBage(saveButton, row, column, width, height);     
                             searchButton = new JButton("Search");
                             searchButton.addActionListener(handler);
                             row += LABEL_HEIGHT;
                             addToGridBage(searchButton, row, column, width, height);                         
                        //End methods for building the main butt0ns.
         private void addToGridBag(Component component, int row, int column, int width, int height)
         {               //Set up the upper-left corner of the component gridx and gridy.
                             constraints.gridx = column;
                             constraints.gridy = row;
                             //Set the numbers of rows and columns the components occupies.
                             constraints.gridwidth = width;
                             constraints.gridheight = height;
                             //set the constraints
                             Layout.setConstraints(component, constraints);
                             //Add the component to the JFrame.
                             add(component);                    
                        }//End method for addGridBag.                     
              //End class JLabelTextFieldViewGui.
    class Invetnory4
              public static void main(String args[])
                        {   //An array variable.
                             Product[]inventory;
                             inventory = new Product[10];
                             //Create and pass control to the GUI
                             FinalInventory gui = new FinaInventoryGUI(inventory);           
                        }//End method main
                   }//End class Inventory4     
    /*Inventory.java*/
    /*Means for importing program packages*/
    /*Beginning of the class type Inventory*/

    Hi Bryan,
    I took your advice and decided to take a different approach to the problem I am having, I decided to stay somewhat with the basics with little knowledge I have about coding. I am new to this and I am trying to learn through the fire but it's getting hot so if you don't mind, can you tell me what I need to do to fix the error messages I am getting.
    1. "else" without "if',
    2. can't load my icon-a JPG
    3. exception in thread amin
    process complete.
    4.Text area for displaying an iteration of the input
    the code is not as long as the other one! any help will be appreciated. Also I am attaching the code to the GUI that does work but I can not seem to get the actionListener aspect to work. Thanks again.
      //this one works and it serves as a model for what I am //trying to do in the fields. as well as designate a text area                                                              //where a each entry per iteration of input is displayed
    * @(#)InventoryGUIFrame.java
    * @author
    * @version 1.00 2008/2/2
    package components;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.ImageIcon;
    import javax.swing.event.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.text.*;
    import java.awt.*;
    * FormattedTextFieldDemo.java requires no other files.
    * It implements a mortgage calculator that uses four
    * JFormattedTextFields.
    public class InventoryGUIFrame extends JFrame
              String productName;
              String itemNumber;
              double unitPrice;
              double unitStock;
              //Labels to identify the fields
              private JLabel productNamelabel;
              private JLabel itemNumberlabel;
              private JLabel unitPricelabel;
              private JLabel unitStocklabel;
              //Fields for data Entry     
              private JTextField productNameField;
              private JTextField itemNumberField;
              private JTextField unitPriceField;
              private     JTextField unitStockField;
                   //Adding the JButtons
              JButton firstButton;
              JButton nextButton;
              JButton previousButton;
              JButton searchButton;
              JButton addButton;
              JButton deleteButton;
              JButton saveButton;
              //Constructor          
    public InventoryGUIFrame()
             super("Welcome To The Inventory Program");
             setLayout(new FlowLayout());
             setDefaultCloseOperation(EXIT_ON_CLOSE);
             JFrame Frame = new JFrame();
             Frame JPanel = new Frame();
             JPanel  JLabel= new JPanel();
             TextArea area = new TextArea();
         productNamelabel = new JLabel("PRODUCT  NAME");
         productNamelabel.setToolTipText("Name of the item you wish to calculate");
        add(productNamelabel);
         productNameField= new JTextField(8);
         add(productNameField);
         itemNumberlabel = new JLabel("PRODUCT  NUMBER");
         itemNumberlabel.setToolTipText("Number identifying the product");
         add(itemNumberlabel);
         itemNumberField =new JTextField(5);
         add(itemNumberField);
         unitPricelabel=new JLabel("PRODUCT  PRICE");
         unitPricelabel.setToolTipText("What is the cost of the product?:");
         add(unitPricelabel);
         unitPriceField = new JTextField(5);
         add(unitPriceField);          
         unitStocklabel = new JLabel("UNITS  IN  STOCK");
         unitStocklabel.setToolTipText("How many products in inventory?:");
         add(unitStocklabel);
         unitStockField = new JTextField(5);
         add(unitStockField);
         firstButton =new JButton("First");
         add(firstButton);
         nextButton = new JButton("Next");
         add(nextButton);
         previousButton = new JButton("Previous");
         add(previousButton);
         addButton = new JButton("Add");
         add(addButton);
         deleteButton = new JButton("Delete");
         add(deleteButton);
         saveButton = new JButton("Save");
         add(saveButton);
         searchButton = new JButton("Search");
         add(searchButton);
         public static void main(String args[])
         InventoryGUIFrame frame  = new InventoryGUIFrame();
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.setSize(740,150);
         frame.setVisible(true);
      class InventorySystem6
    {     /*Declaration of products[] and the maximum storing capacity*/
       private Product products[] = new Product[MAX_NUM_OF_PRODUCTS];
       /*Prompts user to make another selection or exit program*/
       private static final String STOP_COMMAND = "stop";
            /*parameters defining maximun numbers of products available for storing in */
    private static final int MAX_NUM_OF_PRODUCTS = 100;
    /*Declaration of the variables */
    String name;
    String item;
    double stock;
    double price;
    double reStkfee=1.05;
    double pValue;
    double iValue;
    public InventorySystem6()
         /*Empty Constructor*/
    }/*Beginning of product input by the user*/
    public void inputProductInfo()
    {     /*Declaration of currency format*/     
                   DecimalFormat Currency = new DecimalFormat();
                   Scanner input = new Scanner(System.in);
                   /*Beginning of the Loop*/
                   JOptionPane.showMessageDialog(null,"Welcome to the Inventory Program\n","Welcome to the Inventory Program\n",
                   JOptionPane.PLAIN_MESSAGE);               
                   for(int i = 0; i<MAX_NUM_OF_PRODUCTS ; i++)
                   name = JOptionPane.showInputDialog( "What is the Product Name? ");
                   if(name.equalsIgnoreCase("stop"))
                   break;
         String item = JOptionPane.showInputDialog("Enter the products ID");
         String priceStr =JOptionPane.showInputDialog("Enter the products price");
         double price=Double.parseDouble(priceStr);
                   String stockStr=JOptionPane.showInputDialog("Enter the units in stock " );
                   double stock = Double.parseDouble(stockStr);          
                   double sum=price*stock;
              JOptionPane.showMessageDialog(null,"The product value is:"+sum, "pValue",
              JOptionPane.PLAIN_MESSAGE);
                   /* JOptionPane.showMessageDialog(null,"The Product Name is:"+productName, "productName"
                   ,"\n","The Product Id is "+productId,"Product ID"
                        ,"\n","The Unit Price is"+unitPrice,"Unit Price"
                             ,"\n","The Units In Stock is"+unitStock,"UnitStock"
                                  ,"\n","The Product Value is"+productValue, "productValue"
                                       ,"\n","The Restocking Fee is "+reStockfee,"Restock Fee"
                                            ,"\n","The Inventory Value is"+inventoryValue,"Inventory Value"
                                                 ,"\n","The Inventory Restock Fee is"+reStockfee,"Restock Fee"
                                                      ,"\n",JOptionPane.PLAIN_MESSAGE);*/
              //Product products[] = new Product[100];
                   products[i] = new Product();
                   products[i].setitem(item);
                   products[i].setname(name);
                   products[i].setprice(price);
                   products[i].setstock(stock);
                   products[i].setpValue(sum);
                   products[i].setreStkfee(reStkfee);
                   iValue += sum + products[i].getreStkfee();
    public void displayProductInfo()
    { /*Initialization of the variable total inventory value*/
    NumberFormat moneyFormat = NumberFormat.getCurrencyInstance();
    for(int i = 0; i<MAX_NUM_OF_PRODUCTS ; i++)
              Product product = products[i];
              if(product==null)
              System.out.println(products[i]);
                   break;
         System.out.printf("product name: %s\n ", product.getname());
         System.out.printf("product ID: %s \n", product.getitem());
         System.out.printf("Unit Price: %s \n", moneyFormat.format(product.getprice()));
         System.out.printf("units in Stock: %s \n", product.getstock());
         System.out.printf("Total product Value: %s \n", moneyFormat.format(product.getpValue()));
         System.out.printf("Restocking fee: %s \n", moneyFormat.format(product.getreStkfee()));
         System.out.printf("Inventory Value: %s \n", iValue);
    }/*Beginning of method main*/
    public static void main(String[] args)
    {/*Message*/
         /*Means for retrieving and storing new data input into inventory program*/
    InventorySystem6 JTableImageCreator = new InventorySystem6();
    JTableImageCreator.displayProductInfo();
    JTableImageCreator.inputProductInfo();
    class Product
    /*Declaration of and default value of specified variables*/
    //private Product products[] = new Product[100];
    private String item;
    String name;
    private double stock;
    private double price;
    private double pValue;
    private double reStkfee;
    //private String productNames[] = new String[1000]; //declaration of array "productNames" to store Product Names
    private double iValue;
    /*method defining the get and set values of each individual variable*/
    public String getname()
    {/*Mean for storing and retrieving input of name*/
    return name;
    }/*Means for setting the product name*/
    public void setname(String name)
    {/*null pointer argument exception defining metod for obtainng product name*/
    this.name = name;
    }/*Means for getting the units identifcation number inputted by the user*/
    public String getitem()
    {/*Means for returning the user input*/
    return item;
    }/*Means for setting the units identifcation */
    public void setitem(String item)
    {/*null pointer argument exception for setting the product identification number*/
    this.item = item;
    }/*Means for getting the units value input*/
    public double getstock()
    {/*Means for returning the variable of the units*/
    return stock;
    }/*Means for setting the units value*/
    public void setstock(double stock)
    this.stock = stock;
    public double getprice()
    {/*Means for returning the dollar value of the price of the unit(s)*/
    return price;
    }/*Means for setting and requesting user to input + dollar amt*/
    public void setprice(double price)
    this.price = price ;
    }/*Means for setting the value of the total product value*/
    public void setpValue(double pValue)
    this.pValue = pValue+(price*stock);
    }/*Means for getting the value of the product*/
    public double getpValue()
    {/*Means for returning the value*/
         return pValue;
    }/*Means for getting the TtlInventoryValue of products entered*/
    public void setiValue(double iValue)
    {/*Condition Statement*/
              this.iValue=iValue;
    public double getiValue()
              return iValue;
    public void setreStkfee(double reStkfee)
         this.reStkfee=stock*price*1.05;
    /*Means for setting restockin fee of the total products*/
    public double getreStkfee()
    {/*Means for calculating the restocking fee of each products units nStock*/
                   return reStkfee;
    }/*Method for string the elements in [i] for display*/
    public String toString()
         {/*Means for returning defined string of elements in [i]*/
              return "Product{" +
    "item="+ item +
    ", name="+ name +
    ", stock="+ stock +
    ", price="+price +
    ", pValue="+pValue +
    ", reStkfee="+ reStkfee +
    ", iValue="+iValue+     
    }/*End set and get method*/
    }/*End of class Product*/
    /*Delcaration of the class type sortproductNames*/                    
    class sortproductNames extends Product
    {/*Declaration of the variable productName*/
    protected String name;
    /*Means for setting and getting values of the variable productName*/
    public void setname(String name)
    this.name = name;
    public String getname()
    return name;
    public int compareTo(Object object)
    { // for sorting by product name
    Product anotherProduct = (Product) object;
    return name.compareTo( anotherProduct.name);
                   g.drawImage(image,0,0,200,50,0,0,image.getWidth(null), image.getHeight(null),null);
              else;
                   g.drawString("O2K", 10,10);
    * @(#)InventoryGUIFrame.java
    * @author
    * @version 1.00 2008/2/2
    package components;
    import java.io.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.imagio.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.ImageIcon;
    import javax.swing.event.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.text.*;
    import java.awt.*;
    * FormattedTextFieldDemo.java requires no other files.
    * It implements a mortgage calculator that uses four
    * JFormattedTextFields.
    public class InventoryGUIPanelFrameTextArea extends JFrame
    String productName;
    String itemNumber;
    double unitPrice;
    double unitStock;
    //Labels to identify the fields
    private JLabel productNamelabel;
    private JLabel itemNumberlabel;
    private JLabel unitPricelabel;
    private JLabel unitStocklabel;
    //Fields for data Entry     
    private JTextField productNameField;
    private JTextField itemNumberField;
    private JTextField unitPriceField;
    private     JTextField unitStockField;
    private Product[] products;
    private int unitStock;
    private int currentIndex=0;
    //Adding the JButtons
    JButton firstButton;
    JButton nextButton;
    JButton previousButton;
    JButton searchButton;
    JButton addButton;
    JButton deleteButton;
    JButton saveButton;
    //Constructor          
    public InventoryGUIPanelFrameTextArea()
    super("Welcome To The Inventory Program");
    this.products = products;
    this.numOfProducts = products;
    JFrame JPanel = new JFrame();
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLayout(new GridLayout());
    showLogo();
    showLabels();
    showInputFields();
    showButtons();
    public void showLogo()
    O2K myLogo = new O2K();
    this.add(myLogo);
    public void showLabels()
    JPanel panel = new JPanel();
    panel.add(new JLabel("PRODUCT NAME"));
    panel.add(new JLabel("ITEM NUMBER"));
    panel.add(new JLabel("UNIT PRICE"));
    panel.add(new JLabel("UNITS IN STOCK"));
    this.add(panel);
    public void showInputFields()
    itemNumber =new JTextField(5);
    itemNumber.setEditable(false);
    productName= new JTextField(10);
    productName.setEditable(false);
    unitPrice= new JTextField(5);
    unitPrice.setEditable(false);
    unitStock = new JTextField(10);
    unitStock.setEditable(false);
    panel.setEditable(false);
    panel.add(itemNumber);
    panel.add(productName);
    panel.add(unitPrice);
    panel.add(unitStock);
    this.add(panel);
    public void showButtons()
    JPanel panel = new JPanel();
    first = new JButton("First");
    next = new JButton("Next");
    previous = new JButton("Previous");
    add = new JButton ("Add");
    delete = new JButton ("Delete");
    search = new JButton ("Search");
    save = new JButton ("Save");
    panel.add(first);
    panel.add(next);
    panel.add(previous);
    panel.add(add);
    panel.add(delete);
    panel.add(search);
    panel.add(save);
    panel.add(this);
    ButtonActionHandler handler = new ButtonActionHandler();
    first.addActionListener(handler);
    next.addActionListener(handler);
    previous.addActionListener(handler);
    add.addActionListener(handler);
    delete.addActionListener(handler);
    search.addActionListener(handler);
    save.addActinListener(handler);
    this.add(panel);
    setFields(0);
    protected void paintComponent (Graphics g)
    public void setFields(int i)
    setItemNumber(i);
    setProductName(i);
    setUnitPrice(i);
    setUnitStock(i);
    public void setItemNumber( int i)
    itemNumber.setText(products[i].getItemNumber());
    public void setProductName(int i)
    productname.setText(products[i].getProductName());
    public void setUnitPrice( int i)
    unitPrice.setText(String.valueOf(products[i].getunitPrice()));
    public void setUnitStock(int i)
    unitStock.setText(String.valueOf(products[i].getunitStock()));
    private class ButtonActionHandler implements ActionListener
    public void actionPerformed(ActionEvent event)
    if(event.getSource()==first)
    currentIndex=0;
    setFields(currentIndex);
    else if(event.getSource()==next)
    currentIndex++;
    if(currentIndex==unitStock);
    currentIndex--;
    setFields(currentIndex);
    else if (event.getSource()==previous)
    currentIndex--;
    if(curentIndex < 0)
    currentIndex=0;
    setFields(currentIndex);
    else if(event.getSource()==last)
    currentIndex = unitStock -1;
    setFields(currentIndex);
    else if(event.getSource()==add)
    currentIndex = productName ++;
    setFields(currentIndex);
    else if(event.getSource()==delete)
    currentIndex= productName -1;
    setFields(currentIndex);
    else if (event.getSource()==search)
    currentIndex=productName ++;
    setFields(currentIndex);
    else if (event.getSource()==save)
    currentIndex=productName ++;
    setFields(currentIndex);
    public static void main(String args[])
    JFrame mainFrame = new JFrame();
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setSize(400,300);
    mainFrame.setVisible(true);
    class InventorySystem6
    {     /*Declaration of products[] and the maximum storing capacity*/
    private Product products[] = new Product[MAX_NUM_OF_PRODUCTS];
    /*Prompts user to make another selection or exit program*/
    private static final String STOP_COMMAND = "stop";
         /*parameters defining maximun numbers of products available for storing in [i]*/
    private static final int MAX_NUM_OF_PRODUCTS = 100;
    /*Declaration of the variables */
    String name;
    String item;
    double stock;
    double price;
    double reStkfee=1.05;
    double pValue;
    double iValue;
    public InventorySystem6()
         /*Empty Constructor*/
    }/*Beginning of product input by the user*/
    public void inputProductInfo()
    {     /*Declaration of currency format*/     
                   DecimalFormat Currency = new DecimalFormat();
                   Scanner input = new Scanner(System.in);
                   /*Beginning of the Loop*/
                   JOptionPane.showMessageDialog(null,"Welcome to the Inventory Program\n","Welcome to the Inventory Program\n",
                   JOptionPane.PLAIN_MESSAGE);               
                   for(int i = 0; i<MAX_NUM_OF_PRODUCTS ; i++)
                   name = JOptionPane.showInputDialog( "What is the Product Name? ");
                   if(name.equalsIgnoreCase("stop"))
                   break;
         String item = JOptionPane.showInputDialog("Enter the products ID");
         String priceStr =JOptionPane.showInputDialog("Enter the products price");
         double price=Double.parseDouble(priceStr);
                   String stockStr=JOptionPane.showInputDialog("Enter the units in stock " );
                   double stock = Double.parseDouble(stockStr);          
                   double sum=price*stock;
              JOptionPane.showMessageDialog(null,"The product value is:"+sum, "pValue",
              JOptionPane.PLAIN_MESSAGE);
                   /* JOptionPane.showMessageDialog(null,"The Product Name is:"+productName, "productName"
                   ,"\n","The Product Id is "+productId,"Product ID"
                        ,"\n","The Unit Price is"+unitPrice,"Unit Price"
                             ,"\n","The Units In Stock is"+unitStock,"UnitStock"
                                  ,"\n","The Product Value is"+productValue, "productValue"
                                       ,"\n","The Restocking Fee is "+reStockfee,"Restock Fee"
                                            ,"\n","The Inventory Value is"+inventoryValue,"Inventory Value"
                                                 ,"\n","The Inventory Restock Fee is"+reStockfee,"Restock Fee"
                                                      ,"\n",JOptionPane.PLAIN_MESSAGE);*/
              //Product products[] = new Product[100];
                   products[i] = new Product();
                   products[i].setItemNumber(itemNumber);
                   products[i].setPrdocutName(productName);
                   products[i].setUnitPrice(unitPrice);
                   products[i].setUnitStock(unitStock);
                   products[i].setProductValue(sum);
                   products[i].setReStkfee(reStkfee);
                   inventoryValue += sum + products[i].getreStkfee();
    public void displayProductInfo()
    { /*Initialization of the variable total inventory value*/
    NumberFormat moneyFormat = NumberFormat.getCurrencyInstance();
    for(int i = 0; i<MAX_NUM_OF_PRODUCTS ; i++)
              Product product = products[i];
              if(product==null)
              System.out.println(products[i]);
                   break;
         System.out.printf("product name: %s\n ", product.getproductName());
         System.out.printf("product ID: %s \n", product.getitemNumber());
         System.out.printf("Unit Price: %s \n", moneyFormat.format(product.getunitPrice()));
         System.out.printf("units in Stock: %s \n", product.getunitStock());
         System.out.printf("Total product Value: %s \n", moneyFormat.format(product.getproductValue()));
         System.out.printf("Restocking fee: %s \n", moneyFormat.format(product.getreStkfee()));
         System.out.printf("Inventory Value: %s \n", inventoryValue);
    }/*Beginning of method main*/
    public static void main(String[] args)
    {/*Message*/
         /*Means for retrieving and storing new data input into inventory program*/
    InventorySystem6 JTableImageCreator = new InventorySystem6();
    JTableImageCreator.displayProductInfo();
    JTableImageCreator.inputProductInfo();
    class Product
    /*Declaration of and default value of specified variables*/
    //private Product products[] = new Product[100];
    protected String itemNumber;
    protected String prodcutname;
    protected double unitStock;
    protected double unitPrice;
    protected double productValue;
    protected double reStkfee;
    protected double inventoryValue;
    //private String productNames[] = new String[1000]; //declaration of array "productNames" to store Product Names
    /*method defining the get and set values of each individual variable*/
    public String getproductName()
    {/*Mean for storing and retrieving input of name*/
    return productName;
    }/*Means for setting the product name*/
    public void setProductName(String productName)
    {/*null pointer argument exception defining metod for obtainng product name*/
    this.productName = ProductName;
    }/*Means for getting the units identifcation number inputted by the user*/
    public String getitemNumber()
    {/*Means for returning the user input*/
    return itemNumber;
    }/*Means for setting the units identifcation */
    public void setItemNumber(String itemNumber)
    {/*null pointer argument exception for setting the product identification number*/
    this.itemNumber = itemNumber;
    }/*Means for getting the units value input*/
    public double getunitStock()
    {/*Means for returning the variable of the units*/
    return unitStock;
    }/*Means for setting the units value*/
    public void setUnitStock(double unitStock)
    this.unitStock = unitStock;
    public double getunitPrice()
    {/*Means for returning the dollar value of the price of the unit(s)*/
    return unitPrice;
    }/*Means for setting and requesting user to input + dollar amt*/
    public void setUnitPrice(double unitPrice)
    this.unitPrice = unitPrice ;
    }/*Means for setting the value of the total product value*/
    public void setProductValue(double prodcutValue)
    this.prodcutValue = unitPrice*unitStock;
    }/*Means for getting the value of the product*/
    public double getproductValue()
    {/*Means for returning the value*/
         return productValue;
    }/*Means for getting the TtlInventoryValue of products entered*/
    public void setInvetnoryValue(double invetnoryValue)
    {/*Condition Statement*/
              this.inventoryValue=inventoryValue;
    public double getinvetotyValue()
              return productValue;
    public void setReStkfee(double reStkfee)
         this.reStkfee=stock*price*1.05;
    /*Means for setting restockin fee of the total products*/
    public double getreStkfee()
    {/*Means for calculating the restocking fee of each products units nStock*/
                   return reStkfee;
    }/*Method for string the elements in [i] for display*/
    public String toString()
         {/*Means for returning defined string of elements in [i]*/
              return "Product{" +
    "itemNumber="+ itemNumber +
    ", productName="+ productName +
    ", unitStock="+ unitStock +
    ", unitPrice="+unitPrice +
    ", productValue="+prodcutValue +
    ", reStkfee="+ reStkfee +
    ", inventoryValue="+inventoryValue+     
    }/*End set and get method*/
    }/*End of class Product*/
    /*Delcaration of the class type sortproductNames*/                    
    class sortproductNames extends Product
    {/*Declaration of the variable productName*/
    protected String name;
    /*Means for setting and getting values of the variable productName*/
    public void setProdcutName(String productName)
    this.productName = productName;
    public String getproductName()
    return productName;
    public int compareTo(Object object)
    { // for sorting by product name
    Product anotherProduct = (Product) object;
    return productName.compareTo( anotherProduct.productName);
         class myGraphics extends component          
              private BufferedImage image;
              private boolean imageFound = true;
              public myGraphics()
                   super();
                   try
                        image=ImageIO.read(new File("Logo.jpg"));
                   catch(IOException x)
                        x.printStackTrace();
                        imageFound = false;
              public void paint(Graphics g)
                   g.drawImage(image,0,0,200,50,0,0,image.getWidth(null), image.getHeight(null),null);
              else;
                   g.drawString("O2K", 10,10);

  • Problem with Unix version of Reports

    When I run the report(filenam.rep) off of
    my P.C., it works fine. Then when I transfer
    it over to Unix and run the report, I get
    some of the values in my report copied into
    places they don't belong. For instance,
    I have a value for the last row and last column in my report that gets copied to the
    first value in the last column of every page
    except for the first page. The proper value
    doesn't appear and it gets replaced by this
    value instead. I am running Reports 2.5 on
    both my P.C. as well as Unix. My P.C. is
    an NT 4.0 workstation. My command line on Unix looks like this:
    r25runm report=${report} userid=reitprod/namrem batch=YES paramform=NO \
    buffers=1000 destype=file desname=${TEMP}.lis \
    ${PARAMETER_STRING}
    I also have Designer 6.0 installed on my P.C.
    I recently installed a patch to fix a problem
    with formatting in Reports 6.0. I am wondering whether the patch might have something to do with incompatibility between
    Reports 2.5 on my P.C. and Reports 2.5 on
    the Unix system.
    null

    Hello,
    We need more information in order to help. How are you requesting the report (command line, URL, ?). What file is it asking for?
    Regards,
    The Oracle Reports Team --skw
    null

  • Need help!!!! GUI problems with netbeans

    i have a problem with the interface i created using netbeans.
    i created a JFrame, inside it a JDesktopPane, and inside that 3 JInternalFrames. the problem is in one of the JinternalFrames, i have 4 radio buttons which i forgot to add to a buttongroup and whenever i try to do that, the GUI doesn't work anymore. The bigger problem is that if i undo the changes, the thing still doesn't work and i have to copy my backup project folder over the one i work on to get an output.
    i tried to edit the source code to add the 4 buttons to a button group but netbeans won't let me since i created the buttons thru it not by writing it myself
    please i really need help with this and i hope its a stupid thing i'm just overlooking.
    If u need the code, i will gladly post it.
    thanks in advance

    if you're not using a netbeans-specific layout manager, copy the working code
    into notepad, make the changes, then compile and run from the command prompt.
    if all works OK, dump netbeans

  • GUI problem with iCal

    Suddenly I am experiencing problems with iCal crashing after I try to drag items into the TO DO column. The calender grid suddenly shows through the TO DO area and everything comes to a halt. Any suggestions.
    Dual 450 G4   Mac OS X (10.4.8)  

    When I try to do anything involving the "to do"'s things just stop working. Here is where it gets strange. If I transfer via iSync a "to do" from my palm pilot to iCal the "to do" will not show up in iCal. BUT then when I sync Omni Outliner with iCal it will pull the "to do" from somewhere in iCal and put it in the "in box" in Omni Outliner. What in the heck is going on here?

  • URGENT!! problems with Unix command, please help

    I am trying to use the following Unix command and I keep getting error messaages from stdError. However if I run the same command from the command line it works perfectly. For some reason when I run the command from inside the program it thinks the append symbol ">>" is another file.
    String command = " cat /users/02/wjoc1/Test/list.mod >> /users/02/wjoc1/Test/Blacklist ";
    Process p = Runtime.getRuntime().exec(command);
    The error get is :
    /bin/cat: >>: No such file or directory
    Any help would be greatly appreciated

    The better solution for this problem is write a shell script for the action you wnat to perform and execute it using the runtime.exec().In your case just cut and paste cat /users/02/wjoc1/Test/list.mod >> /users/02/wjoc1/Test/Blacklist in to a file and save it. use that file as a argument for the exec method it will work.
    cheers
    R.Karuna

  • GUI problem with textfields, reading in text from a textpad

    Alright well, here is my problem. I am having trouble with aliging the textfields to how I want it but I can't get it to come out how I want it. First, I am trying to figure out how to have the some text appear right above a textfield. Example:
    File Name
    I can't get it appear that way, the text appears side to side with the textfield. And the other problem is how can I made the size of textfield to how I want it. I was reading that you have to assign a specfic number in the text field.
    This is the code I have so far:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class IP_Header extends JApplet
    private JTextField lookUp, showInfo;
    private JButton analyze;
    private JLabel msg;
    public void init()
    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(3,2));
    p1.add(new JLabel("File Name"));
    p1.add(lookUp = new JTextField());
    p1.add(analyze = new JButton("Analyze"));
    p1.add(showInfo = new JTextField());
    msg = new JLabel(" ");
    Container cp = getContentPane();
    cp.setLayout(new BorderLayout());
    cp.add(p1, BorderLayout.NORTH);
    With this what I am tryin to do is as follows:
    File Name
    * "TextField" * *
    **************** * This is a textfield where I am just going to
    * have some text appear in it
    * "Button" * *
    Thank you for your help. I hope you can help me. I haven't done java for a quite a while. Thanks again

    Thanks for help ... really helpful and understanding. I am trying to read a file from the computer which has some numbers in it and I want those numbers to be shown on the textfields individually. The numbers are in a notepad file and they are .... 4, 5, 200, 780, 1, 0, 0, 12, 6, 0, 129, 24, 21, 44, 133, 62, 159, 7. I got the program to compile and everything by adding the code that I believe should work . But whenever I put the file name in and press the button analyze ... it gives me a error saying "Exception: access denied (java.io.FilePermission c:\TCP read) .. can't quite get it ...here the code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    public class IP_Header extends JApplet
        private JTextField lookUp, showInfo;
        private JButton analyze;
        private JLabel msg;
        public void init()
            GridBagLayout gridbag = new GridBagLayout();
            JPanel p1 = new JPanel(gridbag);
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.gridwidth = gbc.REMAINDER;     // one component per row
            gbc.insets = new Insets(0,20,5,0); // spacer [top, left, bottom, right]
            gbc.weightx = 1.0;                 // allows horizontal placement
            gbc.anchor = gbc.WEST;             // align left
            p1.add(new JLabel("File Name"), gbc);
            p1.add(lookUp = new JTextField(16), gbc);
            p1.add(analyze = new JButton("Analyze"), gbc);
            p1.add(showInfo = new JTextField(16), gbc);
            // center section of content pane border layout
            // First Panel - 2 rows, 4 columns
            JPanel p2 = new JPanel(gridbag);
            gbc.insets = new Insets(2,0,0,0);
            gbc.anchor = gbc.CENTER;
            JTextField verText = new JTextField(8);
            JTextField HLENText = new JTextField(8);
            JTextField ServiceType = new JTextField(8);
            JTextField TotalText = new JTextField(8);
            gbc.gridwidth = 1;
            p2.add(new JLabel("VER"), gbc);
            p2.add(new JLabel("HLEN"), gbc);
            p2.add(new JLabel("Service Type"), gbc);
            gbc.gridwidth = gbc.REMAINDER;
            p2.add(new JLabel("Total Length"), gbc);
            gbc.gridwidth = 1;
            p2.add(verText, gbc);
            p2.add(HLENText, gbc);
            p2.add(ServiceType, gbc);
            gbc.gridwidth = gbc.REMAINDER;
            p2.add(TotalText, gbc);
            // Second Panel - 4 rows, 3 columns
            JPanel p3 = new JPanel(gridbag);
            JTextField fragText = new JTextField(8);
            JTextField flags = new JTextField(8);
            JTextField fragOffText = new JTextField(8);
            gbc.insets = new Insets(5,0,0,0);
            gbc.gridwidth = 1;
            p3.add(new JLabel("Fragmentation ID"), gbc);
            p3.add(new JLabel("Flags"), gbc);
            gbc.gridwidth = gbc.REMAINDER;
            p3.add(new JLabel("Fragmentation Offset"), gbc);
            gbc.insets = new Insets(2,0,0,0);
            gbc.gridwidth = 1;
            p3.add(fragText, gbc);
            p3.add(flags, gbc);
            gbc.gridwidth = gbc.REMAINDER;
            p3.add(fragOffText, gbc);
            JTextField ttlText = new JTextField(8);
            JTextField protocolText = new JTextField(8);
            JTextField headText = new JTextField(8);
            gbc.insets = new Insets(5,0,0,0);
            gbc.gridwidth = 1;
            p3.add(new JLabel("TTL"), gbc);
            p3.add(new JLabel("Protocol"), gbc);
            gbc.gridwidth = gbc.REMAINDER;
            p3.add(new JLabel("HeaderChecksum"), gbc);
            gbc.insets = new Insets(2,0,0,0);
            gbc.gridwidth = 1;
            p3.add(ttlText, gbc);
            p3.add(protocolText, gbc);
            gbc.gridwidth = gbc.REMAINDER;
            p3.add(headText, gbc);
            // Third Panel - 4 rows, 4 columns
            JPanel p4 = new JPanel(gridbag);
            JTextField sIP1text = new JTextField(4);
            JTextField sIP2text = new JTextField(4);
            JTextField sIP3text = new JTextField(4);
            JTextField sIP4text = new JTextField(4);
            gbc.insets = new Insets(5,0,0,0);
            gbc.gridwidth = 1;
            p4.add(new JLabel("SourceIP"), gbc);
            p4.add(new JLabel(" "), gbc);
            p4.add(new JLabel(" "), gbc);
            gbc.gridwidth = gbc.REMAINDER;
            p4.add(new JLabel(" "), gbc);
            gbc.insets = new Insets(2,0,0,0);
            gbc.gridwidth = 1;
            p4.add(sIP1text, gbc);
            p4.add(sIP2text, gbc);
            p4.add(sIP3text, gbc);
            gbc.gridwidth = gbc.REMAINDER;
            p4.add(sIP4text, gbc);
            JTextField dIP1text = new JTextField(4);
            JTextField dIP2text = new JTextField(4);
            JTextField dIP3text = new JTextField(4);
            JTextField dIP4text = new JTextField(4);
            gbc.insets = new Insets(5,0,0,0);
            gbc.gridwidth = 1;
            p4.add(new JLabel("Destination IP"), gbc);
            p4.add(new JLabel(" "), gbc);
            p4.add(new JLabel(" "), gbc);
            gbc.gridwidth = gbc.REMAINDER;
            p4.add(new JLabel(" "), gbc);
            gbc.insets = new Insets(2,0,0,0);
            gbc.gridwidth = 1;
            p4.add(dIP1text, gbc);
            p4.add(dIP2text, gbc);
            p4.add(dIP3text, gbc);
            gbc.gridwidth = gbc.REMAINDER;
            p4.add(dIP4text, gbc);
            JPanel panel = new JPanel(gridbag);
            gbc.fill = gbc.HORIZONTAL;
            gbc.insets = new Insets(0,5,0,5);
            panel.add(p2, gbc);
            panel.add(p3, gbc);
            panel.add(p4, gbc);
            msg = new JLabel(" ");
            Container cp = getContentPane();
            cp.setLayout(new BorderLayout());
            cp.add(p1, "North");
            cp.add(panel);
            setSize(450,375);
             analyze.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        String array[] = new String[18];
                        String blankString = new String();
                        String tempString = lookUp.getText();
                        showInfo.setText(array[0]);
                        try
                             FileReader fr = new FileReader(tempString);
                             BufferedReader br = new BufferedReader(fr);
                             String line = br.readLine();
                             StringTokenizer st = new StringTokenizer (line,",");
                             for (int i=0; i<=18; i++)
                                  array[i] = st.nextToken().trim();
                        catch(Exception f)
                             System.out.println("Exception: " + f.getMessage());
    }

  • [SOLVED] Problem with UNIX permissions

    Hello everyone.
    It seems I don't have the permission to write in a folder but I don't understand why :
    olivier:~$ ls -l /srv/
    total 8
    dr-xr-xr-x 2 root ftp 4096 Feb 14 10:16 ftp
    drwxrwxr-x 2 http http 4096 Feb 22 16:53 http
    olivier:~$ cat /etc/group | grep http
    http::33:olivier
    olivier:~$ cd /srv/http
    olivier:/srv/http$ touch myfile
    touch: cannot touch `myfile': Permission denied
    So /srv/http is owned by user http of group http, with write permission for group members.
    I am part of the http group but I can't create (or delete) a file in /srv/http.
    Is this behaviour normal?
    Thanks!
    Last edited by pokraka (2010-02-23 00:55:32)

    ewaller wrote:Have you logged out and back in since becoming a member of group http?
    I guess that was the problem since now after rebooting it works!
    Thanks.
    Last edited by pokraka (2010-02-23 00:56:02)

  • Problem With UNIX command in ODI Environment.

    A procedure is used in our package which involves moving a file from a folder to another in a UNIX server.
    The procedure uses an OS command - 'os.system' to execute unix command.
    The unix command is a grep command which seems to work fine when executed alone.
    But when this procedure is executed ,it fails.
    The following code raises an error and the procedure fails.:
    if os.system(cmd) <> 0:
    raise "command fails","see agent output for details";
    Whenever we are trying to reverse,we get "file not Found " error.
    We tried to execute the jython code by placing the files in local directories. The same error appears both when the file is in local and when it is in a remote directory.
    This is the error we get:
    org.apache.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
    File "<string>", line 20, in ?
    HeaderCmd failed:: See agent output for details      at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
         at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)      at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execSrcScriptingOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlS.treatTaskTrt(SnpSessTaskSqlS.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)      at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.g.y(g.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Unknown Source)

    Hi,
    The unix command is a grep command which seems to work fine when executed alone. :-
    I guess you executed this from your Unix server , so it work fines.
    And when you are trying to execute outside from this (using ODI) , its failing , right ?
    Can you please check the permission settings for that script file (sh).
    Please try by giveing the full permission (specifically execution permission) for all users connecting from other machines.
    This can be one of the reason for the failure .
    please let me know if this is not working
    Regards,
    Rathish

  • GUI problem with JTable..( bug_id=4940522)

    its found that the mouse event is not recognised on empty table when using with java 1.4.2. Please specify if there is any chnge done for mouse event capture for table from java 1.3.1 to java 1.4.2.
    actually its a bug in java 1.4.2 ( ref. bug_id=4940522 )
    here is the code reference..
    public class TableEditor extends JPanel
    implements ListSelectionListener, Selector, Editor
    private JTable myTable;
    private JPopupMenu myPopup;
    private Vector myActions;
    private Vector myListeners;
    public TableEditor(String anAssociation, Editor anEditor, int type)
    super(new GridLayout(1,1));
    myListeners = new Vector();
    myActions = new Vector();
    myPopup = new JPopupMenu();
    myTable = new JTable();
    myTable.getSelectionModel().addListSelectionListener(this);
    myTable.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent me)
    if ((me.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
    // Update actions in case ListSelectionModel are out of sync.
    for (int i = 0; i < myActions.size(); i++)
    Object o = myActions.elementAt(i);
    if (o instanceof SelectorAction)
    ((SelectorAction)o).check();
    myPopup.show(myTable, me.getX(), me.getY());
    // Added mouse listener to JTableHeader
    // This is a temporary solution to open popup menu on blank table,
    // as in Java 1.4.2 no mouse event captured on blank table.
    // So for now we will capture the event from the table header.
    JTableHeader myTableHeader = myTable.getTableHeader();
    myTableHeader.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent me)
    if ((me.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
    // Update actions in case ListSelectionModel are out of sync.
    for (int i = 0; i < myActions.size(); i++)
    Object o = myActions.elementAt(i);
    if (o instanceof SelectorAction)
    ((SelectorAction)o).check();
    myPopup.show(me.getComponent(), me.getX(), me.getY());
    The solution given is temporary ( adding JTableHeader component)..
    we want to retain the same functionality .. mouse event should get captured on empty table only..

    its found that the mouse event is not recognised on empty table when using with java 1.4.2. Please specify if there is any chnge done for mouse event capture for table from java 1.3.1 to java 1.4.2.
    actually its a bug in java 1.4.2 ( ref. bug_id=4940522 )
    here is the code reference..
    public class TableEditor extends JPanel
    implements ListSelectionListener, Selector, Editor
    private JTable myTable;
    private JPopupMenu myPopup;
    private Vector myActions;
    private Vector myListeners;
    public TableEditor(String anAssociation, Editor anEditor, int type)
    super(new GridLayout(1,1));
    myListeners = new Vector();
    myActions = new Vector();
    myPopup = new JPopupMenu();
    myTable = new JTable();
    myTable.getSelectionModel().addListSelectionListener(this);
    myTable.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent me)
    if ((me.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
    // Update actions in case ListSelectionModel are out of sync.
    for (int i = 0; i < myActions.size(); i++)
    Object o = myActions.elementAt(i);
    if (o instanceof SelectorAction)
    ((SelectorAction)o).check();
    myPopup.show(myTable, me.getX(), me.getY());
    // Added mouse listener to JTableHeader
    // This is a temporary solution to open popup menu on blank table,
    // as in Java 1.4.2 no mouse event captured on blank table.
    // So for now we will capture the event from the table header.
    JTableHeader myTableHeader = myTable.getTableHeader();
    myTableHeader.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent me)
    if ((me.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
    // Update actions in case ListSelectionModel are out of sync.
    for (int i = 0; i < myActions.size(); i++)
    Object o = myActions.elementAt(i);
    if (o instanceof SelectorAction)
    ((SelectorAction)o).check();
    myPopup.show(me.getComponent(), me.getX(), me.getY());
    The solution given is temporary ( adding JTableHeader component)..
    we want to retain the same functionality .. mouse event should get captured on empty table only..

  • Problem with Adobe Reader Plug-In (7, 8, and 9) on Windows XP

    We are experiencing a problem with the Adobe Reader plug-in and viewing documents hosted at our site.  The problem seems to happen with larger (over 5 MB) PDF files enabled for fast web viewing.  The problem never happens when viewing PDF image only files which are not enabled for fast web viewing.  The problem happens inside and outside our firewall, so it is not a firewall problem.  My organization has been hosting PDF files to the web at least all this decade, and this is the first time we have experienced and documented this problem on this scale.  We have ruled out the program creating the PDF file is causing the problem as I have eight sample PDF files created and modified by a variety of programs exhibiting the same issue.
    www.osti.gov/servlets/purl/945213-1jsnyF/
    Adobe Capture 3.0 / Adobe PDF Library 4.0
    www.osti.gov/servlets/purl/948577-R7PH1d/
    Adobe Capture 3.0 / Adobe PDF Library 4.0
    www.osti.gov/servlets/purl/959040-nPWEVJ/
    Adobe Acrobat 8.15 / Abbyy Recognition Server
    www.osti.gov/servlets/purl/961608-uR6ukp/
    PaperPort 10.0 / Abbyy Recognition Server
    www.osti.gov/servlets/purl/963955-8wBmHp/
    Adobe Acrobat 8.15 / Abbyy Recognition Server
    www.osti.gov/servlets/purl/964418-Ingskm/
    Adobe Acrobat 7.1 / Adobe Acrobat 7.1 Paper Capture Plug-in
    www.osti.gov/servlets/purl/963372-yhIUhW/
    Adobe Acrobat 7.08 / Abbyy Recognition Server
    www.osti.gov/servlets/purl/965399-4MBPMy/
    Xerox WorkCentre 7345 / Abbyy Recognition Server
    I can reproduce the problem with Internet Explorer 8.0.6 and Firefox 3.5.4 using Adobe Acrobat Plug-In 7.0.9.50 running on Windows XP Professional SP3.  Others have reproduced the problem with 8 and 9 versions of the plug-in on Windows XP Professional and Home.  Oddly, no one has been able to reproduce the problem with Unix/Linux versions of the plug-in or third party plug-ins.  This points to it being something wrong with Adobe Reader.
    The problem is when I attempt to view one of the eight PDFs in my browser, I can severely stall or lock it up if I attempt to view more than the first page before the whole document downloads.  Sometimes if you wait it out, the browser will unlock, but not display text on the pages.  Sometimes if you wait for the whole document to load before switching pages, it works.  Sometimes you can start switching pages and the document will not lock up at all.  All eight documents can be viewed without issue if downloaded to the PC's hard drive and then viewed with Adobe Acrobat 7.0.
    Can anyone point me to a technical document or reason why we would be experiencing this issue?  Even better, does anyone know the solution to these issues?
    Any help will be much appreciated.

    I looked at a few documents. They appear to be scans and scans that have been OCRd. It is also likely they have not been optimized for page view. This means that the document has to be fully downloaded before viewed. That means the browser may appear to freeze until the entire document is downloaded. Downloading the entire document appears to be a reasonable way to handle these files.

  • Design Problem with GUI sub vi

    Hello community,
    in general, I would like to separate the GUI from the data, but I get
    a problem with this design approach in LabView:
    I often have sub VIs that are supposed to control something.
    Therefore, these VIs consist of a control loop. A GUI window should
    show the regulation process (showing how the tracking error is
    hopefully approaching zero etc.). As I said, this GUI should be a
    separate VI (separate from the control loop VI). Since the GUI has to
    be updated on each sample, it is clear that the GUI VI should be
    inside the control loop, and therefore, it should be a sub VI of the
    control loop VI.
    Now, the problem is that the control loop VI itsself is a sub VI
    because the whole regulation is just a subsystem of the whole program
    (The main VI doesn't have a GUI, but first starts a (GUI) input mask
    for the same reason: separate the GUI from the rest).
    But back to the GUI VI inside the control loop. I must check the 'Show
    Front Panel When Called' option. But I can't check the 'Close
    Afterwards if Originally Closed' option since the GUI VI would appear
    and disappear in the control loop - according to the loop's sample
    rate. However, if I don't check the 'Close Afterwards if Originally
    Closed' option then the GUI VI will continue to show, even after the
    control process is finished.
    So in other words: I need the possiblity to close the GUI VI
    programatically, after the control process is finished.
    Any ideas?
    Regards
    Johannes

    Hi tmh,
    thanks for your answer
    On Tue, 11 Nov 2003 10:26:32 -0600 (CST), tmh wrote:
    >I think you're on the wrong track trying to put your 'GUI VI' inside
    >your control loop. It might be a better design to have the control and
    >GUI handled by separate loops and use an appropriate method to pass
    >data between the two, e.g. a global variable to pass the setpoint from
    >GUI to control...
    I try to avoid globals. Now, suppose I had multiple unrelated control
    loops. I had to suppose a global variable for each of these
    subsystems. I already use globals for the GPIB device IDs. I wouldn't
    like more.
    >and a queue to pass readings from control to GUI. In
    >fact, you could even split the GUI into two loops: one to read user
    >input from the front pa
    nel controls and one to display data returned
    >by the control loop.
    But if I split the GUI: How can I view them simultaneously? The user
    must see input and output simultaneously, in one window.
    >You may find it's more convenient to make the GUI
    >the top-level VI and make the control loop a subVI of that (but
    >outside the GUI loops).
    Your approach sounds interesting. Is there a sample for this
    architecture in the examples?
    Anyway, I have to point out that I have several unrelated GUI windows
    in my application. There is no notion of a main GUI in my application.
    The control loop is just one feature of my application, so it doesn't
    make sense to use the control GUI as the top-level VI. At application
    startup a user input form is displayed (it also has some sort of menu
    selection). But even this window can't be toplevel since it provides
    an Option radio button (that shows and hides controls, accordingly) a
    CONTINUE button, and a STOP button which implies that the input
    form.vi must be
    in a loop.
    The problem is that I can't send messages to windows in LabView as I
    am used to in Win32/VC++.
    Johannes

  • Problem With ObjectSream and GUI

    Hi
    I had a problem with the sendBtn ActionListener. When i press the send button the application freeze and the button freeze pressed.
    But when i put some code to do the same think that send button should do, into the main method everything works fine. Any help?
    Thanks in advanced and sorry for my english
    //Some imports
    public class SampleCommunicationAgentGUI extends BaseCommunicationAgent {
         public SampleCommunicationAgentGUI(String name) {
              super(name);
              try {
                   connectToACS("127.0.0.1", 3333);
              } catch (IOException e) {
                   System.out.print("\nNetwork error while connecting to ACS ("
                             + e.getMessage() + ")");
              } catch (ClassNotFoundException e) {
                   System.out.print("\nNetwork error while connecting to ACS ("
                             + e.getMessage() + ")");
              frame = new SampleAgentFrame(name);
              frame.sendBtn.addActionListener(new java.awt.event.ActionListener() {
                   public void actionPerformed(java.awt.event.ActionEvent evt) {
                        KQML message = new KQML();
                        message.setSender(getName());
                        message.setReceiver(frame.receiverField.getText());
                        message.setContent(frame.contentField.getText());
                        message.setInReplyTo(frame.inReplyToField.getText());
                        message.setLanguage(frame.languageField.getText());
                        message.setOntology(frame.ontologyField.getText());
                        message.setPerformative(frame.perfomativeField.getText());
                        message.setReplyWith(frame.inReplayWithField.getText());
                        System.out.println(message.getTotalMsg());
                        try {
                             sendMessage(message); // A method of BaseCommunicationAgent
                        } catch (Exception e) {
                             e.printStackTrace();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.validate();
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
         public static SampleAgentFrame frame;
         public static void main(String[] args) {
              KQML message;
              SampleCommunicationAgentGUI agent = new SampleCommunicationAgentGUI("Chris");
              if (!agent.getACSStatus().equals(ACSStatus.CONNECTED)) {
                   System.out.println("\nERROR: Could not connect on ACS!");
                   return;
              /*If i put this code here everything works fine
                    * message = new KQML();
                    * agent.sendMessage(message);
              while (true) {
                   message = agent.getMessage();
                   frame.messageTextArea.append(message.getContent() + "\r\n");
         protected static class SampleAgentFrame extends JFrame {
              //Some variables
              public SampleAgentFrame(String name) {
                   setTitle(name);
                   initComponents(name);
               * Initializes the GUI.
              private void initComponents(String name) {
                   //Inits the GUI but is to big to post it.
    }And the BaseCommunicationAgent
    //Some imports
    public class BaseCommunicationAgent extends BaseAgent {
         public static enum ACSStatus {
              INITIALIZING, INITIALIZED, CONNECTING, CONNECTED
         private Socket socketACS;
         private ObjectOutputStream dataOut;
         private ObjectInputStream dataIn;
         protected ACSStatus statusACS;
         private KQML kqmlMessage;
         public BaseCommunicationAgent(String name) {
              super(name);
              statusACS = ACSStatus.INITIALIZING;
              socket = null;
              dataOut = null;
              dataOut = null;
              kqmlMessage = null;
              statusACS = ACSStatus.INITIALIZED;
         protected synchronized boolean connectToACS(String address, int port)
                   throws IOException, ClassNotFoundException {
              try {
                   statusACS = ACSStatus.CONNECTING;
                   socketACS = new Socket(address, port);
                   dataOut = new ObjectOutputStream(socketACS.getOutputStream());
                   dataIn = new ObjectInputStream(socketACS.getInputStream());
                   kqmlMessage = new KQML();
                   KQML message;
                   boolean isComment;
                   do {
                        message = (KQML) dataIn.readObject();
                        isComment = message.getPerformative().equals("comment");
                        if (isComment) {
                             System.out.println(message.getContent());
                   } while (isComment);
                   if (message.getPerformative().equals("identify")) {
                        kqmlMessage.resetMessage();
                        kqmlMessage.setPerformative("who-am-i");
                        kqmlMessage.setSender(getName());
                        dataOut.writeObject(kqmlMessage);
                        dataOut.flush();
                        dataOut.reset();
                        do {
                             message = (KQML) dataIn.readObject();
                             isComment = message.getPerformative().equals("comment");
                             if (isComment) {
                                  System.out.println(message.getContent());
                        } while (isComment);
                        if (message.getPerformative().equals("registered")) {
                             statusACS = ACSStatus.CONNECTED;
                        } else {
                             System.out.println(message.getContent());
                             socketACS.close();
                             statusACS = ACSStatus.INITIALIZING;
                   } else {
                        System.out.println(message.getContent());
                        socketACS.close();
                        statusACS = ACSStatus.INITIALIZING;
              } catch (IOException e) {
                   statusACS = ACSStatus.INITIALIZING;
                   throw e;
              } catch (ClassNotFoundException e) {
                   statusACS = ACSStatus.INITIALIZING;
                   throw e;
              return statusACS.equals(ACSStatus.CONNECTED);
         public ACSStatus getACSStatus() {
              return statusACS;
         protected synchronized void closeConnectionWithACS() { // Only the
                                                                               // dataOut.close()
              try {
                   dataOut.flush();
                   dataOut.close();
                   dataIn.close();
                   socketACS.close();
              } catch (IOException ex) {
                   ex.printStackTrace();
         protected synchronized void sendMessage(KQML message) throws IOException {
              dataOut.writeObject(message);
              dataOut.flush();
              dataOut.reset();
         protected synchronized KQML getMessage() {
              KQML message = new KQML();
              try {
                   message = (KQML) dataIn.readObject();
                   return message;
              } catch (IOException e) {
                   e.printStackTrace();
              } catch (ClassNotFoundException e) {
                   e.printStackTrace();
              return message;
    }

    Thanks for the answer. I take a look at Swing Worker but i have a few problems :
    1)The GUI doesn't freeze but nothing happens either.
    2) When i remove the sendMessage method and i put only a System.out.println(somethingToPrint); it works but only once. After i hit second time my send button nothing happens. Somewhere i read that works only once is that true or i misunderstood? And if yes how i can do it every time i press the send button?
    Could you take a look at my code?
    Thanks in advanced
    //Some imports
    public class SampleCommunicationAgentGUI extends BaseCommunicationAgent {
         public SampleCommunicationAgentGUI(String name) {
              super(name);
              try {
                   // agent.connectToREVE("127.0.0.1", 4444);
                   connectToACS("127.0.0.1", 3333);
              } catch (IOException e) {
                   System.out.print("\nNetwork error while connecting to ACS ("
                             + e.getMessage() + ")");
              } catch (ClassNotFoundException e) {
                   System.out.print("\nNetwork error while connecting to ACS ("
                             + e.getMessage() + ")");
                final SwingWorker worker =
                    new SwingWorker() {
                        @Override
                        protected KQML doInBackground() throws Exception {
                             KQML message = new KQML();
                             message.setSender(getName());
                             message.setReceiver(frame.receiverField.getText());
                             message.setContent(frame.contentField.getText());
                             message.setInReplyTo(frame.inReplyToField.getText());
                             message.setLanguage(frame.languageField.getText());
                             message.setOntology(frame.ontologyField.getText());
                             message.setPerformative(frame.perfomativeField.getText());
                             message.setReplyWith(frame.inReplayWithField.getText());
                             System.out.println(message.getTotalMsg());
                             sendMessage(message);
                             return message;
              frame = new SampleAgentFrame(name);
              frame.sendBtn.addActionListener(new java.awt.event.ActionListener() {
                   public void actionPerformed(java.awt.event.ActionEvent evt) {
                        try{
                             worker.execute();
                        } catch (Exception e) {
                             e.printStackTrace();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.validate();
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
         public static SampleAgentFrame frame;
         public static void main(String[] args) {
              KQML message;
              SampleCommunicationAgentGUI agent = new SampleCommunicationAgentGUI("Chris");
              if (!agent.getACSStatus().equals(ACSStatus.CONNECTED)) {
                   System.out.println("\nERROR: Could not connect on ACS!");
                   return;
              while (true) {
                   message = agent.getMessage();
                   frame.messageTextArea.append(message.getContent() + "\r\n");
         protected static class SampleAgentFrame extends JFrame {
              //Some variables
              public SampleAgentFrame(String name) {
                   setTitle(name);
                   initComponents(name);
               * Initializes the GUI.
              private void initComponents(String name) {
                   //Init components
    }

  • Problem with GUI in applet

    Hai to all,
    I am having a problem with GUI in applets
    My first class extends a JPanel named A_a
    import javax.swing .*;
    import java.awt.*;
    import java.awt.event.*;
    public class A_a extends JPanel
    JButton jb;
    JTextArea text;
    public A_a()
    setLayout(new FlowLayout());
    jb=new JButton("Click me");
    //add(jb);
    text=new JTextArea(5,20);
    add(text);
    public void text_appendText(String aa)
    System.out.println("I AM IN A_a");
    text.append(aa);
    text.revalidate();
    revalidate();
    /*public static void main(String ags[])
    A_a a = new A_a();
    JFrame frame=new JFrame();
    frame.getContentPane().add(a);
    frame.pack();
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) { System.exit(0); }
    frame.setSize(200,200);
    frame.show();
    and then I am using other class B_b which is an applet carries a exitsing panel (A_a) inside it .
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class B_b extends JApplet
    public A_a a;
    public void init()
    a=new A_a();
    getContentPane().add(a);
    public void text_appendText(String aa)
    final String aaa =aa;
    new Thread(new Runnable()
    public void run()
    a=new A_a();
    a.setBackground(new java.awt.Color(255,200,200));
    System.out.println("I AM IN B_b");
    a.text.append(aaa);
    a.text.revalidate();
    getContentPane().remove(a);
    resize(500,500);
    }).start();
    and the I am using the second applet C_c in which by performing a button action the old panel A_a should get removed and replace the new panel D_a (which is not here )in the applet B_b with all other components(namely button , text fields etc)
    import javax.swing .*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.util.*;
    public class C_c extends JApplet implements ActionListener
    JButton jbt;
    JTextArea jta;
    public void init()
    getContentPane().setLayout(new FlowLayout());
    jbt=new JButton("Click me");
    jbt.addActionListener(this);
    getContentPane().add(jbt);
    jta=new JTextArea(5,20);
    getContentPane().add(jta);
    public void actionPerformed(ActionEvent ae)
    Enumeration e = getAppletContext().getApplets();
    Applet applets = null;
    while(e.hasMoreElements())
    applets=(Applet)e.nextElement();
    if ( applets instanceof B_b)
    System.out.println("I AM CLASS C_c");
    ((B_b)applets).text_appendText(jta.getText());
    ((B_b)applets).remove());
    ((B_b)applets).getContentPane().add(D_d);
    both the applets C_c and B_b are in same browser page
    How can i achive that pls help .

    Just to make the code readable...
    import javax.swing .*;
    import java.awt.*;
    import java.awt.event.*;
    public class A_a extends JPanel
    JButton jb;
    JTextArea text;
    public A_a()
    setLayout(new FlowLayout());
    jb=new JButton("Click me");
    //add(jb);
    text=new JTextArea(5,20);
    add(text);
    public void text_appendText(String aa)
    System.out.println("I AM IN A_a");
    text.append(aa);
    text.revalidate();
    revalidate();
    /*public static void main(String ags[])
    A_a a = new A_a();
    JFrame frame=new JFrame();
    frame.getContentPane().add(a);
    frame.pack();
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) { System.exit(0); }
    frame.setSize(200,200);
    frame.show();
    }and then I am using other class B_b which is an applet carries a exitsing panel (A_a) inside it .
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class B_b extends JApplet
    public A_a a;
    public void init()
    a=new A_a();
    getContentPane().add(a);
    public void text_appendText(String aa)
    final String aaa =aa;
    new Thread(new Runnable()
    public void run()
    a=new A_a();
    a.setBackground(new java.awt.Color(255,200,200));
    System.out.println("I AM IN B_b");
    a.text.append(aaa);
    a.text.revalidate();
    getContentPane().remove(a);
    resize(500,500);
    }).start();
    }and the I am using the second applet C_c in which by performing a button action the old panel A_a should get removed and replace the new panel D_a (which is not here )in the applet B_b with all other components(namely button , text fields etc)
    import javax.swing .*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.util.*;
    public class C_c extends JApplet implements ActionListener
    JButton jbt;
    JTextArea jta;
    public void init()
    getContentPane().setLayout(new FlowLayout());
    jbt=new JButton("Click me");
    jbt.addActionListener(this);
    getContentPane().add(jbt);
    jta=new JTextArea(5,20);
    getContentPane().add(jta);
    public void actionPerformed(ActionEvent ae)
    Enumeration e = getAppletContext().getApplets();
    Applet applets = null;
    while(e.hasMoreElements())
    applets=(Applet)e.nextElement();
    if ( applets instanceof B_b)
    System.out.println("I AM CLASS C_c");
    ((B_b)applets).text_appendText(jta.getText());
    ((B_b)applets).remove());
    ((B_b)applets).getContentPane().add(D_d);
    }

Maybe you are looking for

  • New to Apple and Time Capsule Wireless

    I am a new apple customer.  I just bought my 1st iMac and I am trying to make the total break from MS. I have mediacom as my ISP and my present wireless router is a Linksys WRT600n (purchased about 3 years ago).  With this system I have had problems

  • Is there a way to create reusable HTML Forms that can be used on multiple pages?

    I'm trying to understand the recommended approach to managing 10 HTML forms that will be reused on many different pages.  I want to be able to modify the form definition once and have the change propogate.

  • 24' 2.16ghz video issues and freezing w 10.5

    I was running 10.5.x - I honestly forget where it was at version wise but it was fully updated as of Thursday the 25th of Feb. and I was getting many random horizontal "rainbow" lines in Safari (also updated to that day) and also the machine would to

  • Yahoo Answers search results won't connect from Google search

    When I do a Google search that has a result from Yahoo Answers, if I click the link in Firefox I can't connect to it, but I can from Chrome, IE, Safari, etc... For example I did a Google search for "yahoo answers" so that the general home page was th

  • Error 1045 mysql new installation on OSX 10.9.3

    after new mysql-5.7.4-m14-osx10.7-x86_64 installation, I typed "/usr/local/mysql/bin/mysql" I got "ERROR 1045 (28000): Access denied for user 'username'@'localhost' (using password: NO)" I type "ps auxww | grep mysql", I got" _mysql            224