January 07, 2021

Published January 07, 2021 by

InvalidOperationException: Object of type 'DevExpress.Blazor.Reporting.DxReportDesigner' does not have a property matching the name 'ReportUrl'

This is the code I wrote seeing a sample code.

@page "/reportdesigner"

<DxReportDesigner ReportUrl="HelloWorld" Height="1000px" Width="100%" AllowMDI="true">
   <DxReportDesignerWizardSettings UseFullscreenWizard="true" />
</DxReportDesigner>

This code throws an internal server error in Version 20.2 of DevExpress Blazor Reporting.

InvalidOperationException: Object of type 'DevExpress.Blazor.Reporting.DxReportDesigner' does not have a property matching the name 'ReportUrl'. Microsoft.AspNetCore.Components.Reflection.ComponentProperties.ThrowForUnknownIncomingParameterName(Type targetType, string parameterName)

To get rid of this problem 'ReportUrl' should be replaced by 'ReportName'

Correct Code

@page "/reportdesigner"

<DxReportDesigner ReportName="HelloWorld" Height="1000px" Width="100%" AllowMDI="false">
    <DxReportDesignerWizardSettings UseFullscreenWizard="false"/>
</DxReportDesigner>
Read More

January 06, 2021

Published January 06, 2021 by

Gradle build failed in eclipse : Could not create an instance of type eclipsePlugin

I upgraded my Eclipse IDE to version 2020-12 (4.18.0) and started to get Gradle build error after launching the IDE.

In Eclipse console it showed this error:


FAILURE: Build failed with an exception.

* What went wrong:

Could not create an instance of type eclipsePlugin_5gol6cepvkmdl1guwpr4mu03j.

> Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.


In Eclipse Problems tab it showed: 

Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-5.2.1-bin.zip'.

Could not create an instance of type eclipsePlugin_5gol6cepvkmdl1guwpr4mu03j.

Could not initialize class org.codehaus.groovy.runtime.InvokerHelper


Solution:

The solution of the problem is simply upgrading Gradle. Previous gradle version was 5.2.1, then I upgraded to version 6.7.1 and got it resolved.

For gradlew wrapper, file gradle-wrapper.properties needs to be modified to update distributionUrl. This file is located at Project Root | gradle | wrapper.

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip.

After the update, gradlew clean build command will download the new gradle version and the problem will be resolved.

Read More

December 24, 2020

Published December 24, 2020 by

Freehand Drawing Application with Java Swing

Here is a sample Java program which is used for freehand drawing with mouse. Features include: - Colors: You can draw in different colors. The supported colors are Black, Blue, Cyan, Gray, Green, Magenta, Orange, Pink, Red, White and Yellow. - Pointer Location: The program always shows the mouse pointer location in the title bar. The title is changed dynamically for the mouse movement. This is not a serous program – it’s a fun. You can use it for education purpose only to learn about how to draw in Java.

Output of the program

Here is the full source code:

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.WindowConstants;

public class FreehandDrawing extends JFrame {

    private static final long serialVersionUID = 1L;

    public FreehandDrawing() {
        initComponents();
        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
        setSize(dimension.width, dimension.height - 30);
    }

    private void initComponents() {

        colorButtonGroup = new ButtonGroup();
        drawingPanel = new JPanel();
        colorPanel = new JPanel();
        radioButtonBlack = new JRadioButton();
        radioButtonBlue = new JRadioButton();
        radioButtonCyan = new JRadioButton();
        radioButtonGray = new JRadioButton();
        radioButtonGreen = new JRadioButton();
        radioButtonMagenta = new JRadioButton();
        radioButtonOrange = new JRadioButton();
        radioButtonPink = new JRadioButton();
        radioButtonRed = new JRadioButton();
        radioButtonWhite = new JRadioButton();
        radioButtonYellow = new JRadioButton();

        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        drawingPanel.setBorder(BorderFactory.createEtchedBorder());
        drawingPanel.addMouseListener(new MouseAdapter() {
            public void mouseExited(MouseEvent evt) {
                drawingPanelMouseExited(evt);
            }
        });
        drawingPanel.addMouseMotionListener(new MouseMotionAdapter() {
            public void mouseDragged(MouseEvent evt) {
                drawingPanelMouseDragged(evt);
            }

            public void mouseMoved(MouseEvent evt) {
                drawingPanelMouseMoved(evt);
            }
        });

        getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER);

        colorPanel.setBorder(BorderFactory.createEtchedBorder());
        colorPanel.setLayout(new java.awt.GridLayout(1, 0));

