-
Notifications
You must be signed in to change notification settings - Fork 11
/
COde
622 lines (617 loc) · 19.8 KB
/
COde
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.lang.*;
public class Paint extends JFrame implements MouseMotionListener,MouseListener,ActionListener{
int ctrl;
Color col;
int thickness;
int inx,iny,clk=0;
int graphic=0,mctrl=0;
JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 50, 25); ;
JPanel P1 = new JPanel(new GridLayout(3,2,6,6));
JPanel P2 = new JPanel(new GridLayout(2,6,0,0));
JPanel P3 = new JPanel(new GridLayout(3,2,6,6));
JPanel P4 = new JPanel();
JPanel P5 = new JPanel(new GridLayout(8,4,6,6));
static JButton b1 = new JButton();
static JButton b2 = new JButton();
static JButton b3 = new JButton();
static JButton b4 = new JButton();
static JButton b5 = new JButton();
static JButton b6 = new JButton();
static JButton b21 = new JButton();
static JButton b22 = new JButton();
static JButton b23 = new JButton();
static JButton b24 = new JButton();
static JButton b25 = new JButton();
static JButton b26 = new JButton();
static JButton b27 = new JButton();
static JButton b28 = new JButton();
static JButton b29 = new JButton();
static JButton b210 = new JButton();
static JButton b211 = new JButton();
static JButton b212 = new JButton();
static JButton b31 = new JButton();
static JButton b32 = new JButton();
static JButton b33 = new JButton();
static JButton b34 = new JButton();
static JButton b35 = new JButton();
static JButton b36 = new JButton();
static JButton b37 = new JButton();
static JButton b38 = new JButton();
static JButton b39 = new JButton();
static JButton b40 = new JButton();
static JButton b41 = new JButton();
static JButton b42 = new JButton();
static JButton b43 = new JButton();
static JButton b44 = new JButton();
static JButton b45 = new JButton();
static JButton b46 = new JButton();
static JButton b47 = new JButton();
static JButton b48 = new JButton();
static JButton b49 = new JButton();
Paint(){
super("Paint by Acharya Aditya Pratap");
Component obj = this;
JMenuBar mb = new JMenuBar();
JMenu File = new JMenu("File");
JMenu Edit = new JMenu("Edit");
JMenu View = new JMenu("View");
JMenu Help = new JMenu("Help");
JMenuItem i1 = new JMenuItem("New");
JButton b37 = new JButton("3d graphics");
b37.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
if(graphic==0)
graphic=1;
else
graphic=0;
}});
P4.add(b37);
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=1;}});
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=2;}});
b3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=3;}});
b4.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=4;}});
b5.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=5;}}
);
b6.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=6;}});
b31.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=31 ;}});
b32.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=32;}});
b33.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=33;}});
b34.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl =34;}});
b35.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=35;}});
b36.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=36;}});
b38.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=38;}});
b39.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=39;}});
b40.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=40;}});
b41.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=41;}});
b42.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=42;}});
b43.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=43;}});
b44.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=44;}});
b45.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=45;}});
b46.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=46;}});
b47.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=47;}});
b48.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=48;}});
b49.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
ctrl=49;}});
b21.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
col=Color.white;
P1.setBackground(col);
P3.setBackground(col);
P4.setBackground(col);
P5.setBackground(col);
}});
b22.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
col=Color.yellow;
P1.setBackground(col);
P3.setBackground(col);
P4.setBackground(col);
P5.setBackground(col);}});
b23.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
col=Color.blue;
P1.setBackground(col);
P3.setBackground(col);
P4.setBackground(col);
P5.setBackground(col);}});
b24.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
col=Color.magenta;
P1.setBackground(col);
P3.setBackground(col);
P4.setBackground(col);
P5.setBackground(col);}});
b25.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
col=Color.green;
P1.setBackground(col);
P3.setBackground(col);
P4.setBackground(col);
P5.setBackground(col);}});
b26.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
col=JColorChooser.showDialog(obj,"Customized Adi COlOR",Color.black);
P1.setBackground(col);
P3.setBackground(col);
P4.setBackground(col);
P5.setBackground(col);}
});
b27.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
col=Color.black;
P1.setBackground(col);
P3.setBackground(col);
P4.setBackground(col);
P5.setBackground(col);}});
b28.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
col= Color.orange;
P1.setBackground(col);
P3.setBackground(col);
P4.setBackground(col);
P5.setBackground(col);}});
b29.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
col=Color.cyan;
P1.setBackground(col);
P3.setBackground(col);
P4.setBackground(col);
P5.setBackground(col);}});
b210.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
col=Color.red;
P1.setBackground(col);
P3.setBackground(col);
P4.setBackground(col);
P5.setBackground(col);}});
b211.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
col=Color.gray;
P1.setBackground(col);
P3.setBackground(col);
P4.setBackground(col);
P5.setBackground(col);}});
b212.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
col=new Color((float)0.2,(float)0.5,(float)0.2,(float)0.5);
P1.setBackground(col);
P3.setBackground(col);
P4.setBackground(col);
P5.setBackground(col);}});
i1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
repaint();
}});
JMenuItem i2 = new JMenuItem("Open");
i2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JFileChooser fc = new JFileChooser();
int j = fc.showOpenDialog(obj);
}});
JMenuItem i3 =new JMenuItem("Save");
i3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JFrame fra = new JFrame("Saving in progress");
fra.setSize(250,150);
JProgressBar pg = new JProgressBar(0,2000);
pg.setBounds(40,40,160,30);
pg.setValue(0);
pg.setStringPainted(true);
fra.add(pg);
fra.setVisible(true);
for(int i =0;i<=2000;i+=20){
pg.setValue(i);
try{Thread.sleep(150);}catch(Exception ee){}
}
if(pg.getValue()==2000)
fra.dispose();
}});
JMenuItem i4 = new JMenuItem("Exit");
i4.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
int a=JOptionPane.showConfirmDialog(obj,"Are you sure??");
if(a==JOptionPane.YES_OPTION){
dispose();
}
}});
JMenuItem cut,copy,paste,selectAll;
cut=new JMenuItem("cut");
copy=new JMenuItem("copy");
paste=new JMenuItem("paste");
selectAll=new JMenuItem("selectAll");
cut.addActionListener(this);
copy.addActionListener(this);
paste.addActionListener(this);
selectAll.addActionListener(this);
JMenuItem view = new JMenuItem("VIEW");
view.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String name = JOptionPane.showInputDialog("Enter name");
JOptionPane.showMessageDialog(obj,name+" ,u gotta understand bud its a work in progress","Patience,"+name,JOptionPane.WARNING_MESSAGE);
}});
JMenuItem help = new JMenuItem("HELP");
help.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String name = JOptionPane.showInputDialog("Enter name");
JOptionPane.showMessageDialog(obj,name+" ,u gotta understand bud its a work in progress","Patience,"+name,JOptionPane.WARNING_MESSAGE);}});
File.add(i1);
File.add(i2);
File.add(i3);
File.add(i4);
Edit.add(cut);
Edit.add(copy);
Edit.add(paste);
Edit.add(selectAll);
View.add(view);
Help.add(help);
mb.add(File);
mb.add(Edit);
mb.add(View);
mb.add(Help);
setJMenuBar(mb);
P1.setBounds(0,0,100,250);
P4.setBounds(0,250,100,340);
P1.setBackground(Color.white);
P4.setBackground(Color.white);
add(P1);
add(P4);
b21.setBackground(Color.white);
b22.setBackground(Color.yellow);
b23.setBackground(Color.blue);
b24.setBackground(Color.magenta);
b25.setBackground(Color.green);
b26.setText("Custom Color");
b27.setBackground(Color.black);
b28.setBackground(Color.orange);
b29.setBackground(Color.cyan);
b210.setBackground(Color.red);
b211.setBackground(Color.gray);
b212.setBackground(new Color((float)0.2,(float)0.5,(float)0.2,(float)0.5));
b212.setText("");
b1.setBackground(Color.white);
b2.setBackground(Color.white);
b3.setBackground(Color.white);
b4.setBackground(Color.white);
b5.setBackground(Color.white);
b6.setBackground(Color.white);
b31.setBackground(Color.white);
b32.setBackground(Color.white);
b33.setBackground(Color.white);
b34.setBackground(Color.white);
b35.setBackground(Color.white);
b36.setBackground(Color.white);
P1.add(b1);
P1.add(b2);
P1.add(b3);
P1.add(b4);
P1.add(b5);
P1.add(b6);
JSeparator s =new JSeparator();
add(s);
P2.setBounds(0,590,1400,100);
P2.setBackground(Color.white);
add(P2);
P2.add(b21);
P2.add(b22);
P2.add(b23);
P2.add(b24);
P2.add(b25);
P2.add(b26);
P2.add(b27);
P2.add(b28);
P2.add(b29);
P2.add(b210);
P2.add(b211);
P2.add(b212);
P5.setBounds(1265,250,100,340);
P5.setBackground(Color.white);
P3.setBounds(1265,0,100,250);
P3.setBackground(Color.white);
add(P3);
P3.add(b31);
P3.add(b32);
P3.add(b33);
P3.add(b34);
P3.add(b35);
P3.add(b36);
add(P5);
b38.setBackground(Color.white);
P5.add(b38);
b39.setBackground(Color.white);
P5.add(b39);
b40.setBackground(Color.white);
P5.add(b40);
b41.setBackground(Color.white);
P5.add(b41);
b42.setBackground(Color.white);
P5.add(b42);
b43.setBackground(Color.white);
P5.add(b43);
b44.setBackground(Color.white);
P5.add(b44);
b45.setBackground(Color.white);
P5.add(b45);
b46.setBackground(Color.white);
P5.add(b46);
b47.setBackground(Color.white);
P5.add(b47);
b48.setBackground(Color.white);
P5.add(b48);
b49.setBackground(Color.white);
P5.add(b49);
JLabel label = new JLabel();
label.setHorizontalAlignment(JLabel.CENTER);
label.setText("Thickness");
P4.add(label);
P4.add(slider);
setSize(400,400);
setLayout(null);
setVisible(true);
addMouseListener(this);
addMouseMotionListener(this);
}