In Desperate Need Of Help..

I have to create a star and a figure 8 from this code....

import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.applet.Applet;

/** Oval shape method */
class OvalShape extends Shape {
/** draw oval shape
* @param g
* @param x
* @param y
* @param w
* @param h
*/
void draw(Graphics g, int x, int y, int w, int h) {
g.drawOval(x, y, w/10, h/2);
}

/** color oval shape
* @param g
* @param x
* @param y
* @param w
* @param h
*/
void fill(Graphics g, int x, int y, int w, int h) {
g.fillOval(x, y, w, h);
}
}


And in this following code i have to remove a drop down list and add radio buttons. I sucessfully added the radio buttons but they are horizontal instead of vertical and i can't seem to get my shapes to change when i click on the buttons.(perhaps something about adding a listener or something?) I also have to add an exit button somehow.

import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.applet.Applet;
import javax.swing.*;


/** Creates The Graphics Panel */
public class GraphicsPanel extends Panel {
ActionListener al;
ItemListener il;
public GraphicsCards cards;



/** Sets dimensions of the graphics panel
* @return
*/
public Dimension getPreferredSize() {
return new Dimension(200, 100);
}

/**
* @param listener
*/
GraphicsPanel(EventListener listener) {
al = (ActionListener)listener;
il = (ItemListener)listener;

setLayout(new BorderLayout());

add("Center", cards = new GraphicsCards());

Panel p = new Panel();
//p.setLayout(new BorderLayout());

Button b = new Button("next");
b.addActionListener(al);
p.add(b);

b = new Button("previous");
b.addActionListener(al);
p.add(b);

p.add(new Label("go to:", Label.RIGHT));

Choice c = new Choice();
c.addItemListener(il);
//p.add(c);


JRadioButton arcButton = new JRadioButton("Arc");
JRadioButton ovalButton = new JRadioButton("Oval");
JRadioButton polygonButton = new JRadioButton("Polygon");
JRadioButton rectButton = new JRadioButton("Rectangle");
JRadioButton roundrectButton = new JRadioButton("Round Rectangle");
JRadioButton figure8Button = new JRadioButton("Figure 8");
JRadioButton starButton = new JRadioButton("Star");

p.add(arcButton);
p.add(ovalButton);
p.add(polygonButton);
p.add(rectButton);
p.add(roundrectButton);
p.add(figure8Button);
p.add(starButton);

ButtonGroup group = new ButtonGroup();
group.add(arcButton);
group.add(ovalButton);
group.add(polygonButton);
group.add(rectButton);
group.add(roundrectButton);
group.add(figure8Button);
group.add(starButton);


//c.addItem("Arc");
//c.addItem("Oval");
//c.addItem("Polygon");
//c.addItem("Rect");
//c.addItem("RoundRect");

// Put the radio buttons in a column in a panel
// JPanel radioPanel = new JPanel();
// radioPanel.setLayout(new GridLayout(20,400));
// radioPanel.add(arcButton);
// radioPanel.add(ovalButton);
// radioPanel.add(polygonButton);
// radioPanel.add(rectButton);
// radioPanel.add(roundrectButton);


add("East", p);//Move Buttons to the Right

setSize(400, 400);



}


}


i am so sorry if i am annoying you by asking these questions but i am in desperate need for help and i don't know who to ask. thank you, sincerely mongloidoo


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories