The code would be public class h2classi private int x

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

give it the value of 24 is to have a class constructor. The code would be: public class H2ClassI { private int x; public H2ClassI( int h) { x=h; } public static void main (String[] args) { H2ClassI h = new H2ClassI(24); } 9. }The problem with this code is that MouseListener is an abstract class. This means that all the unimplemented methods must be added. import javax.swing.*; import java.awt.event.*; public class H2ClassJ extends JFrame { public static final long serialVersionUID = 22; public H2ClassJ () { addMouseListener ( new MouseListener () { public void mouseClicked (MouseEvent e) { } @Override public void mousePressed (MouseEvent e) { } @Override public void mouseReleased (MouseEvent e) { } @Override public void mouseEntered (MouseEvent e) { } @Override public void mouseExited (MouseEvent e) { } }); } }
Image of page 3

Subscribe to view the full document.

10. When compiling this code, the warning is “unchecked call to JComboBox(E[]) as a member of the raw type JComboBox. Where E is a type-variable: E extends Object declared in class JComboBox”. To fix this, change the code into: import javax.swing.*; import javax.swing.*; public class H2ClassK { String [] sa = {"a", "b", "c"}; JComboBox<String> jcbA = new JComboBox<String> (sa); }
Image of page 4
You've reached the end of this preview.
  • Spring '17
  • Ajani
  • public class H2ClassA

{[ 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