Invalid method declaration return type required - Java

Узнай цену своей работы

Формулировка задачи:

код из учебника, однако выдает ошибку при попытке сборки..... вот сама ошибка
java: F:\paint\src\pPainTt.java:17: invalid method declaration; return type required
вот код...
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.geom.*;
import java.util.*;
 
public class pPainTt extends JFrame{
    JButton brushBut, lineBut, ellipseBut, rectBut, strokeBut, fillBut;
    
    int currentAction = 1;
    Color strokeColor=Color.BLACK, fillColor=Color.black;
    
    public static void main(String[] args){
        new JavapPainTt();
    }
    
    public class JavapPainTt(){
        this.setSize(500, 500);
        this.setTitle("Paint");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        JPanel buttonPannel = new JPanel();
        
        Box theBox = Box.createHorizontalBox();
//      brushBut, lineBut, ellipseBut, rectBut, strokeBut, fillBut;
        
        brushBut = makeMeButtons("brush.png",1);
        lineBut = makeMeButtons("line.png",2);
        ellipseBut = makeMeButtons("ellipse.png",3);
        rectBut = makeMeButtons("rect.png",4);
        
        strokeBut = makeMeColorButtons("stroke.png",5, true);
        fillBut = makeMeColorButtons("fill.png",6, false);
        
        theBox.add(brushBut);
        theBox.add(lineBut);
        theBox.add(ellipseBut);
        theBox.add(rectBut);
        theBox.add(strokeBut);
        theBox.add(fillBut);
        
        buttonPannel.add(theBox);
        
        this.add(buttonPannel, BorderLayout.SOUTH);
        this.add(new DrawingBoard(), BorderLayout.CENTER);
        
        this.setVisible(true);
    }
    
    public JButton makeMeButtons(String iconFile, final int actionNum){
        
        JButton theBut = new JButton();
        Icon butIcon = new ImageIcon(iconFile);
        theBut.setIcon(butIcon);
        
        theBut.addActionListener(new ActionListener() {
            
            public void actionPerformed(ActionEvent e){
                currentAction = actionNum;
            }
 
        });
        
        return theBut;  
    }
    
    public JButton makeMeColorButtons(String iconFile, final int actionNum, final boolean stroke){
        
        JButton theBut = new JButton();
        Icon butIcon = new ImageIcon(iconFile);
        theBut.setIcon(butIcon);
        
        theBut.addActionListener(new ActionListener() {
            
            public void actionPerformed(ActionEvent e){
                if(stroke){
                    strokeColor = JColorChooser.showDialog(null,"Pick a stroke", Color.BLACK);
                } else {
                    fillColor = JColorChooser.showDialog(null,"Pick a fill", Color.BLACK);
                }
            }
 
        });
        
        return theBut;  
    }
    
    private class DrawingBoard extends JComponent{
        ArrayList<Shape> shapes = new ArrayList<Shape>();
        ArrayList<Color> shapeFill = new ArrayList<Color>();
        ArrayList<Color> shapeStroke = new ArrayList<Color>();
        Point drawStart, drawEnd;
        
        public DrawingBoard(){
            this.addMouseListener(new MouseAdapter()
            {
                public void mousePressed(MouseEvent e ){
                    drawStart = new Point(e.getX(), e.getY());
                    drawEnd = drawStart;
                    repaint();
                }
                public void mouseReleased(MouseEvent e){
                    Shape aShape = drawRectangle(drawStart.x, drawStart.y, e.getX(), e.getY());
                    
                    shapes.add(aShape);
                    shapeFill.add(fillColor);
                    shapeStroke.add(strokeColor);
                    
                    drawStart = null;
                    drawEnd = null;
                    repaint();

                }
            });
            
            this.addMouseMotionListener(new MouseMotionAdapter()
            {
                public void mouseDragged(MouseEvent e){
                    drawEnd = new Point(e.getX(),e.getY());
                    repaint();
                }
            });
        }
        
        public void paint(Graphics g){
            
            Graphics2D graphSettings = (Graphics2D)g;
            graphSettings.setRendering(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIASING_ON);
            graphSettings.setStroke(new BasicStroke(2));
            Iterator<Color> strokeCounters = shapeStroke.iterator();
            Iterator<Color> fillCounters = shapeFill.iterator();
            
            graphSettings.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
            
            for(Shape s: shapes){
                
                graphSettings.setPaint(strokeCounters.next());
                graphSettings.draw(s);
                graphSettings.setPaint(fillCounters.next());
                graphSettings.fill(s);
            }
            if(drawStart != null && drawEnd != null){
                graphSettings.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
                graphSettings.setPaint(Color.GRAY);
                Shape aShape = drawRectangle(drawStart.x, drawStart.y, drawEnd.x, drawEnd.y);
            }
        }
        
        private Rectangle2D.Float drawRectangle(int x1, int y1, int x2, int y2){
            int x = Math.min(x1,x2);
            int y = Math.min(y1,y2);
            int wigth = Math.abs(x1-x2);
            int height = Math.abs(y1-y2);
            return new Rectangle2D.Float(x,y,wigth,height);
        }
    }
    
}
подскажите, что и как можно тут исправить?!

Решение задачи: «Invalid method declaration return type required»

textual
Листинг программы
// public class JavapPainTt(){
/*на */ public pPainTt() {

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

14   голосов , оценка 3.786 из 5