Home > Back-end >  Always instantiate the type, how to solve
Always instantiate the type, how to solve

Time:09-22

Always instantiate the type, how to solve ah, online, etc., very urgent

CodePudding user response:

Baidu should have a lot of answers,

CodePudding user response:

reference 1st floor SXZLC response:
baidu should have a lot of answers,

Well, if not on baidu search less than, I come to this post section in

CodePudding user response:

Add a default constructor

CodePudding user response:

Or your new is the abstract class

CodePudding user response:

The
reference reply slip into a man of all ages: 3/f
add a default constructor

Please proceed with your performance

CodePudding user response:

Post your code

CodePudding user response:

refer to 6th floor usecf response:
your code post

Package awtDemo;

Import the Java. The awt. BorderLayout.
Import the Java. The awt. Color;
Import the Java. The awt. Dimension;
Import the Java. The awt. FlowLayout;

The import javax.mail. Swing. JButton;
The import javax.mail. Swing. JFrame;
The import javax.mail. Swing. JPanel;

@ SuppressWarnings (" serial ")
Public class DrawMain extends JPanel {
Public static void main (String [] args) {
//TODO Auto - generated method stub
DrawMain the Draw=new DrawMain ();
The Draw. The InitUI ();
}
Public void InitUI () {
JFrame jf=new JFrame ();
Jf. SetSize (1000, 780);
Jf. SetTitle (" simple drawing board ");
Jf. SetDefaultCloseOperation (3);
Jf. SetLocationRelativeTo (null);
jf.setLayout(new BorderLayout());
//class instantiation event listeners
DrawListener dl=new DrawListener (this);
//the middle panel
Enclosing setBackground (Color. WHITE);
Jf. Add (this, BorderLayout. CENTER);
//implementation properties panel
JPanel ShapePanel=new JPanel ();
ShapePanel. SetBackground (Color black);
ShapePanel. SetLayout (new FlowLayout (FlowLayout. CENTER));
ShapePanel. SetBackground (Color. Gray);
;
String [] Shape={" linear ", "curve", "round", "gun", "eraser" and "rectangle", "oval" and "rectangle",
"Arc", "polygon", "graphic", "triangle", "stereoscopic round,"};
for (int i=0; i JButton button=new JButton (Shape [I]);
Button. SetBackground (Color. WHITE);
Button. AddActionListener (dl);//add event monitoring mechanism
ShapePanel. Add (button);
}
Jf. Add (ShapePanel, BorderLayout. NORTH);
//implementation color panel
JPanel ColorPanel=new JPanel ();
ColorPanel. SetBackground (Color black);
ColorPanel. SetLayout (new FlowLayout (FlowLayout. CENTER));
ColorPanel. SetBackground (Color. Gray);
;
Color [] Color={Color. BLACK, Color blue, Color, white, Color, gray,
Color. Red Color. CYAN, Color green, Color, darkGray, Color. Pink};
for (int i=0; i JButton button=new JButton ();
Button. AddActionListener (dl);//add event monitoring mechanism


CodePudding user response:

Your code is not complete?
DrawListener event?I dropped my DrawListener annotation, run the next problem

CodePudding user response:

CodePudding user response:

references 9 f usecf response:

Well, I was a new sprout

CodePudding user response:

refer to the eighth floor usecf response:
your code is not complete?
DrawListener event?I dropped my DrawListener annotation, run the next problem

What ah,??????

CodePudding user response:

Package com. Ar;
Import the Java. The awt. BorderLayout.
Import the Java. The awt. Color;
Import the Java. The awt. Dimension;
Import the Java. The awt. FlowLayout;

The import javax.mail. Swing. JButton;
The import javax.mail. Swing. JFrame;
The import javax.mail. Swing. JPanel;

@ SuppressWarnings (" serial ")
Public class DrawMain extends JPanel {
Public static void main (String [] args) {
//TODO Auto - generated method stub
DrawMain the Draw=new DrawMain ();
The Draw. The InitUI ();
}
Public void InitUI () {
JFrame jf=new JFrame ();
Jf. SetSize (1000, 780);
Jf. SetTitle (" simple drawing board ");
Jf. SetDefaultCloseOperation (3);
Jf. SetLocationRelativeTo (null);
jf.setLayout(new BorderLayout());
//class instantiation event listeners
//DrawListener dl=new DrawListener (this);
//the middle panel
Enclosing setBackground (Color. WHITE);
Jf. Add (this, BorderLayout. CENTER);
//implementation properties panel
JPanel ShapePanel=new JPanel ();
ShapePanel. SetBackground (Color black);
ShapePanel. SetLayout (new FlowLayout (FlowLayout. CENTER));
ShapePanel. SetBackground (Color. Gray);

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related