Looking for Core Java Projects ?

This post is to help all those students who are looking for help to create Core java projects.

We have implemented Java paint program.

The program is created with core java only. In order to help our reader,we have posted source code and output here.

Moreover, you can directly download project here.We promise no signup required.

First Of all, Lets have a look at output,So that it will be clear in you min what you are trying to achieve with the available source code:

So,Here is OutPut:

Probably  you are convinced with Output and also want to create the same!

You source code goes here:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package puretechy.javaprojects;
 
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
 
public class MiniPaintUsingJava extends java.applet.Applet implements ActionListener
{
	int last_x=0,last_y=0;
	Label l;
	Color c=Color.black;
	Button btn_black,btn_magenta,btn_blue,btn_orange;
	Button btn_cyan,btn_pink,btn_darkGray,btn_red;
	Button btn_gray,btn_white,btn_green,btn_yellow;
	Button btn_green1,btn_yellow1;
	Button btn_clear;
 
	public void init()
	{
		l=new Label("Choose Color to draw Lines ");
		btn_black=new Button("Black");
		btn_magenta=new Button("Magenta");
		btn_blue=new Button("Blue");
		btn_orange=new Button("Orange");
		btn_cyan=new Button("Cyan");
		btn_pink=new Button("Pink");
		btn_darkGray=new Button("DarkGray");
		btn_red=new Button("Red");
		btn_gray=new Button("Gray");
		btn_white=new Button("White");
		btn_green=new Button("Green");
		btn_yellow=new Button("Yellow");
		btn_clear=new Button("Clear");
 
		btn_black.addActionListener(this);
		btn_magenta.addActionListener(this);
		btn_blue.addActionListener(this);
		btn_orange.addActionListener(this);
		btn_cyan.addActionListener(this);
		btn_pink.addActionListener(this);
		btn_darkGray.addActionListener(this);
		btn_red.addActionListener(this);
		btn_gray.addActionListener(this);
		btn_white.addActionListener(this);
		btn_green.addActionListener(this);
		btn_yellow.addActionListener(this);
		btn_clear.addActionListener(this);
 
		add(l);
		add(btn_black);
		add(btn_magenta);
		add(btn_blue);
		add(btn_orange);
		add(btn_cyan);
		add(btn_cyan);
		add(btn_pink);
		add(btn_darkGray);
		add(btn_red);
		add(btn_gray);
		add(btn_white);
		add(btn_yellow);
		add(btn_green);
		add(btn_clear);
	}
 
	public void actionPerformed(ActionEvent ae)
	{
		String m=ae.getActionCommand();
		if(m.equals("Clear"))
		{
			clear_method();
		}
		if(m.equals("Magenta"))
		{
			c=Color.magenta;
		}
		if(m.equals("Blue"))
		{
			c=Color.blue;
		}
		if(m.equals("Black"))
		{
			c=Color.black;
		}
		if(m.equals("Orange"))
		{
			c=Color.orange;
		}
		if(m.equals("Cyan"))
		{
			c=Color.cyan ;
		}
		if(m.equals("Pink"))
		{
			c=Color.pink;
		}
		if(m.equals("DarkGray"))
		{	
			c=Color.darkGray;
		}
		if(m.equals("Red"))
		{
			c=Color.red;
		}
		if(m.equals("Gray"))
		{
			c=Color.gray;
		}
		if(m.equals("White"))
		{
			c=Color.white;
		}
		if(m.equals("Green"))
		{
			c=Color.green;
		}
		if(m.equals("Yellow"))
		{
			c=Color.yellow;
		}
		if(m.equals("LightGray"))
		{
			c=Color.lightGray;
		}
	}
	public boolean mouseDown(Event e,int x,int y)
	{
			last_x=x;
			last_y=y;
			return true;
	}
 
	void clear_method()
	{
		Graphics g=getGraphics();
		Dimension d = getSize();
		g.setColor(Color.WHITE);
		g.fillRect(0, 0, d.width, d.height);
	}
	public boolean mouseDrag(Event e,int x,int y)
	{
		Graphics g=getGraphics();
		g.setColor(c);
		g.drawLine(last_x,last_y,x,y);
		last_x=x;	
		last_y=y;
		return true;
	}
}
}

Hope this program helps you.!

Please Let us know your views about the Java paint program in comment section.and also let us know if any queries.Will try to resolve as soon as possible.:)

Hey wait,You might be interested in some more free learning.We promise completely free.We have listed so many free coupons for best Udemy courses.

Check out here.It may change your learning experience!

About

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website

%d bloggers like this: