Class & int/String issues

Upon compiling, I am receiving the following errors:
TeamRosterApp.java:153: cannot find symbol
symbol : class ButtonPanel
location: class TeamRosterPanel
ButtonPanel buttonPanel;
^
TeamRosterApp.java:166: cannot find symbol
symbol : class ButtonPanel
location: class TeamRosterPanel
buttonPanel = new ButtonPanel();
^
2 errors
I've included the code below, but I having difficulty understanding why it cannot find the ButtonPanel class when that class is specified in the code (Line 364).
Thanks in advance for your help!
//Modified by Doe, John 20OCT2007
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.JTextComponent;
import java.util.ArrayList;
import java.text.*;
import java.lang.*;
import java.util.*;
public class TeamRosterApp
     public static void main(String[] args)
          TeamIO.getTeam();
                JFrame frame = new TeamRosterFrame();
                frame.setVisible(true);
class Player
     String lname;
     String fname;
     int number;
     public Player()
          lname = "";
          fname = "";
          number = 0;
     public Player(String lname, String fname, int number)
          this.lname = lname;
          this.fname = fname;
          this.number = number;
     public void setLastName(String lname)
          this.lname = lname;
     public String getLastName()
          return lname;
     public void setFirstName(String fname)
          this.fname = fname;
     public String getFirstName()
          return fname;
     public void setNumber(int number)
          this.number = number;
     public int getNumber()
          return number;
class TeamIO
     private static final ArrayList<Player> team = new ArrayList<Player>();
     public static ArrayList<Player> getTeam()
          team.add(new Player("Doe", "John", 69));
          team.add(new Player("Berg", "Laura", 44));
          team.add(new Player("Bustos", "Crystl", 6));
          team.add(new Player("Clark", "Jamie", 24));
          team.add(new Player("Fernandez", "Lisa", 16));
          team.add(new Player("Finch", "Jennie", 27));
          team.add(new Player("Flowers", "Tairia", 11));
          team.add(new Player("Freed", "Amanda", 7));
          team.add(new Player("Giordano", "Nicole", 4));
          team.add(new Player("Harrigan", "Lori", 21));
          team.add(new Player("Jung", "Lovieanne", 3));
          team.add(new Player("Kretchman", "Kelly", 12));
          team.add(new Player("Lappin", "Lauren", 37));
          team.add(new Player("Mendoza", "Jessica", 2));
          team.add(new Player("O'Brien-Amico", "Lisa", 20));
          team.add(new Player("Nuveman", "Stacy", 33));
          team.add(new Player("Osterman", "Catherine", 8));
          team.add(new Player("Topping", "Jennie", 31));
          team.add(new Player("Watley", "Natasha", 29));
          System.out.println("\nOpening team list" + "\n\n" + "****************************************");
          for(int i = 0; i < team.size(); i++)
               Player p = (Player)team.get(i);
               System.out.print(p.getNumber() + "\t" + p.getLastName() + "," + p.getFirstName() + "\n");
               System.out.println("****************************************");
          return new ArrayList<Player>(team);
     public static ArrayList<Player> saveTeam()
          System.out.println("\nOpening team list" + "\n\n" + "****************************************");
          for(int i = 0; i < team.size(); i++)
          Player p = (Player)team.get(i);
          System.out.print(p.getNumber() + "\t" + p.getLastName() + "," + p.getFirstName() + "\n");
          System.out.println("****************************************");
          return new ArrayList<Player>(team);
class TeamRosterFrame extends JFrame
    public TeamRosterFrame()
        String me = "Campbell, Corey";
          String date;
          Date now = new Date();
          DateFormat longDate = DateFormat.getDateInstance(DateFormat.LONG);
          date = longDate.format(now);
          setTitle("Team Roster "+me+" "+date);
        setResizable(false);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.add(new TeamRosterPanel());
        this.pack();
        centerWindow(this);
    private void centerWindow(Window w)
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        setLocation((d.width-w.getWidth())/2, (d.height-w.getHeight())/2);
class TeamRosterPanel extends JPanel
     ArrayList<Player>team;
     Player newPlayer = null;
     teamSelectorPanel selectorPanel;
     PlayerDisplayPanel playerPanel;
     ButtonPanel buttonPanel;
     public TeamRosterPanel()
          // fill the team ArrayList
          team = TeamIO.getTeam();
          // add the panels
          setLayout(new GridBagLayout());
          selectorPanel = new teamSelectorPanel();
          add(selectorPanel, getConstraints(0,0,1,1, GridBagConstraints.WEST));
          playerPanel = new PlayerDisplayPanel();
          add(playerPanel, getConstraints(0,1,1,1, GridBagConstraints.EAST));
          buttonPanel = new ButtonPanel();
          add(buttonPanel, getConstraints(0,2,1,1, GridBagConstraints.EAST));
          // set the initial player to be displayed
          playerPanel.showPlayer(team.get(0));
          selectorPanel.selectPlayer(team.get(0));
     // a method for setting grid bag constraints
     private GridBagConstraints getConstraints(int gridx, int gridy,
          int gridwidth, int gridheight, int anchor)
          GridBagConstraints c = new GridBagConstraints();
          c.insets = new Insets(5, 5, 5, 5);
          c.ipadx = 0;
          c.ipady = 0;
          c.gridx = gridx;
          c.gridy = gridy;
          c.gridwidth = gridwidth;
          c.gridheight = gridheight;
          c.anchor = anchor;
          return c;
     class teamSelectorPanel extends JPanel implements ActionListener
          public JComboBox    playerComboBox;
          private JLabel      playerLabel;
          boolean filling = false;            // used to indicate the combo box is being filled
          public teamSelectorPanel()
               // set panel layout
               setLayout(new FlowLayout(FlowLayout.LEFT));
               // Player label
               playerLabel = new JLabel("Select Player:");
               add(playerLabel);
               // Player combo box
               playerComboBox = new JComboBox();
               fillComboBox(team);
               playerComboBox.addActionListener(this);
               add(playerComboBox);
          public void actionPerformed(ActionEvent e)
               if (!filling)
                    Player p = (Player)playerComboBox.getSelectedItem();
                    playerPanel.showPlayer(p);
          public void fillComboBox(ArrayList<Player> team)
          filling = true;
          playerComboBox.removeAllItems();
          for (Player p : team)
          playerComboBox.addItem(p);
          filling = false;
          public void selectPlayer(Player p)
               playerComboBox.setSelectedItem(p);
          public Player getCurrentPlayer()
               return (Player) playerComboBox.getSelectedItem();
     class PlayerDisplayPanel extends JPanel
          public JTextField   lastNameTextField,
               firstNameTextField,
               numberTextField;
          private JLabel      lastNameLabel,
               firstNameLabel,
               numberLabel;
          public PlayerDisplayPanel()
               // set panel layout
               setLayout(new GridBagLayout());
               // last name label
               lastNameLabel = new JLabel("Last name:");
               add(lastNameLabel, getConstraints(0,0,1,1, GridBagConstraints.EAST));
               // last name text field
               lastNameTextField = new JTextField(10);
               lastNameTextField.setEditable(false);
               lastNameTextField.setFocusable(false);
               lastNameTextField.addFocusListener(new AutoSelect());
               add(lastNameTextField, getConstraints(1,0,1,1, GridBagConstraints.WEST));
               // first name label
               firstNameLabel = new JLabel("First name:");
               add(firstNameLabel, getConstraints(0,1,1,1, GridBagConstraints.EAST));
               // first name text field
               firstNameTextField = new JTextField(30);
               firstNameTextField.setEditable(false);
               firstNameTextField.setFocusable(false);
               firstNameTextField.addFocusListener(new AutoSelect());
               add(firstNameTextField, getConstraints(1,1,1,1, GridBagConstraints.WEST));
               // number label
               numberLabel = new JLabel("Number:");
               add(numberLabel, getConstraints(0,2,1,1, GridBagConstraints.EAST));
               // number text field
               numberTextField = new JTextField(10);
               numberTextField.setEditable(false);
               numberTextField.setFocusable(false);
               numberTextField.addFocusListener(new AutoSelect());
               numberTextField.addKeyListener(new IntFilter());
               add(numberTextField, getConstraints(1,2,1,1, GridBagConstraints.WEST));
          public void showPlayer(Player p)
               lastNameTextField.setText(p.getLastName());
               firstNameTextField.setText(p.getFirstName());
               numberTextField.setText(String.valueOf(p.getNumber()));
          public void clearFields()
               lastNameTextField.setText("");
               firstNameTextField.setText("");
               numberTextField.setText("");
          // return a new Player object with the data in the text fields
          public Player getPlayer()
               Player p = new Player();
               p.setLastName(lastNameTextField.getText());
               p.setFirstName(firstNameTextField.getText());
               int n = Integer.parseInt(numberTextField.getText());
               p.setNumber(n);
               return p;
          public void setAddEditMode(boolean e)
               lastNameTextField.setEditable(e);
               lastNameTextField.setFocusable(e);
               lastNameTextField.requestFocusInWindow();
               firstNameTextField.setEditable(e);
               firstNameTextField.setFocusable(e);
               numberTextField.setEditable(e);
               numberTextField.setFocusable(e);
          class AutoSelect implements FocusListener
               public void focusGained(FocusEvent e)
                    if(e.getComponent() instanceof JTextField)
                         JTextField t = (JTextField) e.getComponent();
                         t.selectAll();
               public void focusLost(FocusEvent e){}
          class IntFilter implements KeyListener
               public void keyTyped(KeyEvent e)
                    char c = e.getKeyChar();
                    if ( c !='0' && c !='1' && c !='2' && c !='3' && c !='4' && c !='5'
                         && c !='6' && c !='7' && c !='8' && c !='9')
                         e.consume();
               public void keyPressed(KeyEvent e){}
               public void keyReleased(KeyEvent e){}
          class ButtonPanel extends JPanel
               public JButton addButton,
                    editButton,
                    deleteButton,
                    acceptButton,
                    cancelButton,
                    exitButton;
               public ButtonPanel()
                    // create maintenance button panel
                    JPanel maintPanel = new JPanel();
                    maintPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
                    // add button
                    addButton = new JButton("Add");
                    addButton.addActionListener(new AddListener());
                    maintPanel.add(addButton);
                    // edit button
                    editButton = new JButton("Edit");
                    editButton.addActionListener(new EditListener());
                    maintPanel.add(editButton);
                    // delete button
                    deleteButton = new JButton("Delete");
                    deleteButton.addActionListener(new DeleteListener());
                    maintPanel.add(deleteButton);
                    // accept button
                    acceptButton = new JButton("Accept");
                    acceptButton.setEnabled(false);
                    acceptButton.addActionListener(new AcceptListener());
                    maintPanel.add(acceptButton);
                    // cancel button
                    cancelButton = new JButton("Cancel");
                    cancelButton.setEnabled(false);
                    cancelButton.addActionListener(new CancelListener());
                    maintPanel.add(cancelButton);
                    // create exit button panel
                    JPanel exitPanel = new JPanel();
                    exitPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
                    // exit button
                    exitButton = new JButton("Exit");
                    exitButton.addActionListener(new ExitListener());
                    exitPanel.add(exitButton);
                    // add panels to the ButtonPanel
                    setLayout(new BorderLayout());
                    add(maintPanel, BorderLayout.CENTER);
                    add(exitPanel, BorderLayout.SOUTH);
               public void setAddEditMode(boolean e)
                    addButton.setEnabled(!e);
                    editButton.setEnabled(!e);
                    deleteButton.setEnabled(!e);
                    acceptButton.setEnabled(e);
                    cancelButton.setEnabled(e);
          class AddListener implements ActionListener
               public void actionPerformed(ActionEvent e)
                    newPlayer = new Player();
                    playerPanel.clearFields();
                    buttonPanel.setAddEditMode(true);
                    playerPanel.setAddEditMode(true);
          class EditListener implements ActionListener
               public void actionPerformed(ActionEvent e)
                    buttonPanel.setAddEditMode(true);
                    playerPanel.setAddEditMode(true);
          class DeleteListener implements ActionListener
               public void actionPerformed(ActionEvent e)
                    Player p = selectorPanel.getCurrentPlayer();
                    team.remove(p);
                    TeamIO.saveTeam();
                    selectorPanel.fillComboBox(team);
                    selectorPanel.selectPlayer(team.get(0));
                    playerPanel.showPlayer(team.get(0));
                    selectorPanel.playerComboBox.requestFocusInWindow();
          class AcceptListener implements ActionListener
               public void actionPerformed(ActionEvent e)
                    if (isValidData())
                         if (newPlayer != null)
                              newPlayer = playerPanel.getPlayer();
                              team.add(newPlayer);
                              TeamIO.saveTeam();
                              selectorPanel.fillComboBox(team);
                              selectorPanel.selectPlayer(newPlayer);
                              newPlayer = null;
                         else
                              Player p = selectorPanel.getCurrentPlayer();
                              Player newPlayer = playerPanel.getPlayer();
                              p.setLastName(newPlayer.getLastName());
                              p.setFirstName(newPlayer.getFirstName());
                              p.setNumber(newPlayer.getNumber());
                              TeamIO.saveTeam();
                              selectorPanel.fillComboBox(team);
                              selectorPanel.selectPlayer(p);
                              playerPanel.showPlayer(selectorPanel.getCurrentPlayer());
                         playerPanel.setAddEditMode(false);
                         buttonPanel.setAddEditMode(false);
                         selectorPanel.playerComboBox.requestFocusInWindow();
               public boolean isValidData()
                    return SwingValidator.isPresent(playerPanel.lastNameTextField, "Last Name")
                         && SwingValidator.isPresent(playerPanel.firstNameTextField, "First Name")
                         && SwingValidator.isPresent(playerPanel.numberTextField, "Number")
                         && SwingValidator.isInteger(playerPanel.numberTextField, "Number");
          class CancelListener implements ActionListener
               public void actionPerformed(ActionEvent e)
                    if (newPlayer != null)
                         newPlayer = null;
                    playerPanel.setAddEditMode(false);
                    playerPanel.showPlayer(selectorPanel.getCurrentPlayer());
                    buttonPanel.setAddEditMode(false);
                    selectorPanel.playerComboBox.requestFocusInWindow();
          class ExitListener implements ActionListener
               public void actionPerformed(ActionEvent e)
                    System.exit(0);
}Swing Validator Code:
//Programmed by Doe, John 20OCT2007
import javax.swing.*;
import javax.swing.text.JTextComponent;
public class SwingValidator
     public static boolean isPresent(JTextComponent c, String title)
          if(c.getText().length()==0)
               showMessage(c, title + " is a required field.\n" + "Please re-enter.");
               c.requestFocusInWindow();
               return false;
          return true;
     public static boolean isInteger(JTextComponent c, String title)
          try
               int i = Integer.parseInt(c.getText());
               return true;
          catch(NumberFormatException e)
               showMessage(c,title+" must be an integer.\n"+"Please re-enter.");
               c.requestFocusInWindow();
               return false;
     private static void showMessage(JTextComponent c, String message)
          JOptionPane.showMessageDialog(c, message, "Invalid Entry", JOptionPane.ERROR_MESSAGE);
}Edited by: kc0poc on Oct 21, 2007 8:17 AM

Ok. Got it, understand it now. Corrected all 58 errors after created the top level classes. It compiles, but I'm now encountering a NullPointerException:
Exception in thread "main" java.lang.NullPointerException
at teamSelectorPanel.fillComboBox(TeamRosterAppTest.java:233)
at teamSelectorPanel.<init>(TeamRosterAppTest.java:214)
at TeamRosterPanel.<init>(TeamRosterAppTest.java:164)
at TeamRosterFrame.<init>(TeamRosterAppTest.java:135)
at TeamRosterAppTest.main(TeamRosterAppTest.java:17)
I think I am not initializing something correctly and it involved the "team" variable. Thoughts anyone?
Thank you as always!
Below is my code:
//Modified by Campbell, Corey 20OCT2007
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.JTextComponent;
import java.util.ArrayList;
import java.text.*;
import java.lang.*;
import java.util.*;
public class TeamRosterAppTest
     public static void main(String[] args)
          TeamIO.getTeam();
          JFrame frame = new TeamRosterFrame();
          frame.setVisible(true);
class Player
     String lname;
     String fname;
     int number;
     public Player()
          lname = "";
          fname = "";
          number = 0;
     public Player(String lname, String fname, int number)
          this.lname = lname;
          this.fname = fname;
          this.number = number;
     public void setLastName(String lname)
          this.lname = lname;
     public String getLastName()
          return lname;
     public void setFirstName(String fname)
          this.fname = fname;
     public String getFirstName()
          return fname;
     public void setNumber(int number)
          this.number = number;
     public int getNumber()
          return number;
class TeamIO
     private static final ArrayList<Player> team = new ArrayList<Player>();
     public static ArrayList<Player> getTeam()
          team.add(new Player("Campbell", "Corey", 69));
          team.add(new Player("Berg", "Laura", 44));
          team.add(new Player("Bustos", "Crystl", 6));
          team.add(new Player("Clark", "Jamie", 24));
          team.add(new Player("Fernandez", "Lisa", 16));
          team.add(new Player("Finch", "Jennie", 27));
          team.add(new Player("Flowers", "Tairia", 11));
          team.add(new Player("Freed", "Amanda", 7));
          team.add(new Player("Giordano", "Nicole", 4));
          team.add(new Player("Harrigan", "Lori", 21));
          team.add(new Player("Jung", "Lovieanne", 3));
          team.add(new Player("Kretchman", "Kelly", 12));
          team.add(new Player("Lappin", "Lauren", 37));
          team.add(new Player("Mendoza", "Jessica", 2));
          team.add(new Player("O'Brien-Amico", "Lisa", 20));
          team.add(new Player("Nuveman", "Stacy", 33));
          team.add(new Player("Osterman", "Catherine", 8));
          team.add(new Player("Topping", "Jennie", 31));
          team.add(new Player("Watley", "Natasha", 29));
          //System.out.println("\nOpening team list" + "\n\n" + "****************************************");
          //for(int i = 0; i < team.size(); i++)
          //          Player p = (Player)team.get(i);
          //          System.out.print(p.getNumber() + "\t" + p.getLastName() + "," + p.getFirstName() + "\n");
          //System.out.println("****************************************");
          return new ArrayList<Player>(team);
     public static ArrayList<Player> saveTeam()
          System.out.println("\nOpening team list" + "\n\n" + "****************************************");
          for(int i = 0; i < team.size(); i++)
               Player p = (Player)team.get(i);
               System.out.print(p.getNumber() + "\t" + p.getLastName() + "," + p.getFirstName() + "\n");
          System.out.println("****************************************");
          return new ArrayList<Player>(team);
class TeamRosterFrame extends JFrame
     public TeamRosterFrame()
          String me = "Campbell, Corey";
          String date;
          Date now = new Date();
          DateFormat longDate = DateFormat.getDateInstance(DateFormat.LONG);
          date = longDate.format(now);
          setTitle("Team Roster "+me+" "+date);
          setResizable(false);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          this.add(new TeamRosterPanel());
          this.pack();
          centerWindow(this);
     private void centerWindow(Window w)
          Toolkit tk = Toolkit.getDefaultToolkit();
          Dimension d = tk.getScreenSize();
          setLocation((d.width-w.getWidth())/2, (d.height-w.getHeight())/2);
class TeamRosterPanel extends JPanel
     ArrayList<Player>team;
     Player newPlayer = null;
     teamSelectorPanel selectorPanel;
     PlayerDisplayPanel playerPanel;
     ButtonPanel buttonPanel;
     public TeamRosterPanel()
          // fill the team ArrayList
          team = TeamIO.getTeam();
          // add the panels
          setLayout(new GridBagLayout());
          selectorPanel = new teamSelectorPanel();
          add(selectorPanel, getConstraints(0,0,1,1, GridBagConstraints.WEST));
          playerPanel = new PlayerDisplayPanel();
          add(playerPanel, getConstraints(0,1,1,1, GridBagConstraints.EAST));
          buttonPanel = new ButtonPanel();
          add(buttonPanel, getConstraints(0,2,1,1, GridBagConstraints.EAST));
          // set the initial player to be displayed
          playerPanel.showPlayer(team.get(0));
          selectorPanel.selectPlayer(team.get(0));
     // a method for setting grid bag constraints
     private GridBagConstraints getConstraints(int gridx, int gridy,
          int gridwidth, int gridheight, int anchor)
          GridBagConstraints c = new GridBagConstraints();
          c.insets = new Insets(5, 5, 5, 5);
          c.ipadx = 0;
          c.ipady = 0;
          c.gridx = gridx;
          c.gridy = gridy;
          c.gridwidth = gridwidth;
          c.gridheight = gridheight;
          c.anchor = anchor;
          return c;
class teamSelectorPanel extends JPanel implements ActionListener
     public JComboBox playerComboBox;
     private JLabel playerLabel;
     boolean filling = false;            // used to indicate the combo box is being filled
     ArrayList<Player>team;
     PlayerDisplayPanel playerPanel;
     public teamSelectorPanel()
          // set panel layout
          setLayout(new FlowLayout(FlowLayout.LEFT));
          // Player label
          playerLabel = new JLabel("Select Player:");
          add(playerLabel);
          // Player combo box
          playerComboBox = new JComboBox();
          fillComboBox(team);
          playerComboBox.addActionListener(this);
          add(playerComboBox);
     public void actionPerformed(ActionEvent e)
          if (!filling)
               Player p = (Player)playerComboBox.getSelectedItem();
               playerPanel.showPlayer(p);
     public void fillComboBox(ArrayList<Player> team)
          filling = true;
          playerComboBox.removeAllItems();
          for (Player p : team)
          playerComboBox.addItem(p);
          filling = false;
     public void selectPlayer(Player p)
          playerComboBox.setSelectedItem(p);
     public Player getCurrentPlayer()
          return (Player) playerComboBox.getSelectedItem();
class PlayerDisplayPanel extends JPanel
     public JTextField lastNameTextField,
          firstNameTextField,
          numberTextField;
     private JLabel lastNameLabel,
          firstNameLabel,
          numberLabel;
     public PlayerDisplayPanel()
          // set panel layout
          setLayout(new GridBagLayout());
          // last name label
          lastNameLabel = new JLabel("Last name:");
          add(lastNameLabel, getConstraints(0,0,1,1, GridBagConstraints.EAST));
          // last name text field
          lastNameTextField = new JTextField(10);
          lastNameTextField.setEditable(false);
          lastNameTextField.setFocusable(false);
          lastNameTextField.addFocusListener(new AutoSelect());
          add(lastNameTextField, getConstraints(1,0,1,1, GridBagConstraints.WEST));
          // first name label
          firstNameLabel = new JLabel("First name:");
          add(firstNameLabel, getConstraints(0,1,1,1, GridBagConstraints.EAST));
          // first name text field
          firstNameTextField = new JTextField(30);
          firstNameTextField.setEditable(false);
          firstNameTextField.setFocusable(false);
          firstNameTextField.addFocusListener(new AutoSelect());
          add(firstNameTextField, getConstraints(1,1,1,1, GridBagConstraints.WEST));
          // number label
          numberLabel = new JLabel("Number:");
          add(numberLabel, getConstraints(0,2,1,1, GridBagConstraints.EAST));
          // number text field
          numberTextField = new JTextField(10);
          numberTextField.setEditable(false);
          numberTextField.setFocusable(false);
          numberTextField.addFocusListener(new AutoSelect());
          numberTextField.addKeyListener(new IntFilter());
          add(numberTextField, getConstraints(1,2,1,1, GridBagConstraints.WEST));
     public void showPlayer(Player p)
          lastNameTextField.setText(p.getLastName());
          firstNameTextField.setText(p.getFirstName());
          numberTextField.setText(String.valueOf(p.getNumber()));
     public void clearFields()
          lastNameTextField.setText("");
          firstNameTextField.setText("");
          numberTextField.setText("");
     // return a new Player object with the data in the text fields
     public Player getPlayer()
          Player p = new Player();
          p.setLastName(lastNameTextField.getText());
          p.setFirstName(firstNameTextField.getText());
          int n = Integer.parseInt(numberTextField.getText());
          p.setNumber(n);
          return p;
     public void setAddEditMode(boolean e)
          lastNameTextField.setEditable(e);
          lastNameTextField.setFocusable(e);
          lastNameTextField.requestFocusInWindow();
          firstNameTextField.setEditable(e);
          firstNameTextField.setFocusable(e);
          numberTextField.setEditable(e);
          numberTextField.setFocusable(e);
     // a method for setting grid bag constraints
     private GridBagConstraints getConstraints(int gridx, int gridy,
          int gridwidth, int gridheight, int anchor)
          GridBagConstraints c = new GridBagConstraints();
          c.insets = new Insets(5, 5, 5, 5);
          c.ipadx = 0;
          c.ipady = 0;
          c.gridx = gridx;
          c.gridy = gridy;
          c.gridwidth = gridwidth;
          c.gridheight = gridheight;
          c.anchor = anchor;
          return c;
class AutoSelect implements FocusListener
     public void focusGained(FocusEvent e)
          if(e.getComponent() instanceof JTextField)
               JTextField t = (JTextField) e.getComponent();
               t.selectAll();
     public void focusLost(FocusEvent e){}
class IntFilter implements KeyListener
     public void keyTyped(KeyEvent e)
          char c = e.getKeyChar();
          if ( c !='0' && c !='1' && c !='2' && c !='3' && c !='4' && c !='5'
               && c !='6' && c !='7' && c !='8' && c !='9')
               e.consume();
     public void keyPressed(KeyEvent e){}
     public void keyReleased(KeyEvent e){}
class ButtonPanel extends JPanel
     public JButton addButton,
          editButton,
          deleteButton,
          acceptButton,
          cancelButton,
          exitButton;
     public ButtonPanel()
          // create maintenance button panel
          JPanel maintPanel = new JPanel();
          maintPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
          // add button
          addButton = new JButton("Add");
          addButton.addActionListener(new AddListener());
          maintPanel.add(addButton);
          // edit button
          editButton = new JButton("Edit");
          editButton.addActionListener(new EditListener());
          maintPanel.add(editButton);
          // delete button
          deleteButton = new JButton("Delete");
          deleteButton.addActionListener(new DeleteListener());
          maintPanel.add(deleteButton);
          // accept button
          acceptButton = new JButton("Accept");
          acceptButton.setEnabled(false);
          acceptButton.addActionListener(new AcceptListener());
          maintPanel.add(acceptButton);
          // cancel button
          cancelButton = new JButton("Cancel");
          cancelButton.setEnabled(false);
          cancelButton.addActionListener(new CancelListener());
          maintPanel.add(cancelButton);
          // create exit button panel
          JPanel exitPanel = new JPanel();
          exitPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
          // exit button
          exitButton = new JButton("Exit");
          exitButton.addActionListener(new ExitListener());
          exitPanel.add(exitButton);
          // add panels to the ButtonPanel
          setLayout(new BorderLayout());
          add(maintPanel, BorderLayout.CENTER);
          add(exitPanel, BorderLayout.SOUTH);
     public void setAddEditMode(boolean e)
          addButton.setEnabled(!e);
          editButton.setEnabled(!e);
          deleteButton.setEnabled(!e);
          acceptButton.setEnabled(e);
          cancelButton.setEnabled(e);
class AddListener implements ActionListener
     PlayerDisplayPanel playerPanel;
     ButtonPanel buttonPanel;
     Player newPlayer;
     public void actionPerformed(ActionEvent e)
          newPlayer = new Player();
          playerPanel.clearFields();
          buttonPanel.setAddEditMode(true);
          playerPanel.setAddEditMode(true);
class EditListener implements ActionListener
     ButtonPanel buttonPanel;
     PlayerDisplayPanel playerPanel;
     public void actionPerformed(ActionEvent e)
          buttonPanel.setAddEditMode(true);
          playerPanel.setAddEditMode(true);
class DeleteListener implements ActionListener
     teamSelectorPanel selectorPanel;
     PlayerDisplayPanel playerPanel;
     ArrayList<Player>team;
     public void actionPerformed(ActionEvent e)
          Player p = selectorPanel.getCurrentPlayer();
          team.remove(p);
          TeamIO.saveTeam();
          selectorPanel.fillComboBox(team);
          selectorPanel.selectPlayer(team.get(0));
          playerPanel.showPlayer(team.get(0));
          selectorPanel.playerComboBox.requestFocusInWindow();
class AcceptListener implements ActionListener
     teamSelectorPanel selectorPanel;
     PlayerDisplayPanel playerPanel;
     ButtonPanel buttonPanel;
     ArrayList<Player>team;
     Player newPlayer;
     public void actionPerformed(ActionEvent e)
          if (isValidData())
               if (newPlayer != null)
                    newPlayer = playerPanel.getPlayer();
                    team.add(newPlayer);
                    TeamIO.saveTeam();
                    selectorPanel.fillComboBox(team);
                    selectorPanel.selectPlayer(newPlayer);
                    newPlayer = null;
               else
                    Player p = selectorPanel.getCurrentPlayer();
                    Player newPlayer = playerPanel.getPlayer();
                    p.setLastName(newPlayer.getLastName());
                    p.setFirstName(newPlayer.getFirstName());
                    p.setNumber(newPlayer.getNumber());
                    TeamIO.saveTeam();
                    selectorPanel.fillComboBox(team);
                    selectorPanel.selectPlayer(p);
                    playerPanel.showPlayer(selectorPanel.getCurrentPlayer());
               playerPanel.setAddEditMode(false);
               buttonPanel.setAddEditMode(false);
               selectorPanel.playerComboBox.requestFocusInWindow();
     public boolean isValidData()
          return SwingValidator.isPresent(playerPanel.lastNameTextField, "Last Name")
               && SwingValidator.isPresent(playerPanel.firstNameTextField, "First Name")
               && SwingValidator.isPresent(playerPanel.numberTextField, "Number")
               && SwingValidator.isInteger(playerPanel.numberTextField, "Number");
class CancelListener implements ActionListener
     Player newPlayer;
     PlayerDisplayPanel playerPanel;
     ButtonPanel buttonPanel;
     teamSelectorPanel selectorPanel;
     public void actionPerformed(ActionEvent e)
          if (newPlayer != null)
               newPlayer = null;
          playerPanel.setAddEditMode(false);
          playerPanel.showPlayer(selectorPanel.getCurrentPlayer());
          buttonPanel.setAddEditMode(false);
          selectorPanel.playerComboBox.requestFocusInWindow();
class ExitListener implements ActionListener
     public void actionPerformed(ActionEvent e)
          System.exit(0);
class SwingValidator
     public static boolean isPresent(JTextComponent c, String title)
          if(c.getText().length()==0)
               showMessage(c, title + " is a required field.\n" + "Please re-enter.");
               c.requestFocusInWindow();
               return false;
          return true;
     public static boolean isInteger(JTextComponent c, String title)
          try
               int i = Integer.parseInt(c.getText());
               return true;
          catch(NumberFormatException e)
               showMessage(c,title+" must be an integer.\n"+"Please re-enter.");
               c.requestFocusInWindow();
               return false;
     private static void showMessage(JTextComponent c, String message)
          JOptionPane.showMessageDialog(c, message, "Invalid Entry", JOptionPane.ERROR_MESSAGE);
}

Similar Messages

  • Class.getResource JNLP issue

    I'm seeing an error when deploying an application via JNLP:
    schema_reference.4: Failed to read schema document 'jar:com/mycompany/my_schema.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>On a Linux machine, running 1.5.0_15-b04, it works fine. On a Windows machine, running 1.5.0_16-b02, it fails.
    The code is attempting to load an XSD as follows (and is failing on the second line):
      URL schemaURL = MyClass.class.getResource("my_schema.xsd");
      SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaURL);On the Linux machine, where it works, the URL returned from the "getResource" call looks like:
    jar:file:/path/to/containing.jar!/com/mycompany/my_schema.xsd
    On the Windows machine, where it fails, the URL returned from the "getResource" call looks like:
    jar:com/mycompany/my_schema.xsd
    The same JARs are being run via JNLP on both machines.
    I found that getting an InputStream instead of an URL (via MyClass.class.getResourceAsStream("my_schema.xsd")) and passing that into the newSchema call with a new StreamSource works if the schema is completely self-contained. However, one schema I work with is extremely large and is broken into many different files via "<xs:include schemaLocation=""/>". This schema does not appear to load correctly via getResourceAsStream.
    I suspect this may be a classloader issue inside JNLP. When I run the application using the same JARs via javaw on the Windows machine, everything works.
    What am I doing wrong and how do I go about working around/fixing this issue?
    Thanks,
    --David                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Here is some code that works around the issue:
        public static URL getResource(Class clazz, String name) {
            // Get the URL for the resource using the standard behavior
            URL result = clazz.getResource(name);
            // Check to see that the URL is not null and that it's a JAR URL.
            if (result != null && "jar".equalsIgnoreCase(result.getProtocol())) {
                // Get the URL to the "clazz" itself.  In a JNLP environment, the "getProtectionDomain" call should succeed only with properly signed JARs.
                URL classSourceLocationURL = clazz.getProtectionDomain().getCodeSource().getLocation();
                // Create a String which embeds the classSourceLocationURL in a JAR URL referencing the desired resource.
                String urlString = MessageFormat.format("jar:{0}!/{1}/{2}", classSourceLocationURL.toExternalForm(), packageNameOfClass(clazz).replaceAll("\\.", "/"), name);
                // Check to see that new URL differs.  There's no reason to instantiate a new URL if the external forms are identical (as happens on pre-1.5.0_16 builds of the JDK).
                if (urlString.equals(result.toExternalForm()) == false) {
                    // The URLs are different, try instantiating the new URL.
                    try {
                        result = new URL(urlString);
                    } catch (MalformedURLException malformedURLException) {
                        throw new RuntimeException(malformedURLException);
            return result;
        public static String packageNameOfClass(Class clazz) {
            String result = "";
            String className = clazz.getName();
            int lastPeriod = className.lastIndexOf(".");
            if (lastPeriod > -1) {
                result = className.substring(0, lastPeriod);
            return result;
        }There are two additional work-arounds:
    1. Use Class.getResourceAsStream(String). However this doesn't work in the case of XSDs that use <xs:include> to include other XSDs via relative pathing.
    2. A real hack: Class.getResource("MyResource.txt").openConnection().getURL().

  • Any way to assign value for  variable of type Class List String ?

    I'm puzzled why I can declare a variable:
    Class<List<String>> clazz;but I cannot assign a value to it as
    clazz = List<String>.class;The compiler also complains about
    Class<List<?>> clazz0 = List<?>.class;yet it has the nerve to warn about raw types when I give up and use
    Class<List> clazz0 = List.class;Even using a dummy instance does not work.
            List<String> dummy = new ArrayList<String>();
            Class<List<String>> clazz1 = dummy.getClass();I only care because I've declared a method like
    public String useless( Class<List<String>> unSetable){
      return  unSetable.getName();
    }And now there seems to be no way to call it.

    Hello chymes,
    there is no way to get an instance of Class<List<String>> without at least one unchecked warning. Otherwise you could get away with the following:
    List<Integer> ints = new ArrayList<Integer>();
    Class<List<String>> clazz = List<String>.class;
    List<String> strings = clazz.cast(ints);
    strings.add("No Good");
    int i = ints.get(0); // CCETherefore the only way to get it is via unchecked cast:
    Class<List<String>> clazz = (Class<List<String>>) (Object) List.class;With kind regards
    Ben

  • Newbie request.getParameter(String) issue

    I'm having an issue setting a boolean value in a bean based off a string from request.getParameter(). I've created a small example to illustrate what I want to happen:
    testForm.jsp:
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
        <title>testForm</title>
      </head>
      <body><form method="POST" action="testWork.jsp">
          <input type="hidden" name="hiddenTest" value="1"/>
          <input type="submit" name="submitTest" value="Submit"/>
        </form></body>
    </html>testWork.jsp:
    <jsp:useBean id="test" scope="session"
                 class="thistestapp.testClass"/>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
        <title>testWork</title>
      </head>
      <body>
      <%
      out.print("<p>" + request.getParameter("hiddenTest") + "</p>" );
      // Great it's sending "1"
      test.setTestB(request.getParameter("hiddenTest"));
      //So when I set this in the bean I should get true
      out.print("<p>" + test.getTestB() + "</p>" ); 
      //False? Not nice!!
      test.setTestB("1");
      //Alright there must be an issue with my code in the bean, so hardcode a
      //"1" in.  I should still get false.
      out.print("<p>" + test.getTestB() + "</p>" );
      //True?? I hate you.
      %>
      </body>
    </html>testClass.java:
    package thistestapp;
    public class testClass {
        private Boolean testB;
        public void setTestB(String testB) {
            if ( testB == "1"){
               this.testB = true;
            else{
               this.testB = false;
        public Boolean getTestB() {
            return testB;
    }So, I want when the bean is sent a "1" from the form to set the bean value to true. I however can't get that to happen. I'm sure there's something I'm missing.
    TIA.
    Joe

    ? if ( testB == "1"){
    Standard beginner's error. If you want to test if two strings contain the same text, use the equals() method. Like this:if ( testB.equals("1")){Your code tests whether the two sides of the == operator refer to the same object. It's possible and likely for two different strings to contain the same value, which is what you are really interested in.

  • Moving a method from one class to another issues

    Hi, im new. Let me explain what i am trying to achieve. I am basically trying to move a method from one class to another in order to refactor the code. However every time i do, the program stops working and i am struggling. I have literally tried 30 times these last two days. Can some one help please? If shown once i should be ok, i pick up quickly.
    Help would seriously be appreciated.
    Class trying to move from, given that this is an extraction:
    class GACanvas extends Panel implements ActionListener, Runnable {
    private WorldMenuItems speedMenuItems, designMenuItemsPlantGrowth, designMenuItemsPlantCount;
         private WorldMenuItems designMenuItemsPlantEaten, designMenuItemsApproximatePopulation;
         private WorldMenuItems designMenuItemsEatersBorn,designMenuItemsMutationProbability;
         private WorldMenuItems designMenuItemsCrossoverProbability;
    MenuBar getMenuBar() {
              menuBar = new MenuBar();
              addControlItemsToMenuBar();
              addSpeedItemsToMenuBar();
              addWorldDesignItemsToMenuBar();
              return menuBar;
    This is the method i am trying to move (below)
    public void itemsInsideWorldDesignMenu() {
              designMenuItemsPlantGrowth = new WorldMenuItems("Plants Grow",
                        new String[] { "In Rows", "In Clumps", "At Random",
                                  "Along the Bottom", "Along the Edges" }, 1);
              designMenuItemsPlantCount = new WorldMenuItems("Number Of Plants",
                        new String[] { "50", "100", "150", "250", "500" }, 3);
              designMenuItemsPlantEaten = new WorldMenuItems("When a Plant is Eaten",
                        new String[] { "It grows back somewhere",
                                  "It grows back nearby", "It's Gone" }, 0);
              designMenuItemsApproximatePopulation = new WorldMenuItems(
                        "Approximate Population", new String[] { "10", "20", "25",
                                  "30", "40", "50", "75", "100" }, 2);
              designMenuItemsEatersBorn = new WorldMenuItems("Eaters are Born",
                        new String[] { "At the Center", "In a Corner",
                                  "At Random Location", "At Parent's Location" }, 2);
              designMenuItemsMutationProbability = new WorldMenuItems(
                        "Mutation Probability", new String[] { "Zero", "0.25%", "0.5%",
                                  "1%", "2%", "3%", "5%", "10%" }, 3);
              designMenuItemsCrossoverProbability = new WorldMenuItems(
                        "Crossover Probability", new String[] { "Zero", "10%", "25%",
                                  "50%", "75%", "100%" }, 4);
    Class Trying to move to:
    class WorldMenuItems extends Menu implements ItemListener {
       private CheckboxMenuItem[] items;
       private int selectedIndex = -1;
       WorldMenuItems(String menuName, String[] itemNames) {
          this(menuName, itemNames, -1);
       WorldMenuItems(String menuName, String[] itemNames, int selected) {
          super(menuName);
          items = new CheckboxMenuItem[itemNames.length];
          for (int i = 0; i < itemNames.length; i++) {
             items[i] = new CheckboxMenuItem(itemNames);
    add(items[i]);
    items[i].addItemListener(this);
    selectedIndex = selected;
    if (selectedIndex < 0 || selectedIndex >= items.length)
    selectedIndex = 1;
    items[selectedIndex].setState(true);
         public int getSelectedIndex() {
              return selectedIndex;
    public void itemStateChanged(ItemEvent evt) {  // This works on other systems
    CheckboxMenuItem newSelection = (CheckboxMenuItem)evt.getSource();
    for (int i = 0; i < items.length; i++) {
    if (newSelection == items[i]) {
    items[selectedIndex].setState(false);
    selectedIndex = i;
    newSelection.setState(true);
    return;

    Ok i've done this. I am getting an error on the line specified. Can someone help me out and tell me what i need to do?
    GACanvas
    //IM GETTING AN ERROR ON THIS LINE UNDER NAME, SAYING IT IS NOT VISIBLE
    WorldMenuItems worldmenuitems = new WorldMenuItems(name, null);
    public MenuBar getMenuBar() {
              menuBar = new MenuBar();
              addControlItemsToMenuBar();
              addSpeedItemsToMenuBar();
              worldmenuitems.addWorldDesignItemsToMenuBar();
              return menuBar;
    class WorldMenuItems extends Menu implements ItemListener {
         private WorldMenuItems speedMenuItems, designMenuItemsPlantGrowth, designMenuItemsPlantCount;
         private WorldMenuItems designMenuItemsPlantEaten, designMenuItemsApproximatePopulation;
         private WorldMenuItems designMenuItemsEatersBorn,designMenuItemsMutationProbability;
         private WorldMenuItems designMenuItemsCrossoverProbability;
         GACanvas gacanvas = new GACanvas(null);
       private CheckboxMenuItem[] items;
       private int selectedIndex = -1;
       WorldMenuItems(String menuName, String[] itemNames) {
          this(menuName, itemNames, -1);
       WorldMenuItems(String menuName, String[] itemNames, int selected) {
          super(menuName);
          items = new CheckboxMenuItem[itemNames.length];
          for (int i = 0; i < itemNames.length; i++) {
             items[i] = new CheckboxMenuItem(itemNames);
    add(items[i]);
    items[i].addItemListener(this);
    selectedIndex = selected;
    if (selectedIndex < 0 || selectedIndex >= items.length)
    selectedIndex = 1;
    items[selectedIndex].setState(true);
         public int getSelectedIndex() {
              return selectedIndex;
    public void itemStateChanged(ItemEvent evt) {  // This works on other systems
    CheckboxMenuItem newSelection = (CheckboxMenuItem)evt.getSource();
    for (int i = 0; i < items.length; i++) {
    if (newSelection == items[i]) {
    items[selectedIndex].setState(false);
    selectedIndex = i;
    newSelection.setState(true);
    return;
    public void itemsInsideWorldDesignMenu() {
         designMenuItemsPlantGrowth = new WorldMenuItems("Plants Grow",
                   new String[] { "In Rows", "In Clumps", "At Random",
                             "Along the Bottom", "Along the Edges" }, 1);
         designMenuItemsPlantCount = new WorldMenuItems("Number Of Plants",
                   new String[] { "50", "100", "150", "250", "500" }, 3);
         designMenuItemsPlantEaten = new WorldMenuItems("When a Plant is Eaten",
                   new String[] { "It grows back somewhere",
                             "It grows back nearby", "It's Gone" }, 0);
         designMenuItemsApproximatePopulation = new WorldMenuItems(
                   "Approximate Population", new String[] { "10", "20", "25",
                             "30", "40", "50", "75", "100" }, 2);
         designMenuItemsEatersBorn = new WorldMenuItems("Eaters are Born",
                   new String[] { "At the Center", "In a Corner",
                             "At Random Location", "At Parent's Location" }, 2);
         designMenuItemsMutationProbability = new WorldMenuItems(
                   "Mutation Probability", new String[] { "Zero", "0.25%", "0.5%",
                             "1%", "2%", "3%", "5%", "10%" }, 3);
         designMenuItemsCrossoverProbability = new WorldMenuItems(
                   "Crossover Probability", new String[] { "Zero", "10%", "25%",
                             "50%", "75%", "100%" }, 4);
    public void addWorldDesignItemsToMenuBar() {
         gacanvas = new GACanvas(null);
         itemsInsideWorldDesignMenu();
         Menu designMenuItems = new Menu("WorldDesign");
         designMenuItems.add(designMenuItemsPlantGrowth);
         designMenuItems.add(designMenuItemsPlantCount);
         designMenuItems.add(designMenuItemsPlantEaten);
         designMenuItems.add(designMenuItemsApproximatePopulation);
         designMenuItems.add(designMenuItemsEatersBorn);
         designMenuItems.add(designMenuItemsMutationProbability);
         designMenuItems.add(designMenuItemsCrossoverProbability);
         gacanvas.menuBar.add(designMenuItems);

  • Weird   String[][] issue

    Hey all ,
    Just need some help for this bidimensional Array .
    I just want to do x [20][15] = "j";
    But the ouput shows position x[0][0] also with "j" and not with "."
    here it's the code:
    public void desenhaquadro(String [][] x){
              for(int i =1; i != x.length; i++){
                   for(int j= 1; j != x.length; j++){
                        if(x[i][j] == x[20][15]){
                             System.out.print(x[20][15] = "j");                         
                        }else System.out.print(x[i][j] = ".");
                   } System.out.println();
    thanks

    public class Tabuleiro {
         public void drawboard(String[][] x) {
              for (int i = 0; i != x.length; i++) {
                   for (int j = 0; j != x.length; j++) {
                        if (i == 20 && j == 15) {
                             x[i][j] = "L";
                             System.out.print(x[20][15]);
                        } else
                             System.out.print(x[i][j] = ".");
                   System.out.println();
         public static void main(String[] xxx) {
              Tabuleiro tabu = new Tabuleiro();
              final int numLines = 28;
              final int numColu = 48;
              String[][] y = new String[numLines][numColu];
              tabu.drawboard(y);
    This works for me. Part of the problem is you are using == to compare strings when you do
    if(x[i][j] == x[20][15])the other problem is that since you have not populated the array, every element in the array is null, so even if you do x[i][j].equals(x[20][15]) it will give you the wrong answer.
    Message was edited by:
    SomeoneElse
    Message was edited by:
    SomeoneElse

  • Template member function of a class template specialisation issue

    The following bit of code from gmock (http://code.google.com/p/googlemock/) caused CC 5.9 ( and Studio Express) to emit:
    "./include/gmock/gmock-printers.h", line 418: Error: static testing::internal::TuplePrefixPrinter<testing::internal::N>::PrintPrefixTo<testing::internal::TuplePrefixPrinter<testing::internal::N>::Tuple>(const testing::internal::TuplePrefixPrinter<testing::internal::N>::Tuple&, std::ostream *) already had a body defined.
    Code:
    template <size_t N>
    struct TuplePrefixPrinter {
    // Prints the first N fields of a tuple.
    template <typename Tuple>
    static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
    TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
    *os << ", ";
    UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type>
    ::Print(::std::tr1::get<N - 1>(t), os);
    // Tersely prints the first N fields of a tuple to a string vector,
    // one element for each field.
    template <typename Tuple>
    static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
    TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
    ::std::stringstream ss;
    UniversalTersePrint(::std::tr1::get<N - 1>(t), &ss);
    strings->push_back(ss.str());
    template <>
    template <typename Tuple>
    void TuplePrefixPrinter<1>::PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
    UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
    Print(::std::tr1::get<0>(t), os);
    Removing the inline definition of TuplePrefixPrinter from the class and adding it after the specialisation fixed the issue.
    Ian.

    Hi, Ian. Please file a bug report at bugs.sun.com so we can track the problem.
    - Steve

  • Strings issues

    I need to write a simple code for something like this:
    Write a program that analyzes a string as follows:
    a.     indicate if it ends with the three letters ing string compare = stringname.getChars(iend, 3);
    b.     
    c.     Print out the length of the string int count = stringname.length();
    d.     Print out the first character in the string string fdsdfs = stringname.getChars(istart, 1);
    e.     Print out the the second, through ninth character in the string
    f.     Print out the string in all lowercase letters
    You should look at the methods defined for the String class in both your textbook and in the API to see if there are any that will make the analysis of this string easier.
    Output:     (given that the string was ?I love to program in Java.?)
         ing ending: no
              length: 26
              first char: I
              chars 2-9: love to
              lowercase: i love to program in java.
    Create this program procedurally ? with the main method
    Any one?

    you are so nice Melanie, lol. I did not know what I am getting myself into. Anyway I needed a technical class for my degree and I chose this one cause I thought it will be easy, but the teacher I have just from the first class gave us 7 quick labs to write like I am a fu*ing programmer. I do not like programing and I just need to pass the class. I am reading the book but it does not make sense. For you people that have some knowledge about programming I am sure it is easy, and yes I would love for someone to do the homework for me as I do not actually need to learn programming. Like I said it is Java1 and for a person that does not have any knowledge about programming to start writing 7 labs it is not easy, so please stop being sarcastic and say I do not wanna do it or help me. I did this with someone help and with what I could find on the net, but I still do not understand much. You guys if you wanna help you could tell me go here or there and give me some examples of similar code, that is how it is helpful not being sarcastic.
    Ya and here is the code that I did but not with your guys sarcastic answers. I need help not sarcastic answers. If I post something it is because I do not know how to start, where to start.
    * Strings.java
    import javax.swing.JOptionPane;
    public class Strings {
    public static void main(String [] args) {
         String s = (String)JOptionPane.showInputDialog("Type a string:\n");
         JOptionPane.showMessageDialog(null,
                                                      "ing ending:"+( (s.endsWith("ing")) ? "yes" : "no" )+
                                                      "\nlength:"+s.length()+
                                                      "\nfirst char:"+s.charAt(0)+
                                                      "\nchars 2-9:"+s.substring(2,9)+
                                                      "\nlowercase:"+s.toLowerCase()
    }

  • Jabber for Windows v9.1 FCS - Dial String Issue

    I thought the capability to cut and past phone numbers that started with a "(" was fixed in the newere version of J4W.
    I just tried a copy/paste of a number pulled from the internet, but Jabber doesn't recognize it as a phone number.
    A number that is entered in this format of  (202) 762 1401 is not recognized as a dialable string.  If I delete the first "(" then it is recognized and can be dialed.  I can even put the "(" back and the number is still recognized as a dialable string.
    Please let me know if this is still an outstanding issue, bug, or what.
    Thanks,
    Arras

    Hi Arras,
    Thanks for reporting this problem. I have created a defect for tracking.
    CSCud05630: Jabber doesn't recognize number format starting with (xxx)
    This will be prioritized in due course for a future release.
    Thanks,
    Maqsood

  • Function Module GUI_DOWNLOAD: Type String Issue

    I am working in 4.6C. I have used this Function Module many times in the past without issue, but not at this site. It abends and gives me the error message:
    The call to the function module "GUI_DOWNLOAD" is incorrect:                                                                               
    The function module interface allows you to specify only fields          
    of a particular type under "FILENAME". The field "FNAME" specified here  
    has a different field type.                                              
    Here is the field declaration in the code:
    PARAMETER: fname type rlgrap-filename DEFAULT 'C:/New_PO_Format.xls'.
    The import parameter in GUI_DOWNLOAD for FILENAME is type STRING. When I double click on STRING in the FM I get "Unable to find a tool to process request". And, TYPE STRING does not exist in the system? I started making a Z version of GUI_DOWNLOAD, but it started giving me headaches because I had to start copying other SAP function modules.
    Am I missing something? Or, is there a new and improved version of GUI_DOWNLOAD to use?

    data : v_file type string.
    PARAMETER: fname type rlgrap-filename DEFAULT 'C:/New_PO_Format.xls'.
    start-of-selection.
    v_file = fname.
    use v_file in gui_download parameter.
    Thanks
    Seshu

  • Register plugin in OIM11g-class not found issue

    Hi All,
    I have a plugin created and imported the metadata.
    I have also made the plugin.zip with the necessary structure.
    now whenever i restart my oim to see if my plugin has been initialized its gives
    <Aug 8, 2011 9:03:06 AM CEST> <Error> <oracle.iam.platform.pluginframework> <IAM-1050006> <An error occurred while loading the plugin class. Class com.test.oim.adapter.entity.testwas not found.>
    any guesses what cd be the issue
    I have double ckeced witth my pakage structure,n didnt found any typo mistake as such

    Did you resolve this issue? Is it something related to compilation issue?

  • I have a minor string issue

    Been looking at the code all day but if I can get a little help this would be great...
    I have a hashtable of buttons and strings and i run a loop to see if they are true...
    public static String checkCaja()
           String temp="";
           for(String name:checkboxes.keySet()){
               // System.out.println(checkboxes.get(name).isSelected()+name);
                if (checkboxes.get(name).isSelected()==true)
                     temp=temp+name+",";
         return temp;
      }the temp returns the strings with an ','. So I will get a
    From one,two,three,four, five,
    I would like to remove the last comma from the last word added... any ideas?
    It should look like one, two,three,four,five
    Thank you in advance!

    As long as we are tweaking code, when you're iterating over names and values, you should use the entry set:
    String f(Map<String, JCheckBox> checkboxes) {
        StringBuffer sb = new StringBuffer();
        for(Map.Entry < String, JCheckBox > e : checkboxes.entrySet()) {
            if(e.getValue().isSelected()) {
                if (sb.length() > 0)
                    sb.append(", ");
                sb.append(e.getKey());
        return sb.toString();
    }I would also go with adding the delimiter every time, then substringing to remove the last one, if any:
    String f(Map<String, JCheckBox> checkboxes) {
        String DELIM = ", ";
        StringBuffer sb = new StringBuffer();
        for(Map.Entry < String, JCheckBox > e : checkboxes.entrySet())
            if(e.getValue().isSelected())
                sb.append(e.getKey()).append(DELIM);
        String s = sb.toString();
        int length = s.length();
        return length > 0 ? s.substring(0, length - DELIM.length()) : s;
    }

  • Class has be instantiated in document class but having issue..HELP

    Guys,
    I am making my way with AS3 in little steps and have hit a
    road block. This is what I have:
    I have a document class called "Document Class"
    I have a custom class called "Game"
    I have instantiated an object of "Game" class and I am able
    to trace a class method which return a simple "HELLO".
    within my Game class, I have a variable(type Array) called
    "questions" as instance variable.
    I would like to add questions to "questions" array by using
    "Mutator" method, or count the current elements with the questions
    array and return the total number of questions. I am unable to add
    or access elements to the questions array.
    Any help would highly be appreciated, please.

    First thing: you need to set the functions you're calling to
    public, so that you have access to them outside of your class.
    Second: you are initializing 'questions' to null. I made some
    changes and it seems to work for me:
    //////////////Game
    Class///////////////////////////////////////////////
    public function Game()
    //this.questions = null;
    this.correctAnswers = null;
    this.userAnswers = null;
    // SETQUESTION FUNCTION CAN ADD QUESTIONS TO THE QUESTION
    ARRAY;
    public function myArr():void
    trace(questions.length);
    public function AddQuestions(val:String)
    this.questions.push(val);
    trace(val);
    }

  • How to use the Class.getMethod(String name, Class[] paramArrays)

    Hi,
    I've a problem with the .getMethod method. I've search solutions in the tutorials but I haven't found sorry.
    I'm trying to copy a method from a Class named carre in a reference named m. But I don't understand the second part of the parameters. How can I write parameters in a Class array ?
    Method m = Carre.class.getMethod("getYou", args) ; //It doesn't work, because args is a String array, not a Class array, my parameters would be double.
    Could you help me ? Thanks for answers.

    Class[] classArray = { new Double().getClass(), new String().getClass()};That's not what you want to write. That generates two objects unnecessarily. You should write:new Class[] { Double.class, String.class };

  • Classes and Methods Issues

    I can't seem to figure out how to get a method to print without returning to main. I am importing time from the method just above this one but cannot make it a constant because I change the time later on in the program. Nor can I change the main program. This is the code snippet of the method...
         public void convert(int time)
              /*convert*/     
              if (time < 12)
                   System.out.println(time + " months have gone by.");
              else if (time > 12)
                        int years = time / 12;
                        int months = time % 12;
                        System.out.print(years + " year(s) and " + months + " month(s) have passed.");
    This is the call to that snippet in main...
         /*calling the method convert() in class homes*/
         homes.convert(time);
    This is the error that I get...
    Exception in thread "main" java.lang.NoSuchMethodError: homes.convert(I)I
    at HomeTime.main(HomeTime.java:28)

    This code shouldn't be compiling if you are getting the error you are.
    My guess is that you have not compiled all of your classes, or you have a mixture of old and new classes in the same classpath.
    Also, make sure that your methods are declared inside the class - not inside methods inside the class. I've seen some folks who are new to Java make the mistake of trying to declare a method inside the main() method.
    If the code is actually compiling without any errors, please post what you've got (read the help file on how to post code to the forum first!) and I'll give it a shot.
    - Kevin

Maybe you are looking for

  • Failure of EXECUTE IMMEDIATE when in a stored procedure

    Hello, this concerns behaviour observed in Oracle 10g on Windows. As user "system", I execute from the command line the following: SQL> select COUNT(1) from sys.dba_sequences; COUNT(1) 645 Again I try the same thing from the command line: SQL> declar

  • Why won't imovie '11 finalize or prepare my project??

    why won't imovie '11 finalize or prepare my project?? Just an error message. I've made many videos before with NO issues.

  • Displaying Playlist on iPod by Artist

    Hi there, does anyone know, if it is possible, to display a playlist on my iPod by Artist. As long as I use iPods, they only show the song titles in the playlists. that's awfull if you use a intelligent playlist (example: for the last 3 months) and y

  • Verizon DSL/Router

    Hi! I'd really appreciate it very much if anyone out there could help me with the procedure/mechanics on setting up or creating a password to my Verizon dsl/router so that my neighbors would not be able to access the net using my dsl connection. I've

  • Mac 10.5.8 VS Photosmart B109n-z: connection problem

    Hi, i've got a problem with my brand new Photosmart B109n-z. Two days ago I've installed the software and connected my Mac 10.5 to the printer. I've successfully spent few minutes printing docs wirelessly. Then i turned off Mac & printer and went to