Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,933 members, 7,806,700 topics. Date: Tuesday, 23 April 2024 at 09:13 PM

My Paint Application Project - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / My Paint Application Project (2644 Views)

Supply Source Code For Windows Paint Utility (2) (3) (4)

(1) (Reply)

My Paint Application Project by spikytang(m): 4:16pm On Aug 25, 2009
I need to design a Paint Application using Java Technologies and i am having problems, i have finished with the GUI interface but adding the ActionListeners is really giving me problems. Am not really grounded in applying ActionListeners to GUI applications but am trying to read up.

I really need codes on MyPaint application.
Re: My Paint Application Project by mexy042: 6:33pm On Aug 25, 2009
Spiky,
First of all your MyPaint class needs to implement the ActionListener class from the java API.

eg.
public Class MyPaint extends JFrame implements ActionListener {

//assuming you are developing an application with a JFrame
}

Then for each component ie JButton myButton that you would like to the ActionListener to 'listen to' you would need register the component with a unique reference, such that when an event is triggered, ie You click myButton, the desired action is performed, eg paint();.

So within your MyPaint class, if you had a JButton called myButton, after general initialisation you would need to register the button.

eg. JButton myButton = new JButton();
myButton.setActionCommand("paint"wink;
myButton.addActionListener(this);

After you have done this, you can then instruct the JVM to perform certain actions anytime (your myButton is clicked).

eg. public void actionPerformed(ActionEvent e) {

String command = e.getActionCommand();

if (command.equals("paint"wink) {

//I assume you have already created the paint method

paint();

}

Note that your unique reference in this scenario is "paint".

P.S Dont forget to import all necessary classes for event handling etc.

In this case you would need the following

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
Re: My Paint Application Project by Mobinga: 2:33pm On Jan 18, 2011
You see your life and my life grin I and you both had a project work but we both came online to cheat grin

(1) (Reply)

My Programming Skills (J. C. Ozochi) / Suggestions Needed / State Of The Developer Nation Q4

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 9
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.