how to do it??

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2004
Posts: 2
Reputation: smalltalk is an unknown quantity at this point 
Solved Threads: 0
smalltalk smalltalk is offline Offline
Newbie Poster

how to do it??

 
0
  #1
Nov 20th, 2004
a ball have radius 20 when i press a button once the radius increase by 5 subsequent clicks have the same effect until a max radius of 30 is reached after this the effect of click is to reduce the radius by 5 until it reach 10. after this a click cause a radius increase by 5 and so on.... maintaining the radius within the upper and lower limits....


please what is the code ......
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: how to do it??

 
0
  #2
Nov 20th, 2004
English isn't Latin. Sentences are allowed to be less than 3 lines in length.

Divide up your problem, word it so you can make it understood what you're trying to do.

And no, we're not here to build your code for you. That's your job. We CAN help you find logic or other errors in the code if you can show us your code and tell us 1) what it does and 2) what it should be doing.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 2
Reputation: smalltalk is an unknown quantity at this point 
Solved Threads: 0
smalltalk smalltalk is offline Offline
Newbie Poster

Re: how to do it??

 
0
  #3
Nov 20th, 2004
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class JFrame1 extends JFrame {
public static void main(String [] args){
JFrame1 frame = new JFrame1();
frame.show();
}
JPanel contentPane;
JButton jButton1 = new JButton();


/**Construct the frame*/
public JFrame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}

}
/**Component initialization*/
private void jbInit() throws Exception {
jButton1.setText("InOut");
jButton1.setBounds(new Rectangle(296, 118, 84, 37));
jButton1.addMouseListener(new JFrame1_jButton1_mouseAdapter(this));
//setIconImage(Toolkit.getDefaultToolkit().createImage(JFrame1.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(null);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
contentPane.add(jButton1, null);

}
/**Overridden so we can exit when window is closed*/
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
private Ball aBall = new Ball(new Point(150,165),20);


public void paint(Graphics g)
{
super.paint(g);
aBall.paint(g);

}

void jButton1_mouseClicked(MouseEvent e) {

int d = 5;
int r = aBall.radius();

if (r == 10 || r == 30)
d = -d;
aBall.rad = aBall.rad + d;

repaint();
}
}

class JFrame1_jButton1_mouseAdapter extends java.awt.event.MouseAdapter {
JFrame1 adaptee;

JFrame1_jButton1_mouseAdapter(JFrame1 adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent e) {
adaptee.jButton1_mouseClicked(e);
}
}
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: how to do it??

 
0
  #4
Nov 20th, 2004
ok, so you have had some IDE autogenerate a piece of code for you without the parts that are important to your application (what's called the business logic).
A few mouseclicks in JBuilder will give me the same.

Now comes the thinking, good luck with that and trying to find out what it is you want to happen when that mouse is clicked...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum


Views: 1504 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC