Scrollsetbounds230

This preview shows page 2 - 4 out of 4 pages.

scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scroll.setBounds(230, 112, 247, 100); frame.getContentPane().add(scroll, BorderLayout.CENTER ); textField_2.setColumns(10); textField.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { if(e.getKeyChar() == '\n') { if(textField.getText() == null || textField.getText().equals("")) return; int m = Integer.parseInt(textField.getText()); shapes = new Polygon3[m]; } } }); textField_1.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { if(e.getKeyChar() == '\n') { if(textField_1.getText() == null || textField_1.getText().equals("")) return; if(i == shapes.length){ JOptionPane.showMessageDialog(null,"Max reached", "Alert", JOptionPane.INFORMATION_MESSAGE); return; } shapes[i] = new Polygon3(i, Integer.parseInt(textField_1.getText()));
Image of page 2

Subscribe to view the full document.

str += "array "+i+" has "+shapes[i].getSides()+" sides. \n"; textField_2.setText(str); i++; textField_1.setText(null); } } }); } public static Polygon3[] create(){ int m = Integer.parseInt(textField.getText()); shapes = new Polygon3[m]; shapes[i] = new Polygon3(i, Integer.parseInt(textField_1.getText())); textField_1.setText(null); str += "array "+i+" has "+shapes[i].getSides()+" sides. \n"; textField_2.setText(str); i++; //} return shapes; } private static ArrayList<Integer> typesearch() { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); ArrayList<Integer> myList = new ArrayList<Integer>(); System.out.println("Array Length: "+Array.getLength(shapes)); if(Array.getLength(shapes)>0){ System.out.println("Enter number of sides"); int sides = in.nextInt(); for(int i=0;i<Array.getLength(shapes);i++){ if(shapes[i].getSides()==sides) { myList.add(i); } } if(myList.size()==0){ System.out.println("No Polygon2s to view!"); } else{ System.out.println(myList);} //can't print list } else{ System.out.println("No Polygon2s to view!"); } return myList; } } class Polygon3{ private int id;
Image of page 3
private int sides=0; Polygon3(int id,int sides){ this.id = id; this.setSides(sides); } public int getSides() { return sides; } public void setSides(int sides) { this.sides = sides; } }
Image of page 4
You've reached the end of this preview.
  • Fall '08
  • STAFF
  • Return statement, Void type, private JFrame frame

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern