Problems with writing to file, and with ActionListener.

I have been trying to write a Payroll Division type program as my school Computer Science Project. However, I have a few problems with it...
import java.io.IOException;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.*;
public class Personnel implements ActionListener  {    
         JFrame GUIFrame;
         JLabel ID, Line, OKText,AnswerField;
         JTextField IDField, LineField;
         JButton OK;
         JPanel GUIPanel;
         int trialCounter=0;
         final static int employeeNumber = 7;
         final static int maxValue = ((employeeNumber*4)-1);
        //Number of employees, which would be in real life passed by the Payroll division.   
        public static String [][] sortHelp = new String [employeeNumber+1][3];    /** Creates a new instance of Personnel */       
        public Personnel() {
          GUIFrame = new JFrame("PersonnelSoft"); //create title header.
                 GUIFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                 GUIFrame.setSize(new Dimension(100, 140));
                 GUIPanel= new JPanel(new GridLayout(2, 2));
                 addWidgets();
                 GUIFrame.getRootPane().setDefaultButton(OK);
                 GUIFrame.getContentPane().add(GUIPanel, BorderLayout.CENTER);
                 GUIFrame.pack();
                GUIFrame.getContentPane().setVisible(true);
                GUIFrame.setVisible(true);
        private void addWidgets() {
              ID = new JLabel ("Please enter your employee Identification Number:", SwingConstants.LEFT);
              IDField = new JTextField ("ID", 5);
              Line = new JLabel ("Please enter the line of your payroll with which you have concerns:", SwingConstants.LEFT);
              LineField = new JTextField ("###", 2);
              OKText = new JLabel ("Click OK when you have verified the validity of your request", SwingConstants.LEFT);
              OK = new JButton ("OK");
              OK.setVerticalTextPosition(AbstractButton.CENTER);
              OK.setMnemonic(KeyEvent.VK_I);
              AnswerField = new JLabel("The Result of your Querie will go here", SwingConstants.LEFT);
              GUIPanel.add(ID);
              GUIPanel.add(IDField);
              GUIPanel.add(Line);
              GUIPanel.add(LineField);
              GUIPanel.add(OKText);
              GUIPanel.add(OK);
              GUIPanel.add(AnswerField);
              OK.addActionListener(this);
              ID.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
              OKText.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
              Line.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
        public static void ArrayCreate() throws IOException {   
          //creates a employeeNumber x 3 array, which will hold all data neccessary for future sorting by employee ID number.      
          int counter = 2;      
          int empCounter = 1;      
          String save;
          //avoid having to waste memory calculating this value every time the for loop begins 
          FileInputStream inFile = new FileInputStream("C:\\Documents and Settings\\Abraham\\humanresource4\\src\\humanresource4\\HR.txt"); 
          BufferedReader in = new BufferedReader(new InputStreamReader(inFile));
          String line;
                line = in.readLine();
                StringTokenizer st = new StringTokenizer(line);
                save = st.nextToken();
                sortHelp[0][0] = save;
                sortHelp[0][2] = save;
                while (st.hasMoreTokens()) {
                save = st.nextToken();   
                sortHelp[0][1] = save;
                while (counter <= maxValue) {
                line = in.readLine();
                if (((counter - 1) % 4) == 0) {
                st = new StringTokenizer(line);
                sortHelp[empCounter][0] = st.nextToken();
                sortHelp[empCounter][2] = sortHelp[empCounter][0];
                while (st.hasMoreTokens()) {
                save = st.nextToken();   
                sortHelp[empCounter][1] = save;
                empCounter++;
                counter++;
             public static String[] joinString() {
                  String[] tempStorage = new String[employeeNumber+1];
                  int counter;
                  for (counter = 0; counter <= employeeNumber; counter++) {
                       tempStorage[counter] = (sortHelp[counter][1] + sortHelp[counter][0]);
                  return (tempStorage);
             public static String[] sortEm(String[] array, int len)
                 java.util.Arrays.sort(array);
                 return array;
             public static void splitString(String[] splitString){
                int counter;
                for (counter = 0; counter <= employeeNumber; counter++){
                     sortHelp[counter][0]=splitString[counter].substring( 5 );
                     sortHelp[counter][1]=splitString[counter].substring(0,5);
             void setLabel(String newText) {
                 AnswerField.setText(newText);
             void writetoHR(String local) throws IOException {
                  FileOutputStream outFile = new FileOutputStream ("C:\\Documents and Settings\\Abraham\\humanresource4\\src\\humanresource4\\HR2.txt");
                   BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outFile));
                   out.write(local+"the preceding employee number is not in our database, but has submitted a request. Please sort out the issue");
                   System.exit(0);
             public void actionPerformed(ActionEvent e){
                  boolean flag=false;
                  String local=IDField.getText();
                  int i=0;
                  while((i<=employeeNumber)&&(flag==false)){
                       if (sortHelp[1]==local) {
               flag=true;
          i++;
     trialCounter++;
     if (trialCounter>=3)
          writetoHR(local);
     if (flag==false)
          setLabel("Your ID number does not exist in our records. Verify your ID and try again.");
     else {
          switch (LineField.getText())
          case 04:
               setLabel("Your pay is calculated by multiplying your working hours by the amount per hour. If both of these fields are satisfactory to you, please contact humanresource");
               break;
          case 03:
               setLabel("Hourly amount was calculated by the system, by dividing your yearly pay 26 and then 80.");
               break;
          case 07:
               setLabel("Overtime pay was calculated by multiplying regular hourly pay by 1.1");
               break;
          case 06:
               setLabel("The overtime hourly pay was multiplied by the amount of overtime hours.");
               break;
          case 10:
               setLabel("For holiday hours, your pay is increased by 25%.");
               break;
          case 09:
               setLabel("The holiday hourly pay was multiplied by your amount of holiday hours.");
               break;
          case 11:
               setLabel("Your total pay was calculated by adding all the separate types of payment to your name.");
               break;
          case 17:
               setLabel("Your net pay was found by subtracting the amount withheld from your account");
               break;
          case 19:
               setLabel("Your sick hours remaining were taken from a pool of 96 hours.");
               break;
          default:
               setLabel("Please contact humanresource.");
          break;
private static void CreateAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
Personnel GUI = new Personnel();
     public static void main(String[] args) throws IOException {
          String[] temporary = new String[employeeNumber];
          ArrayCreate();
temporary = joinString();
temporary = sortEm(temporary, employeeNumber);
splitString(temporary);
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
CreateAndShowGUI();
int row;
int column;
     for (row = 0; row < (employeeNumber); row++) {    // verify proper output by ArrayCreate splitString
for (column = 0; column <= 2; column++) {
System.out.print(sortHelp[row][column]);
System.out.print(' ');
System.out.print(' ');
System.out.println();
1) It does not permit me to switch on a String. How do I solve that?
2)How would I throw an exception (IO) within actionperformed?
3)Generally, if cut it down to everything except the writing to a file part, the actionperformed script causes an error... why?
Thanks in advance.
And sorry for the relative lameness of my question...
---abe---

Thank you very much. That did solve almost all the problems that I had...
I just have one more problem.
First (here's the new code):
import java.io.IOException;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
import javax.swing.*;
import java.util.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.*;
  public class Personnel implements ActionListener  {    
         JFrame GUIFrame;
          JLabel ID, Line, OKText,AnswerField;
           JTextField IDField, LineField;
           JButton OK;
           JPanel GUIPanel;
           int trialCounter=0;
     final static int employeeNumber = 7;
     final static int maxValue = ((employeeNumber*4)-1);
            public static String [][] sortHelp = new String [employeeNumber+1][3];   
     public Personnel() {
          GUIFrame = new JFrame("PersonnelSoft"); //create title header.
         GUIFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         GUIFrame.setSize(new Dimension(100, 140));
         GUIPanel= new JPanel(new GridLayout(2, 2));
         addWidgets();
         GUIFrame.getRootPane().setDefaultButton(OK);
         GUIFrame.getContentPane().add(GUIPanel, BorderLayout.CENTER);
         GUIFrame.pack();
        GUIFrame.getContentPane().setVisible(true);
        GUIFrame.setVisible(true);
        private void addWidgets() {
              ID = new JLabel ("Please enter your employee Identification Number:", SwingConstants.LEFT);
              IDField = new JTextField ("ID", 5);
              Line = new JLabel ("Please enter the line of your payroll with which you have concerns:", SwingConstants.LEFT);
              LineField = new JTextField ("###", 2);
              OKText = new JLabel ("Click OK when you have verified the validity of your request", SwingConstants.LEFT);
              OK = new JButton ("OK");
              OK.setVerticalTextPosition(AbstractButton.CENTER);
              OK.setMnemonic(KeyEvent.VK_I);
              AnswerField = new JLabel("The Result of your Querie will go here", SwingConstants.LEFT);
              GUIPanel.add(ID);
              GUIPanel.add(IDField);
              GUIPanel.add(Line);
              GUIPanel.add(LineField);
              GUIPanel.add(OKText);
              GUIPanel.add(OK);
              GUIPanel.add(AnswerField);
              OK.addActionListener(this);
              ID.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
              OKText.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
              Line.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
        public static void ArrayCreate() throws IOException {   
          int counter = 2;      
          int empCounter = 1;      
          String save;
          FileInputStream inFile = new FileInputStream("C:\\Documents and Settings\\Abraham\\humanresource4\\src\\humanresource4\\HR.txt"); 
          BufferedReader in = new BufferedReader(new InputStreamReader(inFile));
          String line;
                line = in.readLine();
                StringTokenizer st = new StringTokenizer(line);
                save = st.nextToken();
                sortHelp[0][0] = save;
                sortHelp[0][2] = save;
                while (st.hasMoreTokens()) {
                save = st.nextToken();   
                sortHelp[0][1] = save;
                while (counter <= maxValue) {
                line = in.readLine();
                if (((counter - 1) % 4) == 0) {
                st = new StringTokenizer(line);
                sortHelp[empCounter][0] = st.nextToken();
                sortHelp[empCounter][2] = sortHelp[empCounter][0];
                while (st.hasMoreTokens()) {
                save = st.nextToken();   
                sortHelp[empCounter][1] = save;
                empCounter++;
                counter++;
             public static String[] joinString() {
                  String[] tempStorage = new String[employeeNumber+1];
                  int counter;
                  for (counter = 0; counter <= employeeNumber; counter++) {
                       tempStorage[counter] = (sortHelp[counter][1] + sortHelp[counter][0]);
                  return (tempStorage);
             public static String[] sortEm(String[] array, int len)
                 java.util.Arrays.sort(array);
                 return array;
             public static void splitString(String[] splitString){
                int counter;
                for (counter = 0; counter <= employeeNumber; counter++){
                     sortHelp[counter][0]=splitString[counter].substring( 5 );
                     sortHelp[counter][1]=splitString[counter].substring(0,5);
             void setLabel(String newText) {
                 AnswerField.setText(newText);
             void writetoHR(String local) throws IOException {
                  FileOutputStream outFile = new FileOutputStream ("C:\\Documents and Settings\\Abraham\\humanresource4\\src\\humanresource4\\HR2.txt");
                   BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outFile));
                   out.write(local+"the preceding employee number is not in our database, but has submitted a request. Please sort out the issue");
                   System.exit(0);
             public void actionPerformed(ActionEvent e){
                  boolean flag=false;
                  String local=IDField.getText();
                  local trim();
                  int i=0;
                  while((i<employeeNumber)&&(flag==false)){
                       if (sortHelp[1]==local) {
               flag=true;
          else {
     i++;
     trialCounter++;
     if (trialCounter>=3)
          try {
               writetoHR(local);
          } catch (IOException exception) {
setLabel("We are sorry. The program has encountered an unexpected error and must now close");
          } finally {
     if (flag==false)
          setLabel("Your ID number does not exist in our records. Verify your ID and try again.");
     else {
          final Map m = new HashMap();
          m.put("04","Your pay is calculated by multiplying your working hours by the amount per hour. If both of these fields are satisfactory to you, please contact humanresource.");
          m.put("03", "Hourly amount was calculated by the system, by dividing your yearly pay 26 and then 80.");
          m.put("07", "Overtime pay was calculated by multiplying regular hourly pay by 1.1");
          m.put("06", "The overtime hourly pay was multiplied by the amount of overtime hours.");
          m.put("10", "For holiday hours, your pay is increased by 25%.");
          m.put("09", "The holiday hourly pay was multiplied by your amount of holiday hours.");
          m.put("11", "Your total pay was calculated by adding all the separate types of payment to your name.");
          m.put("17", "Your net pay was found by subtracting the amount withheld from your account.");
          m.put("19", "Your sick hours remaining were taken from a pool of 96 hours.");
setLabel(m.get(LineField.getText()));
private static void CreateAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
Personnel GUI = new Personnel();
public static void main(String[] args) throws IOException {
          String[] temporary = new String[employeeNumber];
          ArrayCreate();
temporary = joinString();
temporary = sortEm(temporary, employeeNumber);
splitString(temporary);
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
CreateAndShowGUI();
int row;
int column;
     for (row = 0; row < (employeeNumber); row++) {    // verify proper output by ArrayCreate splitString
for (column = 0; column <= 2; column++) {
System.out.print(sortHelp[row][column]);
System.out.print(' ');
System.out.print(' ');
System.out.println();
Now that code above produces two errors. First of all.
local trim();produces the error:
Syntax error, insert "AssignmentOperator ArrayInitializer" to complete ArrayInitializerAssignementSecondly, if I take that into comments, the line
setLabel(m.get(LineField.getText()));Produces the error:
The method setLabel(String) in the type Personnel is not applicable for the arguments (Object)If anybody could help me solve these, I would be sincerely thankfull.
Now, before anybody asks as to why I want to trim the String in the first place, it is due to the fact that I compare it to another String that is without whitespaces. Thus the field that DOES have whitespaces was preventing me from launching into the if loop:
if (sortHelp[1]==local) {
               flag=true;
(within actionperformed) Or at least that's my explanation as to why the loop never launched. If it is wrong, can somebody please explain?)
I apologize for the horrible indentation and lack of comments. This is an unfinished version.. I'll be adding the comments last (won't that be a joy), as well as looking for things to cut down on and make the program more efficient.
Anyways,
Thanks in Advance,
---abe---

Similar Messages

  • New to Applets: Problems wiht writing to files and with scroll panes.

    Hi, I've recently graduated from university and so I have limited experience in java programming and I'm having some trouble with JApplets (this is the first time I've made one). I'm trying to make a simple program that will allow users to pick one of a few background images from a list (a list of jpanels within a scroll pane) then at the click of a button will output a CSS with the background tag set to the image location. This is for use on a microsoft sharepoint site where each user has a My-Sit area which I want to be customizable.
    So far I've been creating this program as an application rather than a JApplet and just having another class that extends the JApplet Class which then displays the JFrame from the GUI Class. This initially didnt work because I was trying to add a window to a container so I kept programming it as an application until I got it working before trying to convert it to a JApplet. I solved the previous problem by changing my GUI class to extend JPanel instead of JFrame and it now displays correctly but with a coupe of issues.
    Firstly the applet will not create/write to the CSS file. I read that applets couldnt read/write to the users file system but they could to their own. The file I wish to write to is kept on the same machine as the applet so I'm not sure why this isn't working.
    Secondly the scroll panel is no longer working properly. This worked fine when I was still running the program as an application when the GUI still extended JFrame instead of JPanel (incidentally the program no longer runs as an application in this state) but now the scroll bar does not appear. This is a problem since I want the applet to remain the same size on the page even if I decide to add more backgrounds to the list. I tried setting the applet height/width to smaller values in the html file to see if the scroll bar would appear if the area was smaller than the GUI should be, but this just meant the bottom off the applet was cut off.
    Could anyone offer any suggestion as to why these thigns arnt working and how to fix them? If necessary I can post my source code here. Thanks in advance.

    Ok, well my program is made up of 4 classes, I hope this isnt too much to be posting. If any explaination is needed then I'll post that next. Theres lots of print lines scattered aroudn due to me trying to fix this and theres some stuff commented out from when the program used to be an application isntead of an applet.
    GUI Class, this was the main class until I made a JApplet Class
    public class AppletGUI extends JPanel{
        *GUI Components*
        //JFrames
        JFrame mainGUIFrame = new JFrame();
        JFrame changeBackgroundFrame = new JFrame();
        //JPanels (Sub-panels are indented)
        JPanel changeBackgroundJP = new JPanel(new BorderLayout());
            JPanel changeBackgroundBottomJP = new JPanel(new GridLayout(1,2));
        JPanel backgroundJP = new JPanel(new GridLayout(1,2));
        JPanel selectBackground = new JPanel(new GridLayout(1,2));
        //Jbuttons
        JButton changeBackgroundJB = new JButton("Change Background");
        JButton defaultStyleJB = new JButton("Reset Style");
        //JLabels
        JLabel changeBackgroundJL = new JLabel("Choose a Background from the Menu");
        JLabel backgroundJL = new JLabel();
        //JScrollPane
        JScrollPane backgroundList = new JScrollPane();
            JPanel backgroundListPanel = new JPanel(new GridLayout());
        //Action Listeners
        ButtonListener bttnLstnr = new ButtonListener();
        //Controllers
        CSSGenerator cssGenerator = new CSSGenerator();
        Backgrounds backgroundsController = new Backgrounds();
        backgroundMouseListener bgMouseListener = new backgroundMouseListener();
        //Flags
        Component selectedComponent = null;
        *Colour Changer*
        //this method is used to change the colour of a selected JP
        //selected JPs have their background darkered and when a
        //different JP is selected the previously seleced JP has its
        //colour changed back to it's original.
        public void changeColour(JPanel theJPanel, boolean isDarker){
        //set selected JP to a different colour
        Color tempColor = theJPanel.getBackground();
            if(isDarker){
                tempColor = tempColor.darker();
            else{
                tempColor = tempColor.brighter();
            theJPanel.setBackground(tempColor);
         //also find any sub-JPs and change their colour to match
         int j = theJPanel.getComponents().length;
         for(int i = 0; i < j; i++){
                String componentType = theJPanel.getComponent(i).getClass().getSimpleName();
                if(componentType.equals("JPanel")){
                    theJPanel.getComponent(i).setBackground(tempColor);
        *Populating the GUI*
        //backgroundList.add();
        //Populating the Backgrounds List
        *Set Component Size Method*
        public void setComponentSize(Component component, int width, int height){
        Dimension tempSize = new Dimension(width, height);
        component.setSize(tempSize);
        component.setMinimumSize(tempSize);
        component.setPreferredSize(tempSize);
        component.setMaximumSize(tempSize);     
        *Constructor*
        public AppletGUI() {
            //REMOVED CODE
            //AppletGUI.setDefaultLookAndFeelDecorated(true);
            //Component Sizes
            //setComponentSize
            //Adding Action Listeners to Components
            System.out.println("adding actions listeners to components");
            changeBackgroundJB.addActionListener(bttnLstnr);
            defaultStyleJB.addActionListener(bttnLstnr);
            //Populating the Change Background Menu
            System.out.println("Populating the window");
            backgroundsController.populateBackgroundsData();
            backgroundsController.populateBackgroundsList();
            //loops to add background panels to the JSP
            ArrayList<JPanel> tempBackgroundsList = new ArrayList<JPanel>();
            JPanel tempBGJP = new JPanel();
            tempBackgroundsList = backgroundsController.getBackgroundsList();
            int j = tempBackgroundsList.size();
            JPanel backgroundListPanel = new JPanel(new GridLayout(j,1));
            for(int i = 0; i < j; i++){
                tempBGJP = tempBackgroundsList.get(i);
                System.out.println("Adding to the JSP: " + tempBGJP.getName());
                //Add Mouse Listener
                tempBGJP.addMouseListener(bgMouseListener);
                backgroundListPanel.add(tempBGJP, i);
            //set viewpoing
            backgroundList.setViewportView(backgroundListPanel);
            /*TESTING
            System.out.println("\n\n TESTING!\n Printing Content of SCROLL PANE \n");
            j = tempBackgroundsList.size();
            for(int i = 0; i < j; i++){
                System.out.println(backgroundList.getComponent(i).getName());
            changeBackgroundJP.add(changeBackgroundJL, BorderLayout.NORTH);
            changeBackgroundJP.add(backgroundList, BorderLayout.CENTER);
            //changeBackgroundJP.add(tempBGJP, BorderLayout.CENTER);
            changeBackgroundJP.add(changeBackgroundBottomJP, BorderLayout.SOUTH);
            changeBackgroundBottomJP.add(changeBackgroundJB);
            changeBackgroundBottomJP.add(defaultStyleJB);
            System.out.println("Finsihed populating");
            //REMOVED CODE
            //adding the Background Menu to the GUI and settign the GUI options
            //AppletGUI.setDefaultLookAndFeelDecorated(true);
            //this.setResizable(true);
            //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setLocation(500,500);
            this.setSize(400,300);
            this.add(changeBackgroundJP);
        //REMOVED CODE
         *Main Method*
        public static void main(String[] args){
           System.out.println("Creating GUI");
           AppletGUI theGUI = new AppletGUI();
           theGUI.setVisible(true);
           System.out.println("GUI Displayed");
         *Button Listener Inner Class*
        public class ButtonListener implements ActionListener{
            //check which button is clicked
            public void actionPerformed(ActionEvent event) {
                AbstractButton theButton = (AbstractButton)event.getSource();
                //Default Style Button
                if(theButton == defaultStyleJB){
                    System.out.println("Default Style Button Clicked!");
                //Change Background Button
                if(theButton == changeBackgroundJB){
                    System.out.println("Change Background Button Clicked!");
                    String backgroundURL = cssGenerator.getBackground();
                    if(backgroundURL != ""){
                        cssGenerator.setBackgroundChanged(true);
                        cssGenerator.setBackground(backgroundURL);
                        cssGenerator.outputCSSFile();
                        System.out.println("Backgroudn Changed, CSS File Written");
                    else{
                        System.out.println("No Background Selected");
         *Mouse Listener Inner Class*
        public class backgroundMouseListener implements MouseListener{
            public void mouseClicked(MouseEvent e){
                //get component
                JPanel tempBackgroundJP = new JPanel();
                tempBackgroundJP = (JPanel)e.getComponent();
                System.out.println("Background Panel Clicked");
                //change component colour
                if(selectedComponent == null){
                    selectedComponent = tempBackgroundJP;
                else{
                    changeColour((JPanel)selectedComponent, false);
                    selectedComponent = tempBackgroundJP;
                changeColour((JPanel)selectedComponent, true);
                //set background URL
                cssGenerator.setBackground(tempBackgroundJP.getName());
            public void mousePressed(MouseEvent e){
            public void mouseReleased(MouseEvent e){
            public void mouseEntered(MouseEvent e){
            public void mouseExited(MouseEvent e){
    }JApplet Class, this is what I plugged the GUI into after I made the change from Application to JApplet.
    public class AppletTest extends JApplet{
        public void init() { 
            System.out.println("Creating GUI");
            AppletGUI theGUI = new AppletGUI();
            theGUI.setVisible(true);
            Container content = getContentPane();
            content.setBackground(Color.white);
            content.setLayout(new FlowLayout());
            content.add(theGUI);
            AppletGUI theGUI = new AppletGUI();
            theGUI.setVisible(true);
            setContentPane(theGUI);
            System.out.println("GUI Displayed");
        public static void main(String[] args){
            AppletTest at = new AppletTest();
            at.init();
            at.start();
    }The CSS Generator Class. This exists because once I have the basic program working I intend to expand upon it and add multiple tabs to the GUI, each one allowing the user to change different style options. Each style option to be changed will be changed wit ha different method in this class.
    public class CSSGenerator {
        //Variables
        String background = "";
        ArrayList<String> backgroundCSS;
        //Flags
        boolean backgroundChanged = false;
        //Sets and Gets
        //For Variables
        public void setBackground(String theBackground){
            background = theBackground;
        public String getBackground(){
            return background;
        //For Flags
        public void setBackgroundChanged(boolean isBackgroundChanged){
            backgroundChanged = isBackgroundChanged;
        public boolean getBackgroundChanged(){
            return backgroundChanged;
        //background generator
        public ArrayList<String> backgroundGenerator(String backgroundURL){
            //get the URL for the background
            backgroundURL = background;
            //creat a new array list of strings
            ArrayList<String> backgroundCSS = new ArrayList<String>();
            //add the strings for the background options to the array list
            backgroundCSS.add("body");
            backgroundCSS.add("{");
            backgroundCSS.add("background-image: url(" + backgroundURL + ");");
            backgroundCSS.add("background-color: #ff0000");
            backgroundCSS.add("}");
            return backgroundCSS;
        //Write CSS to File
        public void outputCSSFile(){
            try{
                //Create CSS file
                System.out.print("creating file");
                FileWriter cssWriter = new FileWriter("C:/Documents and Settings/Gwilym/My Documents/Applet Data/CustomStyle.css");
                System.out.print("file created");
                System.out.print("creating buffered writer");
                BufferedWriter out = new BufferedWriter(cssWriter);
                System.out.print("buffered writer created");
                //check which settings have been changed
                //check background flag
                if(getBackgroundChanged() == true){
                    System.out.print("retrieving arraylist");
                    ArrayList<String> tempBGOptions = backgroundGenerator(getBackground());
                    System.out.print("arraylist retrieved");
                    int j = tempBGOptions.size();
                    for(int i = 0; i < j ; i++){
                        System.out.print("writing to the file");
                        out.write(tempBGOptions.get(i));
                        out.newLine();
                        System.out.print("written to the file");
                out.close();
            }catch (Exception e){//Catch exception if any
                System.out.println("Error: Failed to write CSS file");
        /** Creates a new instance of CSSGenerator */
        public CSSGenerator() {
    }The Backgrounds Class. This class exists because I didnt want there to just be a hardcoded lsit of backgrounds, I wanted it to be possible to add new ones to the list without simply lettign users upload their own images (since the intended users are kids and this sharepoint site is used for educational purposes, I dont want them uplaoded inapropraite backgrounds) but I do want the site admin to be able to add more images to the list. for this reason the backgrounds are taken from a list in a text file that will be stored in the same location as the applet, the file specifies the background name, where it is stored, and where a thumbnail image is stored.
    public class Backgrounds {
        //Array Lists
        private ArrayList<JPanel> backgroundsList;
        private ArrayList<String> backgroundsData;
        //Set And Get Methods
        public ArrayList getBackgroundsList(){
            return backgroundsList;
        //ArrayList Population Methods
        public void populateBackgroundsData(){
            //decalre the input streams and create a new fiel hat points to the BackgroundsData file
            File backgroundsDataFile = new File("C:/Documents and Settings/Gwilym/My Documents/Applet Data/BackgroundsData.txt");
            FileInputStream backgroundsFIS = null;
            BufferedInputStream backgroundsBIS = null;
            DataInputStream backgroundsDIS = null;
            try {
                backgroundsFIS = new FileInputStream(backgroundsDataFile);
                backgroundsBIS = new BufferedInputStream(backgroundsFIS);
                backgroundsDIS = new DataInputStream(backgroundsBIS);
                backgroundsData = new ArrayList<String>();
                String inputtedData = null;
                //loops until it reaches the end of the file
                while (backgroundsDIS.available() != 0) {
                    //reads in the data to be stored in an array list
                    inputtedData = backgroundsDIS.readLine();
                    backgroundsData.add(inputtedData);
            //TESTING
            System.out.println("\n\nTESTING: populateBackgroundsData()");
            int j = backgroundsData.size();
            for(int i = 0; i < j; i++){
                System.out.println("Index " + i + " = " + backgroundsData.get(i));
            System.out.println("\n\n");
            //close all stremas
            backgroundsFIS.close();
            backgroundsBIS.close();
            backgroundsDIS.close();
            } catch (FileNotFoundException e) {
                System.out.println("Error: File Not Found");
            } catch (IOException e) {
                System.out.println("Error: IO Exception Thrown");
        public void populateBackgroundsList(){
            backgroundsList = new ArrayList<JPanel>();
            int j = backgroundsData.size();
            System.out.println("number of backgrounds = " + j);
            backgroundsList = new ArrayList<JPanel>();
            for(int i = 0; i < j; i++){
                String tempBackgroundData = backgroundsData.get(i);
                JPanel backgroundJP = new JPanel(new GridLayout(1,2));
                JLabel backgroundNameJL = new JLabel();               
                JLabel backgroundIconJL = new JLabel();
                //split the string string and egt the background name and URL
                String[] splitBGData = tempBackgroundData.split(",");
                String backgroundName = splitBGData[0];
                String backgroundURL = splitBGData[1];
                String backgroundIcon = splitBGData[2];
                System.out.println("\nbackgroundName = " + backgroundName);
                System.out.println("\nbackgroundURL = " + backgroundURL);
                System.out.println("\nbackgroundIcon = " + backgroundIcon + "\n");
                backgroundNameJL.setText(backgroundName);
                backgroundIconJL.setIcon(new javax.swing.ImageIcon(backgroundIcon));
                backgroundJP.add(backgroundNameJL);
                backgroundJP.add(backgroundIconJL);
                backgroundJP.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
                //Name the JP as the background URL so it can be found
                //May be useful sicne the data file may need to contain 3 fields in future
                //this is incase the preview image (icon) is different from the acctual background
                //most liekly in the case of more complex ppictures rather then repeating patterns
                backgroundJP.setName(backgroundURL);
                //Add the JP to the Array List
                backgroundsList.add(backgroundJP);
            //TESTING
            System.out.println("\n\nTESTING: populateBackgroundsList()");
            j = backgroundsList.size();
            for(int i = 0; i < j; i++){
                System.out.println("Index " + i + " = " + backgroundsList.get(i));
            System.out.println("\n\n");
    }So thats my program so far, if theres anythign that needs clarifying then please jsut ask. Thank you very much for the help!

  • Problem about writing txt file and  utl_put_line

    After some research on the internet I found the way how to writre files from Oracle 11g to a txt file.
    I read that utl_put_line only holds 32k per line and adds a new line at the end of each row but my problem it´s that if I want to open the file with SQL Server :D it doesn't recognize the CRLF so there is no end line and the last column has the data from the next row. The files are created on Linux so if I open them on Windows i have to convert into DOS format but if I try to open that file with Excel everything works fine, so I was wondering if there is a limit of columns or number of characters that can be on a txt file.
    There is my pl sql that I used to create my txt files:
    -------------------CODE-----------------------------
    declare
    cursor r1 is
    select * from dqstage.st_nomdetalle
    where sistema = 'NOR'
    and procesar = 0
    and identidad=02;
    cursor r2 ( p_parid number) is
    select * from dqstage.st_nomsubdetalle
    where par_id = p_parid
    and procesar = 0
    and sistema = 'NOR'
    and substr(nombrearchivo,6,2)=02;
    vcadena varchar2(4000);
    --vcadena1 varchar2(4000);
    vcadena1 clob;
    vcadena2 long;
    c number:=0;
    vencabezados long;
    archivo sys.utl_file.file_type;
    begin
    archivo:= SYS.UTL_FILE.FOPEN(location=>'UPEPE_DIR',filename=>'nor02.txt',open_mode=>'w',max_linesize=>32767);
    vencabezados :='FILEID|NOMBREARCHIVO|TIPOREGISTRO|IDENTIFICADORREGISTRO|FECHAEMISIONPAGO|CLAVETIPONOMINA|CLAVECT|TURNOCT|RFC|CURP|NUMEMPLEADOESTATAL'
    ||'|NUMSEGURIDADSOCIAL|NOMBRECOMPLETO|NOMBRES|PRIMERAPELLIDO|SEGUNDOAPELLIDO|CODIGOPAGADURIA|IDORIGENPRESUPUESTALPLAZA|CLAVEPRESUPUESTAL|'
    ||'PARTIDAPRESUPUESTAL|CODIGOPAGO|CLAVEUNIDAD|CLAVESUBUNIDAD|CLAVECATEGORIA|HSM|NUMEROPLAZA|CLAVENIVELPUESTO|CLAVENIVELSUELDO|ZONAECONOMICA|'
    ||'PERCEPCIONNETA|CLABECUENTA|NUMEROCHEQUE|CLAVEMOTIVOPAGORETROACTIVO|NUMTOTALPERDED|ERRORES|'
    ||'TIPOCONCEPTO1|CONCEPTOPAGO1|MONTO1|PERIODODEL1|PERIODOAL1|FUENTEFINANCIAMIENTO1|ORIGEN1|ERRORES1|'
    ||'TIPOCONCEPTO2|CONCEPTOPAGO2|MONTO2|PERIODODEL2|PERIODOAL2|FUENTEFINANCIAMIENTO2|ORIGEN2|ERRORES2|'
    ||'TIPOCONCEPTO3|CONCEPTOPAGO3|MONTO3|PERIODODEL3|PERIODOAL3|FUENTEFINANCIAMIENTO3|ORIGEN3|ERRORES3|'
    ||'TIPOCONCEPTO4|CONCEPTOPAGO4|MONTO4|PERIODODEL4|PERIODOAL4|FUENTEFINANCIAMIENTO4|ORIGEN4|ERRORES4|'
    ||'TIPOCONCEPTO5|CONCEPTOPAGO5|MONTO5|PERIODODEL5|PERIODOAL5|FUENTEFINANCIAMIENTO5|ORIGEN5|ERRORES5|'
    ||'TIPOCONCEPTO6|CONCEPTOPAGO6|MONTO6|PERIODODEL6|PERIODOAL6|FUENTEFINANCIAMIENTO6|ORIGEN6|ERRORES6|'
    ||'TIPOCONCEPTO7|CONCEPTOPAGO7|MONTO7|PERIODODEL7|PERIODOAL7|FUENTEFINANCIAMIENTO7|ORIGEN7|ERRORES7|'
    ||'TIPOCONCEPTO8|CONCEPTOPAGO8|MONTO8|PERIODODEL8|PERIODOAL8|FUENTEFINANCIAMIENTO8|ORIGEN8|ERRORES8|'
    ||'TIPOCONCEPTO9|CONCEPTOPAGO9|MONTO9|PERIODODEL9|PERIODOAL9|FUENTEFINANCIAMIENTO9|ORIGEN9|ERRORES9|'
    ||'TIPOCONCEPTO10|CONCEPTOPAGO10|MONTO10|PERIODODEL10|PERIODOAL10|FUENTEFINANCIAMIENTO10|ORIGEN10|ERRORES10|'
    ||'TIPOCONCEPTO11|CONCEPTOPAGO11|MONTO11|PERIODODEL11|PERIODOAL11|FUENTEFINANCIAMIENTO11|ORIGEN11|ERRORES11|'
    ||'TIPOCONCEPTO12|CONCEPTOPAGO12|MONTO12|PERIODODEL12|PERIODOAL12|FUENTEFINANCIAMIENTO12|ORIGEN12|ERRORES12|'
    ||'TIPOCONCEPTO13|CONCEPTOPAGO13|MONTO13|PERIODODEL13|PERIODOAL13|FUENTEFINANCIAMIENTO13|ORIGEN13|ERRORES13|'
    ||'TIPOCONCEPTO14|CONCEPTOPAGO14|MONTO14|PERIODODEL14|PERIODOAL14|FUENTEFINANCIAMIENTO14|ORIGEN14|ERRORES14|'
    ||'TIPOCONCEPTO15|CONCEPTOPAGO15|MONTO15|PERIODODEL15|PERIODOAL15|FUENTEFINANCIAMIENTO15|ORIGEN15|ERRORES15|'
    ||'TIPOCONCEPTO16|CONCEPTOPAGO16|MONTO16|PERIODODEL16|PERIODOAL16|FUENTEFINANCIAMIENTO16|ORIGEN16|ERRORES16|'
    ||'TIPOCONCEPTO17|CONCEPTOPAGO17|MONTO17|PERIODODEL17|PERIODOAL17|FUENTEFINANCIAMIENTO17|ORIGEN17|ERRORES17|'
    ||'TIPOCONCEPTO18|CONCEPTOPAGO18|MONTO18|PERIODODEL18|PERIODOAL18|FUENTEFINANCIAMIENTO18|ORIGEN18|ERRORES18|'
    ||'TIPOCONCEPTO19|CONCEPTOPAGO19|MONTO19|PERIODODEL19|PERIODOAL19|FUENTEFINANCIAMIENTO19|ORIGEN19|ERRORES19|'
    ||'TIPOCONCEPTO20|CONCEPTOPAGO20|MONTO20|PERIODODEL20|PERIODOAL20|FUENTEFINANCIAMIENTO20|ORIGEN20|ERRORES20|'
    ||'TIPOCONCEPTO21|CONCEPTOPAGO21|MONTO21|PERIODODEL21|PERIODOAL21|FUENTEFINANCIAMIENTO21|ORIGEN21|ERRORES21|'
    ||'TIPOCONCEPTO22|CONCEPTOPAGO22|MONTO22|PERIODODEL22|PERIODOAL22|FUENTEFINANCIAMIENTO22|ORIGEN22|ERRORES22|'
    ||'TIPOCONCEPTO23|CONCEPTOPAGO23|MONTO23|PERIODODEL23|PERIODOAL23|FUENTEFINANCIAMIENTO23|ORIGEN23|ERRORES23|'
    ||'TIPOCONCEPTO24|CONCEPTOPAGO24|MONTO24|PERIODODEL24|PERIODOAL24|FUENTEFINANCIAMIENTO24|ORIGEN24|ERRORES24|'
    ||'TIPOCONCEPTO25|CONCEPTOPAGO25|MONTO25|PERIODODEL25|PERIODOAL25|FUENTEFINANCIAMIENTO25|ORIGEN25|ERRORES25|'
    ||'TIPOCONCEPTO26|CONCEPTOPAGO26|MONTO26|PERIODODEL26|PERIODOAL26|FUENTEFINANCIAMIENTO26|ORIGEN26|ERRORES26|'
    ||'TIPOCONCEPTO27|CONCEPTOPAGO27|MONTO27|PERIODODEL27|PERIODOAL27|FUENTEFINANCIAMIENTO27|ORIGEN27|ERRORES27|'
    ||'TIPOCONCEPTO28|CONCEPTOPAGO28|MONTO28|PERIODODEL28|PERIODOAL28|FUENTEFINANCIAMIENTO28|ORIGEN28|ERRORES28|'
    ||'TIPOCONCEPTO29|CONCEPTOPAGO29|MONTO29|PERIODODEL29|PERIODOAL29|FUENTEFINANCIAMIENTO29|ORIGEN29|ERRORES29|'
    ||'TIPOCONCEPTO30|CONCEPTOPAGO30|MONTO30|PERIODODEL30|PERIODOAL30|FUENTEFINANCIAMIENTO30|ORIGEN30|ERRORES30|'
    ||'TIPOCONCEPTO31|CONCEPTOPAGO31|MONTO31|PERIODODEL31|PERIODOAL31|FUENTEFINANCIAMIENTO31|ORIGEN31|ERRORES31|'
    ||'TIPOCONCEPTO32|CONCEPTOPAGO32|MONTO32|PERIODODEL32|PERIODOAL32|FUENTEFINANCIAMIENTO32|ORIGEN32|ERRORES32|'
    ||'TIPOCONCEPTO33|CONCEPTOPAGO33|MONTO33|PERIODODEL33|PERIODOAL33|FUENTEFINANCIAMIENTO33|ORIGEN33|ERRORES33|'
    ||'TIPOCONCEPTO34|CONCEPTOPAGO34|MONTO34|PERIODODEL34|PERIODOAL34|FUENTEFINANCIAMIENTO34|ORIGEN34|ERRORES34|'
    ||'TIPOCONCEPTO35|CONCEPTOPAGO35|MONTO35|PERIODODEL35|PERIODOAL35|FUENTEFINANCIAMIENTO35|ORIGEN35|ERRORES35|'
    ||'TIPOCONCEPTO36|CONCEPTOPAGO36|MONTO36|PERIODODEL36|PERIODOAL36|FUENTEFINANCIAMIENTO36|ORIGEN36|ERRORES36|'
    ||'TIPOCONCEPTO37|CONCEPTOPAGO37|MONTO37|PERIODODEL37|PERIODOAL37|FUENTEFINANCIAMIENTO37|ORIGEN37|ERRORES37|'
    ||'TIPOCONCEPTO38|CONCEPTOPAGO38|MONTO38|PERIODODEL38|PERIODOAL38|FUENTEFINANCIAMIENTO38|ORIGEN38|ERRORES38|'
    ||'TIPOCONCEPTO39|CONCEPTOPAGO39|MONTO39|PERIODODEL39|PERIODOAL39|FUENTEFINANCIAMIENTO39|ORIGEN39|ERRORES39|'
    ||'TIPOCONCEPTO40|CONCEPTOPAGO40|MONTO40|PERIODODEL40|PERIODOAL40|FUENTEFINANCIAMIENTO40|ORIGEN40|ERRORES40|'
    ||'TIPOCONCEPTO41|CONCEPTOPAGO41|MONTO41|PERIODODEL41|PERIODOAL41|FUENTEFINANCIAMIENTO41|ORIGEN41|ERRORES41|'
    ||'TIPOCONCEPTO42|CONCEPTOPAGO42|MONTO42|PERIODODEL42|PERIODOAL42|FUENTEFINANCIAMIENTO42|ORIGEN42|ERRORES42|'
    ||'TIPOCONCEPTO43|CONCEPTOPAGO43|MONTO43|PERIODODEL43|PERIODOAL43|FUENTEFINANCIAMIENTO43|ORIGEN43|ERRORES43|'
    ||'TIPOCONCEPTO44|CONCEPTOPAGO44|MONTO44|PERIODODEL44|PERIODOAL44|FUENTEFINANCIAMIENTO44|ORIGEN44|ERRORES44|'
    ||'TIPOCONCEPTO45|CONCEPTOPAGO45|MONTO45|PERIODODEL45|PERIODOAL45|FUENTEFINANCIAMIENTO45|ORIGEN45|ERRORES45|'
    ||'TIPOCONCEPTO46|CONCEPTOPAGO46|MONTO46|PERIODODEL46|PERIODOAL46|FUENTEFINANCIAMIENTO46|ORIGEN46|ERRORES46|'
    ||'TIPOCONCEPTO47|CONCEPTOPAGO47|MONTO47|PERIODODEL47|PERIODOAL47|FUENTEFINANCIAMIENTO47|ORIGEN47|ERRORES47|'
    ||'TIPOCONCEPTO48|CONCEPTOPAGO48|MONTO48|PERIODODEL48|PERIODOAL48|FUENTEFINANCIAMIENTO48|ORIGEN48|ERRORES48|'
    ||'TIPOCONCEPTO49|CONCEPTOPAGO49|MONTO49|PERIODODEL49|PERIODOAL49|FUENTEFINANCIAMIENTO49|ORIGEN49|ERRORES49|'
    ||'TIPOCONCEPTO50|CONCEPTOPAGO50|MONTO50|PERIODODEL50|PERIODOAL50|FUENTEFINANCIAMIENTO50|ORIGEN50|ERRORES50';
    --||'TIPOCONCEPTO51|CONCEPTOPAGO51|MONTO51|PERIODODEL51|PERIODOAL51|FUENTEFINANCIAMIENTO51|ORIGEN51|ERRORES51';
    sys.utl_file.put_line(archivo, vencabezados);
    for i in r1 loop
    c:=c+1;
    vcadena := i.fileid||'|'||i.nombrearchivo||'|'||i.tiporegistro||'|'||i.identificadorregistro||'|'||i.fechaemisionpago||'|'||i.clavetiponomina||'|'||i.clavect||'|'||i.turnoct||'|'||i.rfc
    ||'|'||i.curp||'|'||i.numempleadoestatal||'|'||i.numseguridadsocial||'|'||i.nombrecompleto||'|'||i.nombres||'|'||i.primerapellido||'|'||i.segundoapellido||'|'||i.codigopagaduria
    ||'|'||i.idorigenpresupuestalplaza||'|'||i.clavepresupuestal||'|'||i.partidapresupuestal||'|'||i.codigopago||'|'||i.claveunidad||'|'||i.clavesubunidad||'|'||i.clavecategoria||'|'||i.hsm
    ||'|'||i.numeroplaza||'|'||i.clavenivelpuesto||'|'||i.clavenivelsueldo||'|'||i.zonaeconomica||'|'||i.percepcionneta||'|'||i.clabecuenta||'|'||i.numerocheque||'|'||i.clavemotivopagoretroactivo
    ||'|'||i.numtotalperded||'|'||i.errores;
    vcadena1:=null;
    for j in r2 (i.fileid) loop
    vcadena1 := vcadena1||'|'|| j.tipoconcepto||'|'||j.conceptopago||'|'||j.monto||'|'||j.periododel||'|'||j.periodoal||'|'||j.fuentefinanciamiento ||'|'||j.origen||'|'||j.errores;
    end loop;
    sys.utl_file.put_line(archivo, vcadena2);
    end loop;
    sys.utl_file.fclose(archivo);
    end;
    As you can see I write the column names first and with a loop I add the data, so I can have a very large column at the end.
    How can I add the CRLF at the end of each line to have it working with Windows?

    user2068122 wrote:
    After some research on the internet I found the way how to writre files from Oracle 11g to a txt file.
    I read that utl_put_line only holds 32k per line and adds a new line at the end of each row but my problem it´s that if I want to open the file with SQL Server :D it doesn't recognize the CRLF so there is no end line and the last column has the data from the next row. The files are created on Linux so if I open them on Windows i have to convert into DOS format but if I try to open that file with Excel everything works fine, so I was wondering if there is a limit of columns or number of characters that can be on a txt file.
    <snip>
    Oracle is simply passing a string of characters to the OS to be written to a file in the host OS's native text format. That format is different from Windows and nix.  Windows will append a CR-LF pair to the end of the provided character string, as its end-of-record delimiter.  nix will append only a CR (or is it LF?) as its end-of-record delimiter. This is purely and OS issue that Oracle knows or cares nothing about. It is also something that must always be kept in mind when passing files between *nix and Windows.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Repeating problems (1) Many Missing Files; and (2) Downloading From iTunes

    I am having multiple issues with the iTunes store currently. I have spoken with an Apple Expert on August 14, 2010 (case number available if needed). Although he was very good at helping me to the best of his ability, he referred me to iTunes Store Customer Service, which I previously was in contact with.
    I have 2 types of repeating problems (1) Many Missing Files; and (2) Downloading From iTunes Store.
    _Problem One - (1) Downloading From iTunes Store_
    I have 1610 missing files from my iTunes folders. I created a list of missing items by following these steps:
    +If for any reason you find yourself with random missing tracks, (or are trying to recover from a dying hard drive like me), there is an easy way to isolate those missing tracks.+
    +1. Create a standard playlist called "Not Missing".+
    +2. Drag your entire library into that playlist. Missing tracks cannot+
    +be copied to a playlist.+
    +3. Create a smart playlist called where you select the following conditions in the options window for the new smart playlist:+
    +*dropdown menu* PLAYLIST+
    +*dropdown menu* IS NOT+
    +*dropdown menu* NOT MISSING.+
    +4. Rename the smart playlist "Missing"+
    +5. Right Click the "Missing" playlist+
    +6. Click the "Export..." option+
    +7. Select the Plain Text option and Desktop location+
    My missing playlistable items represent a better part of a decades worth of audiobook files, transfered files from my PC days, etc... i loved my - now missing - Doctor Who and Torchwood purchases from iTunes.
    I have already read the Trouble Shooting, checked Time Machine Backup, and been walked through replacing the preferences list. The missing file path from the "get info" options in iTunes points towards a non-existant file.
    _Problem Two (2) Downloading From iTunes Store_
    I have had problems downloading files from iTunes for months. I first noticed it with the TV Show "Avatar: The Last Airbender". Lately, when I download from the (non-music) part of the store, the majority of files are downloaded and then immediately not found. This has been prompting iTunes to repeat the download. Until I force quit itunes and *potentially cry*.
    There have been multiple iTunes store purchases of audio books recently. If I reported the missing file immediately, I can contact iTunes support to repost the file and that usually fixes the issue. But today, I went to go rewatch "Torchwood: Children of Earth" and noticed Problem One.
    _Hind Sight_
    If provided with a spreadsheet of my iTunes Store purchase history, I can write a vlookup( formula in excel to compare the list against my exported missing list so a shortlist of what is missing from just my iTunes Store purchase history can be created (hint: it's the majority of items from the list, others are years worth of files from my PC days). If we could do that, could iTunes make my missing purchases available?
    Then we can focus on purely, trying to figure out why they went missing in the first place - so we can prevent it again & possibly help others from running into the same.
    Plea
    I strongly suspect the two issues are related to a root cause ... in addition to my user error in file management of backups ... what is going on?

    iTunes Support (Eric) emailed me some instructions. I am posting, in hopes that this will help others.
    _Suggestions from iTunes Support_
    Troubleshooting 1. iTunes Store: Finding missing purchases and downloads http://support.apple.com/kb/TS1408
    Troubleshooting 2. Direct Assistance
    _Results based on Suggestions_
    Results on "Searching the harddrive" - did not resolve my concerns
    Results from "Direct Assistant" - i emailed the list of the missing files... status is pending
    Conclusion
    I'll follow up again later, if I have new news.

  • Problem in Creating .wsdl file and mapping.xml with ant

    hi
    i am created my .wsdl file and mapping.xml file with wscompile tool but when i run this by ant tool it show a problem.
    the command runs on command prompt but when run throught ant file it shows a following error :-
    Execute failed: java.io.IOException: CreateProces: wscompile -define -mapping build\classes\META-INF\mapping.xml -d . -nd build\.................and so on
    so if anybody have any idea then plz help me asap
    thanx

    The following Ant snippet is the way I've defined my wscompile task. I'm creating a web application and it looks like yours might be an EJB endpoint, but you can adjust where necessary:
    <taskdef name="wscompile" classname="com.sun.xml.rpc.tools.ant.Wscompile">
         <classpath refid="compile.classpath" />
    </taskdef>
    <target name="init">
         <echo message="-------- ${appname} --------" />
    </target>
    <!-- This target compiles the server components using an existing WSDL as the driving document.
           The configuration file must use the <wsdl> element giving the location (local file system
           or URL) of the WSDL document.
           Note: the fork argument is needed to over come a bug when using the mapping argument. See
           http://forum.java.sun.com/thread.jspa?threadID=592994&tstart=0
      -->
         <target name="generate-server-from-WSDL" depends="init">
              <wscompile fork="yes"
                           keep="true"
                           base="${basedir}/WebContent/WEB-INF/classes"
                           import="true"
                           features="wsi"
                           xPrintStackTrace="true"
                           verbose="true"
                           mapping="${basedir}/WebContent/WEB-INF/jaxrpc-mapping.xml"
                           sourcebase="${basedir}/src"
                           config="${config.server.doclit.file}">
                   <classpath>
                        <path refid="compile.classpath" />
                   </classpath>
              </wscompile>
         </target>
         <target name="compile-server-from-WSDL" depends="generate-server-from-WSDL">
              <javac srcdir="${basedir}/src" destdir="${basedir}/WebContent/WEB-INF/classes" debug="${compile.debug}">
                   <classpath refid="compile.classpath" />
              </javac>
         </target>Just make sure that the named destination directories exist before you run the script.
    If you'd like more details on the wscompile Ant task, I found the following pages invaluable:
    https://jax-rpc.dev.java.net/whitepaper/1.1/index-part1.html

  • Problems with actionListener

    Hi, I'm having som problems with getSource.
    I realize that actionPerformed doesn't recognize the JButtons because of the scope, but as far as I can tell, I have done it like the examples I have followed.
    package gui;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class NumericPanel extends JPanel implements ActionListener {
         public NumericPanel(){
              setLayout(new GridLayout(4,3));
              //Generating Buttons
            JButton b1 = new JButton("1");
            JButton b2 = new JButton("2");
            JButton b3 = new JButton("3");
            JButton b4 = new JButton("4");
            JButton b5 = new JButton("5");
            JButton b6 = new JButton("6");
            JButton b7 = new JButton("7");
            JButton b8 = new JButton("8");
            JButton b9 = new JButton("9");
            JButton bClear = new JButton("Clear");
            JButton b0 = new JButton("0");
            JButton bEnter = new JButton("Enter");
            setLayout(new GridLayout(4,3));
            add(b1);
            add(b2);
            add(b3);
            add(b4);
            add(b5);
            add(b6);
            add(b7);
            add(b8);
            add(b9);
            add(bClear);
            add(b0);
            add(bEnter);
            b1.addActionListener(this);
            b2.addActionListener(this);
            b3.addActionListener(this);
            b4.addActionListener(this);
            b5.addActionListener(this);
            b6.addActionListener(this);
            b7.addActionListener(this);
            b8.addActionListener(this);
            b9.addActionListener(this);
            b0.addActionListener(this);
            bEnter.addActionListener(this);
            bClear.addActionListener(this);
         public void actionPerformed(ActionEvent e){
              Object button = e.getSource();
              if(button = b1){ // Says it doesn't recognize b1 - how am I supposed to do this??!
    }

    I have done it like the examples I have followed.Check out the example in the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/button.html]How to Use Buttons which uses the "action command" instead of checking the button.
    An even better way is to write generic code when possible so you con't have to check which button was clicked as demonstrated in this simple example:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=609795
    You can always use multiple listeners, one for the numbers on one for the other buttons.

  • Problem in dreamweaver - image file and swf file.

    Hi friends.....nice to be here.
    Ahnm, lets start from the beginning! J I am new here and my english isnt so good, but i´ll try to explain what was happening with my webpage using Dreamweaver CS3 and a swf file…..Im sure that for most of you it’s a basic problem with a basic solution, but I didn’t find one…..and I´m new to CS3 too ! J
    I´m creating a simply webpage using 2 frames: Top frame and main frame, but my problem was in top frame.
    I created an image (like a banner) to fill this frame, not background, an image with name company, phone number etc…..My intention was to put some buttons (using flash) in this image……..but NOT in all image…, so I split the image in two….half jpeg file, half a swf file…….joining this images on dreamweaver later…..
    So, on dreamweaver works great……there everthing works perfect…..but on I.E, an BORDER appears, separating the two images
    Well…..better than words, here is the images:
    On dreamweaver
    http://img204.imageshack.us/img204/2867/tela1.jpg
    http://img543.imageshack.us/img543/2083/tela2.jpg
    On I.E. (my problem)
    http://img717.imageshack.us/img717/585/tela3u.jpg
    Guys, I´m sure that was an easy solution………. I hope someone can help me…
    Sorry for my english J
    Hugs
    Vinicius
     

    1) You don't need frames.  Why Frames are bad for you and your site visitors.
    http://apptools.com/rants/framesevil.php
    2) Don't use Flash for navigation.  Many people can't use Flash.  What will they do?
    3) Learn HTML and CSS code first.  This will make DW much easier to learn.
    Start here:
    HTML & CSS Tutorials - http://w3schools.com/
    Then work through this 3-part tutorial:
    Taking  a Fireworks (or Photoshop) comp to a CSS based layout in DW
    Part 1 --
    http://www.adobe.com/devnet/fireworks/articles/web_standards_layouts_pt1.html
    Part 2 --
    http://www.adobe.com/devnet/fireworks/articles/web_standards_layouts_pt2.html
    Part 3 --
    http://www.adobe.com/devnet/fireworks/articles/web_standards_layouts_pt3.html
    For best results, post a URL to your web page.  You'll get faster replies and much better answers that way. 
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com

  • Problem while writing to file

    I have a value '2222.12' stored in a database table. i fetch this value and write this value to a file but in file the value is '2222,12' instead of '2222.12'. i.e dot is being replaced with a comma automatically, can anyone tell what is the mistake i am making?????
    my code is for writing to file is:
    Sys.UTL_FILE.PUT_LINE (file_handle,my_cursor.amount);

    To answer any question at a minimum you need to post
    4 digit Oracle version (from select * from v$version)
    OS and version
    In this particular case : regional settings when running on Windows
    Apparently you are writing a number and you are relying on implicit conversion to a character string, as put_line writes strings only.
    You may want to use explicit conversion and use to_char(my_cursor.amount,'99999.09')
    Sybrand Bakker
    Senior Oracle DBA
    Edited by: sybrand_b on 21-apr-2010 7:11

  • Problem in writing to file or in console

    Hi friends,
    I am here once again with one more problem.
    I read from a file and process each line and write back the result on the console. The result is strange.
    On console it starts from middle of the file and goes on reading till the end of file . Each time it trims some.
    For example I have 1500 lines. It reads, processes and writes 900 (the total is 1500) next time it may be 850 like this...
    why is like this ?
    public static void main (String[] args)throws Exception
              List one=new ArrayList();
              List A=new ArrayList();
              MyVertex j,startNode,s,targetNode;
         //load Graph
              File n=new File("nodes.txt");
              File e=new File("relation.txt");
              ts=new Test(n,e);
              //System.out.println(ts.toString());
              vs=ts.getVertexSet();
              es=ts.getEdgeSet();
              //read from file          
              BufferedReader br=new BufferedReader(new FileReader("test.txt"));
              startNodeName=br.readLine();
              while((startNodeName!=null))
                   System.out.println("START NODE : "+ startNodeName);
                                  System.out.println("links for startNodes are :     "+counter1);
                                  first(startNodeName);
                   targetNodeName=br.readLine();
                   System.out.println("TARGET NODE : "+ targetNodeName);
                   second(targetNodeName);
                   System.out.println();
                   shared();
                   System.out.println();
                   startNodeName=br.readLine();
         public static void first(String s)
         System.out.println(vs.toString());
              Iterator i=vs.iterator();
              while(i.hasNext())
                   j=(MyVertex)i.next();
                   startNode=j;
                   if(startNode.getName().equals(s))
                        one=ts.outwardNodes(startNode);
                        System.out.println(one.toString());
              counter1=one.size()+1;
         public static void second(String s)
              Iterator j=vs.iterator();
              while(j.hasNext())
                   k=(MyVertex)j.next();
                   targetNode=k;
                   if(targetNode.getName().equals(s))
                        B=ts.outwardNodes(targetNode);
                        System.out.println(B.toString());
              counter2=B.size();
              System.out.println("Links for target Nodes are :     "+counter2);
         public static void shared()
              counter3=1;
              Iterator i=one.iterator();
              while(i.hasNext())
                   s=(MyVertex)i.next();
                   if(B.contains(s))
                        counter3++;
              System.out.println("Number of common links are :     "+counter3);
              relWeight=(double)counter3/counter1;
              System.out.println("Relation weight is :     "+relWeight);
    }//end of classThanks once again

    I tried to write to a text file it is still strange. It trims some of the last lines.
    out f 1500 lines it only reads 1400 lines.
    I am using Eclipse, so I meant the console of Eclipse not windows console. In both the cases the problem remains.
    Can any one suggest me how to get rid of this problem ?
    Thanks a lot for yur time.

  • When downloading iTunes, I got a message about error writing to file and it told the file. Then it said to verify that you have access to that directory. I have no idea how to fix it. I could really use some help, please.

    I was trying to download iTunes on my computer, and while doing so, I got this message: Error writing to file: C:/Program Files (x86)/Common Files/Apple/Apple Application Support/Apple Versions.dll. Verify that you have access to that directory. I have downloaded iTunes numerous times and I have never had this problem. If anyone knows what's going on, I would really appreciate the help.

    Well, there's definitely a mac and a Windows version. And you're at the right page. I think the problem is that someone forgot (or decided not to) to update the text at teh bottom of the page to have Mac and Windows.
    Just push the button, you'll get the Mac update no problem.
    Regards,
    Bentley Wolfe
    Senior Support Engineer, Flash/Flash Player/Digital Editions
    Adobe

  • Problems while writing to file

    Hi,
    I'm trying to query my test database (mysql) and to write these results to a file, I manage to get the results out of the database, but when I try to write for instance an int to a file, the file replaces the int by a square. What can be wrong?? The file is created successfully and I've writen the int to the standard out before writing it to the file; in the standard out the int is correct.
    code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class getData extends HttpServlet {
    FileWriter fw;
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    } catch(Exception e){
    System.err.println("Database driverclass not found");
    Connection conn;
         //insert values into DB
    try {
         conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=admin12&password=adm12");
    Statement stmt = conn.createStatement();
    String slq = "Select * from feedback";
    ResultSet rs = stmt.executeQuery(slq);
    if (rs==null){System.out.println("nOT OK");}
    else{
    try{
    File f = new File("D:\\mysql\\Data.txt");
    fw = new FileWriter(f);
    while(rs.next())
    writeToFile(rs.getString(1));
    writeToFile(rs.getString(2));
    writeToFile(rs.getInt(3));
    writeToFile(rs.getInt(4));
    writeToFile(rs.getString(5));
    writeToFile(rs.getInt(6));
    catch(IOException e)
    System.out.println("Error occured while writing to file");
    stmt.close();
         conn.close();
    } catch(SQLException sqle){
    System.err.println("A SQL error has occured: " + sqle.getMessage());          
    /* output your page here*/
    out.println("<html>");
    out.println("<head>");
    out.println("<title>getDataServlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h2>Data recovered</h2>");
    out.println("</body>");
    out.println("</html>");
    out.close();
    fw.flush();
    fw.close();
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    private void writeToFile(int i)
    try{
    System.out.println("test: "+i);
    fw.write(i);
    fw.write(";");
    }catch(IOException e1)
    private void writeToFile(String str)
    try{
    if (str!=null&&(str.equals("null")==false)){
    fw.write(str);
    fw.write(";");
    }catch(IOException e2)

    I would imagine that FileWriter is writing the byte value to the file. Just change your SQL get to this writeToFile(rs.getString(6)); and write it as a String instead of an int.
    DesQuite

  • Install Problem - Error Writing to file

    I am getting the following error when I try to Install the demo of 3.4.1:   Error 1304. Error writing to file   C:\ProgramData\Adobe\Cameraraw\CameraPRofiles\Camera\Nikon d40X\Nikon D40X Camera D2X Mode 2.dcp.  Verify that you have access to that directory.
    I though I changed access but it will not access when I hit  Retry.  Any suggestions?  Thanks  Alan.

    Beat:  I ran as Administrator and tried downloading a second program  Same thing.  Then I check I I saw the file was Hidden so I inchecke
    d that.  Same thing.  Then I checked the Nikon D40X folder and tried to explore it.  I got a message that the files were corrupted
    .  So apparently LR3 couldn't get in there.  SO I tried to delete that file.  No good.
    So now what?  What created that file in the first place?  Maybe I have to re-install that program.  Ignoring it as an option doesn't work.  It just ends the installatiopn of LR3.
    Any suggestions?

  • Problem with ActionListener

    Hi
    i have coded a button and added a Actionlistner that when the button is pressed then it should repaint the dice.but I don't know why it is not working.
    here i my code
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.ImageIcon;
    public class Board {
    JFrame frame;
    //Image dice[] = new Image[2];
    //int stick1,stick2,stick3,stick4,stick5;
    //boolean begin = true;
    Stick st = new Stick();
    public static void main(String[] args) {
         Board b = new Board();
         b.go();
        public void go() {
            //Make sure we have nice window decorations.
           JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("Senet");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel jp = new JPanel();
            JButton button = new JButton("Make Move");
            button.addActionListener((ActionListener) new Stick());
          Stick st = new Stick();
            //frame.getContentPane().add(BorderLayout.EAST,button);
           frame.getContentPane().add(BorderLayout.CENTER,jp);
           jp.setBackground(Color.DARK_GRAY);
           jp.setLayout(new BoxLayout(jp,BoxLayout.Y_AXIS));
           Check c = new Check();
           jp.add(c);
           jp.add(st);
           st.add(button);
          st.setBackground(Color.WHITE);
            //Display the window.
            frame.setSize(600,500);
            frame.setVisible(true);
       /* public void actionPerformed(ActionEvent event){
             st.repaint();
    import javax.swing.*;
    import java.awt.*;
    import java.awt.Graphics.*;
    import java.awt.event.*;
    * @author Kokil Bhalerao
    public class Stick extends JPanel implements ActionListener{
          Image dice[] = new Image[2];
          int stick1, stick2,stick3,stick4,stick5, result;
          boolean begin = true;
          public void actionPerformed(ActionEvent event){
                  repaint();
          public void paintComponent(Graphics g)
               super.paintComponent(g);
               Graphics2D g2 = (Graphics2D)g;
               dice = new Image[2];
                  dice[0] = new ImageIcon("C:/Program Files/Java/images/stick2.gif").getImage();
                    dice[1] = new ImageIcon("C:/Program Files/Java/images/stick1.gif").getImage();
                    begin = false;
                       stick1 = (int)(Math.random() * 2 + 1);
                      stick2 = (int)(Math.random() * 2 + 1);
                      stick3 = (int)(Math.random() * 2 + 1);
                      stick4 = (int)(Math.random() * 2 + 1);
                      stick5 = (int)(Math.random() * 2 + 1);
                     setAll(stick1,stick2,stick3,stick4,stick5,begin);
               // draw dice if they've clicked the roll button at least once
               if (!begin)
                   g2.drawImage(dice[stick1 - 1], 20, 40,100,50,this);
                  g2.drawImage(dice[stick2 - 1], 120, 40,100,50,this);
                  g2.drawImage(dice[stick3 - 1], 220, 40,100,50,this);
                  g2.drawImage(dice[stick4 - 1], 320, 40,100,50,this);
                  g2.drawImage(dice[stick5 - 1], 420,40,100,50,this);
               else
                  g2.drawString("Welcome to senet", 20, 60);
            public void setImages(Image s[])
               dice = s;
            public void setAll(int s1,int s2,int s3,int s4,int s5,boolean b)
                 stick1 = s1;
                 stick2 = s2;
                 stick3 = s3;
                 stick4 = s4;
                 stick5 = s5;
                 begin = b;
    public class Check extends JPanel{
         public void paint(Graphics g) {
            int row;   // Row number, from 0 to 7
            int col;   // Column number, from 0 to 7
            int x,y;   // Top-left corner of square
            Image bg = new ImageIcon("C:/Program Files/Java/images/piece1.gif").getImage();
            for ( row = 0;  row < 3;  row++ ) {
               for ( col = 0;  col < 10;  col++) {
                  x = col * 60;
                  y = row * 60;
                     g.setColor(Color.black);
                  g.drawRect(x, y, 60, 60);
                  g.setColor(Color.blue);
                 g.fillRect(x+1, y+1, 60, 60);
                  if( row == 0 )
                 g.drawImage(bg, x+5,y+5,40,40,Color.RED, this);
            } // end for row
         }  // end paint()Please somebody help me with this.
    Thanks

    thanks for the reply. but i don't know how i can do
    that.So the code above is not yours ?
    http://java.sun.com/docs/books/tutorial/java/index.html

  • Problem with ActionListener firing multiple times

    I have a GUI class, GUIView, with a no-arg constructor and a static getInstance() method.
    The GUI class has a JButton called btnB1 with a method:
         void addB1Listener(ActionListener al){
              btnB1.addActionListener(al);
         }The Controller class has an instance of the GUI and the Model.
    The Controller has a constructor which assigns a new ActionListener to the JButton from the GUI.
    private GUI m_gui;
         FTController(GUIView view){
              m_gui = view;
              m_gui.addButtonListener(new AddButtonListener());
         }The Controller has an inner class:
    class AddButtonListener implements ActionListener{
              @Override
              public void actionPerformed(ActionEvent e) {
                          // do stuff
    }The model has a constructor which accepts a GUIView.
    My main method setups instances of the objects:
         private GUIView view;
         private Model model;
         private Controller controller;
         public static void main(String [] args){
              view = GUIView.getInstance();
              model = new Model(view);
              controller = new Controller(view);
         }This action listener for btnB1 is firing multiple times, but I don't understand why.
    Edited by: user10199598 on Jan 9, 2012 2:56 PM

    Here is the actual Controller class
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.IOException;
    import javax.swing.JOptionPane;
    import com.esri.arcgis.carto.FeatureLayer;
    import com.esri.arcgis.carto.IActiveView;
    import com.esri.arcgis.carto.Map;
    import com.esri.arcgis.interop.AutomationException;
    public class FTController{
         private FTView m_arraView;
         private FTModel m_arraModel;
         private Map m_map;
         FTController(FTView view, FTModel model, Map map){
              m_arraView = view;
              m_arraModel = model;
              m_map = map;
              m_arraView.addPointListener(new AddPointListener());
              m_arraView.addExitListener(new AddExitListener());
              m_arraView.addResetListener(new AddResetListener());
         public FTView getM_arraView() {
              return m_arraView;
         // Inner class used as the ActionListener for the btnAddPoint in FTView
         class AddPointListener implements ActionListener {
              @Override
              public void actionPerformed(ActionEvent e) {
                   FeatureLayer fl = (FeatureLayer) m_arraModel.getLayerByName("arra_field_teams", m_map);
                   try {
                        // Start the process to add a new feature point
                        m_arraModel.addPoint(fl, (IActiveView) m_map.getActiveView());
                        // Reset and dispose of the ARRA Field Teams form.
                        m_arraView.getCboTeam().setSelectedIndex(0);
                        m_arraView.getCboAgency().setSelectedIndex(0);
                        m_arraView.getTxtLatitude().setText("");
                        m_arraView.getTxtLongitude().setText("");
                        m_arraView.getTxtGridL().setText("");
                        m_arraView.getTxtGridN().setText("");
                        m_arraView.getTxtQuadrant().setText("");
                        m_arraView.getFtf3IC().setText("0.002");
                        m_arraView.getFtf3FC().setText("0.002");
                        m_arraView.getFtf3IO().setText("0.002");
                        m_arraView.getFtf3FO().setText("0.002");
                        m_arraView.getFtfAgxCartridge().setText("0.000");
                        m_arraView.getFtfBGCM().setText("50.000");
                        m_arraView.getFtfBGURHR().setText("0.002");
                        m_arraView.getTxtTimeOfReading().setText("");
                        m_arraView.dispose();
                        // Refresh the map window
                        m_map.getActiveView().refresh();
                   } catch (AutomationException e1) {
                        e1.printStackTrace();
                   } catch (IOException e1) {
                        e1.printStackTrace();
         } // end AddPointListener
         // Inner class used as the ActionListener for the btnExit in FTView
         class AddExitListener implements ActionListener{
              @Override
              public void actionPerformed(ActionEvent e) {
                   m_arraView.getCboTeam().setSelectedIndex(0);
                   m_arraView.getCboAgency().setSelectedIndex(0);
                   m_arraView.getTxtLatitude().setText("");
                   m_arraView.getTxtLongitude().setText("");
                   m_arraView.getTxtGridL().setText("");
                   m_arraView.getTxtGridN().setText("");
                   m_arraView.getTxtQuadrant().setText("");
                   m_arraView.getFtf3IC().setText("0.002");
                   m_arraView.getFtf3FC().setText("0.002");
                   m_arraView.getFtf3IO().setText("0.002");
                   m_arraView.getFtf3FO().setText("0.002");
                   m_arraView.getFtfAgxCartridge().setText("0.000");
                   m_arraView.getFtfBGCM().setText("50.000");
                   m_arraView.getFtfBGURHR().setText("0.002");
                   m_arraView.getTxtTimeOfReading().setText("");
                   m_arraView.dispose();
         } // end AddExitListener
         // Inner class used as the ActionListner for the btnReset in FTView
         class AddResetListener implements ActionListener{
              @Override
              public void actionPerformed(ActionEvent e) {
                   FeatureLayer fl = (FeatureLayer) m_arraModel.getLayerByName("field_teams", m_map);
                   try {
                        // Actually, "Reset" is deleting all features from the shapefile, poor choice of labels.
                        m_arraModel.resetFeatures(fl, (IActiveView) m_map.getActiveView(), (Map) m_map);
                        // Refresh the map window
                        m_map.getActiveView().refresh();
                   } catch (AutomationException e1) {
                        e1.printStackTrace();
                   } catch (IOException e1) {
                        e1.printStackTrace();
    }Here is where the application starts:
    import java.awt.event.MouseEvent;
    import java.io.IOException;
    import java.text.DecimalFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    import com.esri.arcgis.addins.desktop.Tool;
    import com.esri.arcgis.arcmap.Application;
    import com.esri.arcgis.arcmapui.IMxDocument;
    import com.esri.arcgis.arcmapui.MxDocument;
    import com.esri.arcgis.carto.IActiveView;
    import com.esri.arcgis.carto.IFeatureLayer;
    import com.esri.arcgis.carto.Map;
    import com.esri.arcgis.framework.IApplication;
    import com.esri.arcgis.geodatabase.Feature;
    import com.esri.arcgis.geodatabase.IFeatureClass;
    import com.esri.arcgis.geometry.Point;
    import com.esri.arcgis.interop.AutomationException;
    public class FTTool extends Tool {
         private IApplication app;
         private IActiveView av;
         private IMxDocument mxDocument;
         private Map map;
         private FTView arraView;
         private FTModel model;
         private FTController controller;
         private int left;
         private int top;
          * Called when the tool is activated by clicking it.
          * @exception java.io.IOException if there are interop problems.
          * @exception com.esri.arcgis.interop.AutomationException if the component throws an ArcObjects exception.
         @Override
         public void activate() throws IOException, AutomationException {
         @Override
         public void init(IApplication app) throws IOException, AutomationException {
              this.app = app;
              try {
                 try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                   } catch (ClassNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   } catch (InstantiationException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   } catch (IllegalAccessException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   } catch (UnsupportedLookAndFeelException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   // Initialize our map document, map and active view
                   mxDocument = (IMxDocument)app.getDocument();
                   av = mxDocument.getActiveView();
                   map = (Map)mxDocument.getMaps().getItem(0);
                   // Get an instance of the ARRAView JFrame, and setup the model and controller for this tool add-in
                   arraView = FTView.getInstance();
    //               arraView.addWindowListener(arraView);
                   // Set up the model and controller objects
                   model = new FTModel(arraView);
                   controller = new FTController(arraView, model, map);
              } catch (AutomationException e) {
                   e.printStackTrace();
              } catch (IOException e) {
                   e.printStackTrace();
         @Override
         public void mousePressed(MouseEvent mouseEvent) {
              super.mousePressed(mouseEvent);
              // Cast IMxDocument into MxDocument so we can get the Parent which returns an Application
              MxDocument mxd = (MxDocument)mxDocument;
              Application application;
              // Create an Application object so we can get the left and top properties of the window
              //  so we can position the Field Teams GUI.
              try {
                   application = new Application(mxd.getParent());
                   left = application.getLeft() + 75;
                   top = application.getTop() + 105;
              } catch (IOException e2) {
                   e2.printStackTrace();
              try {
                   // Call the model to convert the screen coordinates to map coordinates and project the point to WGS_1984
                   Point p1 = new Point();
                   p1.putCoords((double)mouseEvent.getX(), (double)mouseEvent.getY());
                   Point p2 = (Point) model.getMapCoordinatesFromScreenCoordinates(p1, av);
                   Point point = (Point)model.handleToolMouseEvent(mouseEvent, av);
                 // Format the decimal degrees to six decimal places
                   DecimalFormat df = new DecimalFormat("#.######");
                   // Assign the point2 values to double
                   double x = point.getX();
                   double y = point.getY();
                   // Set the text of the lat/long fields.
                   arraView.getTxtLatitude().setText(df.format(y));
                   arraView.getTxtLongitude().setText(df.format(x));
                   // Set the Time of Reading text field
                   Date now = new Date();
                   SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
                   arraView.getTxtTimeOfReading().setText(sdf.format(now).toString());
                   // Determine whether the mouse click point intersects the arra_grid_quad.
                   //  If so, iterate over that feature cursor to update the gridl, gridn and quadrant fields...
                   IFeatureLayer featLayer = (IFeatureLayer) model.getLayerByName("arra_grid_quads", map);     
                   IFeatureClass featClass = featLayer.getFeatureClass();
                   Feature iFeat = (Feature) model.queryArraGridQuads(featClass, p2);
                   if(iFeat != null){
                        // Fill in the grid and quadrant values if there are any.
                        String gridl = (String) iFeat.getValue(iFeat.getFields().findField("GRID_L"));
                        String gridn = (String) iFeat.getValue(iFeat.getFields().findField("GRID_N"));
                        String quadrant = (String) iFeat.getValue(iFeat.getFields().findField("QUADRANT"));
                        arraView.getTxtGridL().setText(gridl);
                        arraView.getTxtGridN().setText(gridn);
                        arraView.getTxtQuadrant().setText(quadrant);
                   } else {
                        // Revert values back to empty string after clicking in the grid, then outside of the grid.
                        arraView.getTxtGridL().setText("");
                        arraView.getTxtGridN().setText("");
                        arraView.getTxtQuadrant().setText("");
                   // Set the Field Team Readings form to visible, or redisplay it if it is already visible
                   arraView.setBounds(left, top, 325, 675);
                   arraView.setVisible(true);
              } catch (Exception e) {
                   e.printStackTrace();
         @Override
         public boolean deactivate() throws IOException, AutomationException {
              return super.deactivate();
         @Override
         public boolean isChecked() throws IOException, AutomationException {
              return super.isChecked();
         public FTView getArraView() {
              return arraView;
         public IApplication getApp() {
              return app;
         public Map getMap() {
              return map;
         public FTModel getModel() {
              return model;
    }Is this enough?
    Edited by: user10199598 on Jan 9, 2012 3:20 PM

  • Troubles writing to file and printing characters above 127

    Hi,
    Whenever I write to a file or to the standard output (System.out), all characters above 127 are replaced by a question mark.
    I only started having this problem after upgrading to jdk 1.3.1, with previous version all was fine. I'm using slackware linux 7.0.
    output of java -version
    java version "1.3.1"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
    Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
    After reading a lot about internationalization I still can't solve my problem.
    The output of the following code:
    System.out.println(java.util.Locale.getDefault().getDisplayName());
    System.out.println( System.getProperty("file.enconding"));
    is:
    English (United States)
    null
    Shouldn't the file.encoding property be set?
    I've tried setting it:
    System.out.println( System.setProperty("file.enconding","UTF8"));
    but the aplication simply hangs at that line.
    Please help!

    Hi,
    I am having similiar problem as posted by you in the message - ours is a web application hosted on Apache - JServ, JDK 1.2.1, Servlets, MySQL, and SunOS 5.6. We have recently upgraded to JDK 1.3.1 and SunOS 5.8.
    The application works fine except for the internationalization code.
    The web application support 8 languages. The application works fine for english but for asian languages (korean,japanese,traditional chinese,simplified chinese), all characters are replaced by question marks. Similarly some characters in latin based languages (german,french,italian)are replaced by question marks.
    I am wondering if you can share the solution - i think it should be applicable to us also.
    The mechanism used by us is to set the content type in the HTTPServletResponse object and use output stream writer to send localized information to browser:
    res.setContentType("text/html;charset=EUC_JP");
    OutputStreamWriter out = new BufferedWriter( new OutputStreamWriter(this.oHttpResponse.getOutputStream() ), 512 );
    Regards,
    Kapil Kapoor.

Maybe you are looking for