        radioButtonBlack.setBackground(Color.BLACK);
        colorButtonGroup.add(radioButtonBlack);
        radioButtonBlack.setForeground(Color.WHITE);
        radioButtonBlack.setSelected(true);
        radioButtonBlack.setText("Black");
        radioButtonBlack.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                color = Color.BLACK;
            }
        });
        colorPanel.add(radioButtonBlack);

        radioButtonBlue.setBackground(Color.BLUE);
        colorButtonGroup.add(radioButtonBlue);
        radioButtonBlue.setText("Blue");
        radioButtonBlue.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                color = Color.BLUE;
            }
        });
        colorPanel.add(radioButtonBlue);

        radioButtonCyan.setBackground(Color.CYAN);
        colorButtonGroup.add(radioButtonCyan);
        radioButtonCyan.setText("Cyan");
        radioButtonCyan.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                color = Color.CYAN;
            }
        });
        colorPanel.add(radioButtonCyan);

        radioButtonGray.setBackground(Color.GRAY);
        colorButtonGroup.add(radioButtonGray);
        radioButtonGray.setText("Gray");
        radioButtonGray.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                color = Color.GRAY;
            }
        });
        colorPanel.add(radioButtonGray);

        radioButtonGreen.setBackground(Color.GREEN);
        colorButtonGroup.add(radioButtonGreen);
        radioButtonGreen.setText("Green");
        radioButtonGreen.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                color = Color.GREEN;
            }
        });
        colorPanel.add(radioButtonGreen);

        radioButtonMagenta.setBackground(Color.MAGENTA);
        colorButtonGroup.add(radioButtonMagenta);
        radioButtonMagenta.setText("Magenta");
        radioButtonMagenta.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                color = Color.MAGENTA;
            }
        });
        colorPanel.add(radioButtonMagenta);

        radioButtonOrange.setBackground(Color.ORANGE);
        colorButtonGroup.add(radioButtonOrange);
        radioButtonOrange.setText("Orange");
        radioButtonOrange.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                color = Color.ORANGE;
            }
        });
        colorPanel.add(radioButtonOrange);

        radioButtonPink.setBackground(Color.PINK);
        colorButtonGroup.add(radioButtonPink);
        radioButtonPink.setText("Pink");
        radioButtonPink.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                color = Color.PINK;
            }
        });
        colorPanel.add(radioButtonPink);

        radioButtonRed.setBackground(Color.RED);
        colorButtonGroup.add(radioButtonRed);
        radioButtonRed.setText("Red");
        radioButtonRed.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                color = Color.RED;
            }
        });
        colorPanel.add(radioButtonRed);

        radioButtonWhite.setBackground(Color.WHITE);
        colorButtonGroup.add(radioButtonWhite);
        radioButtonWhite.setText("White");
        radioButtonWhite.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                color = Color.WHITE;
            }
        });
        colorPanel.add(radioButtonWhite);

        radioButtonYellow.setBackground(Color.YELLOW);
        colorButtonGroup.add(radioButtonYellow);
        radioButtonYellow.setText("Yellow");
        radioButtonYellow.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                color = Color.YELLOW;
            }
        });
        colorPanel.add(radioButtonYellow);

        getContentPane().add(colorPanel, java.awt.BorderLayout.PAGE_START);

        pack();
    }

    private void drawingPanelMouseMoved(MouseEvent evt) {
        oldX = evt.getX();
        oldY = evt.getY();
        setTitle(oldX + "," + oldY + " - Freehand Drawing");
    }

    private void drawingPanelMouseExited(MouseEvent evt) {
        setTitle("Freehand Drawing");
    }

    private void drawingPanelMouseDragged(MouseEvent evt) {

        newX = evt.getX();
        newY = evt.getY();
        graphics = drawingPanel.getGraphics();
        graphics.setColor(color);
        graphics.drawLine(oldX, oldY, newX, newY);
        oldX = newX;
        oldY = newY;
        setTitle(oldX + "," + oldY + " - Freehand Drawing");
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FreehandDrawing().setVisible(true);
            }
        });
    }

    private ButtonGroup colorButtonGroup;
    private JPanel colorPanel;
    private JPanel drawingPanel;
    private JRadioButton radioButtonBlack;
    private JRadioButton radioButtonBlue;
    private JRadioButton radioButtonCyan;
    private JRadioButton radioButtonGray;
    private JRadioButton radioButtonGreen;
    private JRadioButton radioButtonMagenta;
    private JRadioButton radioButtonOrange;
    private JRadioButton radioButtonPink;
    private JRadioButton radioButtonRed;
    private JRadioButton radioButtonWhite;
    private JRadioButton radioButtonYellow;
    private int oldX, oldY, newX, newY;
    private Color color = Color.BLACK;
    private Graphics graphics;
}
Read More