私のコードに何が間違っているのかわかりません。エラーメッセージ: エラー:(122,74)java:互換性のない型:java.awt.Pointをdoubleに変換できない エラー:(119,74)java:互換性のない型:java.awt.Point (112、23)は、Java: エラーをdoubleに変換することができない方法ドロー(java.awt.Graphics) 場所:タイプjavafx.scene.shape.Circleの可変drawCircle描画プログラム:エラーが発生し続ける理由を把握できません
import javafx.scene.shape.Circle;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
import java.util.Iterator;
/**
* Michael VanKlompenberg
* Date: 11/5/2016.
* CIS 117 Java Programming 1
* Description:
*/
public class DrawingProgram {
public static void main(String[] args) {
DrawingFrame f = new DrawingFrame();
f.setTitle("Drawing Program");
f.setSize(462, 312);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
class circle {
private int size;
private Point point;
private Color color;
public circle(int size, Point point, Color color) {
this.size = size;
this.point = point;
this.color = color;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public Point getPoint() {
return point;
}
public void setPoint(Point point) {
this.point = point;
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public void draw(Graphics g){
g.setColor(color);
g.fillOval(getPoint().x,getPoint().y, size,size);
}
}
class DrawingPanel extends JPanel implements MouseMotionListener {
private int circleDiameter;
private Color circleColor;
private Circle drawingCircle;
private ArrayList<Circle> circleArrayList = new ArrayList<Circle>();
public int getCircleDiameter() {
return circleDiameter;
}
public void setCircleDiameter(int circleDiameter) {
this.circleDiameter = circleDiameter;
}
public Color getCircleColor() {
return circleColor;
}
public void setCircleColor(Color circleColor) {
this.circleColor = circleColor;
}
public Circle getDrawingCircle() {
return drawingCircle;
}
public void setDrawingCircle(Circle drawingCircle) {
this.drawingCircle = drawingCircle;
}
public DrawingPanel(int circleDiameter, Color circleColor) {
this.circleDiameter = circleDiameter;
this.circleColor = circleColor;
addMouseMotionListener(this);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Iterator<Circle> circleIterator = circleArrayList.iterator();
Circle drawCircle;
while(circleIterator.hasNext()) {
drawCircle = (Circle) circleIterator.next();
drawCircle.draw(g);
}
}
@Override
public void mouseDragged(MouseEvent e) {
if (e.isMetaDown()) {
Circle newCircle = new Circle(getCircleDiameter(), e.getPoint(), this.getBackground());
circleArrayList.add(newCircle);
}else {
Circle newCircle = new Circle(getCircleDiameter(), e.getPoint(), getCircleColor());
circleArrayList.add(newCircle);
}
repaint();
}
@Override
public void mouseMoved(MouseEvent e) {
}
}
class DrawingFrame extends JFrame implements ActionListener {
private DrawingPanel drawPanel;
private final int SMALL =4;
private final int MEDIUM =8;
private final int LARGE =10;
//Main menu bar
private JMenuBar mainBar = new JMenuBar();
private JMenu file = new JMenu("File");
private JMenu menuSize = new JMenu("Size");
private JMenu menuColor = new JMenu("Color");
private JMenu help = new JMenu("Help");
//Button groups for color and size radio buttons
private ButtonGroup size = new ButtonGroup();
private ButtonGroup color = new ButtonGroup();
//Sub menu items
private JMenuItem clear = new JMenuItem("Clear");
private JMenuItem exit = new JMenuItem("Exit");
// Size radio buttons
private JRadioButtonMenuItem small = new JRadioButtonMenuItem("Small");
private JRadioButtonMenuItem medium = new JRadioButtonMenuItem("Medium");
private JRadioButtonMenuItem large = new JRadioButtonMenuItem("Large");
private JMenuItem about = new JMenuItem("About");
//Color radio buttons
private JRadioButtonMenuItem red = new JRadioButtonMenuItem("Red");
private JRadioButtonMenuItem blue = new JRadioButtonMenuItem("Blue");
private JRadioButtonMenuItem green = new JRadioButtonMenuItem("Green");
private JRadioButtonMenuItem yellow = new JRadioButtonMenuItem("Yellow");
private JRadioButtonMenuItem orange = new JRadioButtonMenuItem("Orange");
public DrawingFrame() {
drawPanel = new DrawingPanel(SMALL,Color.RED);
drawPanel.setBackground(Color.WHITE);
//actionlistners for menu items that are clicked on
file.addActionListener(this);
menuSize.addActionListener(this);
menuColor.addActionListener(this);
help.addActionListener(this);
//add buttons and menu items to their groups/location
setJMenuBar(mainBar);
mainBar.add(file);
mainBar.add(menuSize);
mainBar.add(menuColor);
mainBar.add(help);
file.add(clear);
file.add(exit);
size.add(small);
size.add(medium);
size.add(large);
color.add(red);
color.add(blue);
color.add(green);
color.add(yellow);
color.add(orange);
// add Mnemonics
file.setMnemonic('F');
menuSize.setMnemonic('z');
menuColor.setMnemonic('o');
help.setMnemonic('H');
clear.setMnemonic('C');
exit.setMnemonic('x');
}
@Override
public void actionPerformed(ActionEvent e) {
if(small.isSelected())
drawPanel.setCircleDiameter(SMALL);
if(medium.isSelected())
drawPanel.setCircleDiameter(MEDIUM);
if(large.isSelected())
drawPanel.setCircleDiameter(LARGE);
if (red.isSelected())
drawPanel.setCircleColor(Color.RED);
if (blue.isSelected())
drawPanel.setCircleColor(Color.BLUE);
if (green.isSelected())
drawPanel.setCircleColor(Color.GREEN);
if (yellow.isSelected())
drawPanel.setCircleColor(Color.YELLOW);
if (orange.isSelected())
drawPanel.setCircleColor(Color.ORANGE);
String arg = e.getActionCommand();
if (arg.equals("Exit")) {
System.exit(0);
}
if (arg.equals("Clear")){
drawPanel = new DrawingPanel(SMALL,Color.RED);
}
if (arg.equals("About")) {
JOptionPane.showMessageDialog(null, "Drawing Program, version 1.0\n"+
"by Michael VanKlompenberg\nNovember 9, 2016");
}
}
}
偉大な答えをお伝えするには、あなたがまだ質問していなければ[尋ねる]を一目でわかると助けになるかもしれません。あなたが[mcve]を提供できるなら、それは役に立つかもしれません。 – Mat