Howdy, Stranger!

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

Categories

In Desperate Need Of Help..

MongloidooMongloidoo Member Posts: 52
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


Comments

  • Andre YoungAndre Young USAMember Posts: 0

    __ || http://forcoder.org || free ebooks and video tutorials about < Scratch Ruby Assembly PHP Perl Go C# Visual Basic MATLAB R Swift Delphi JavaScript Java Objective-C C++ PL/SQL Visual Basic .NET C Python Prolog Scala LabVIEW D Lisp ML Transact-SQL F# Hack COBOL ABAP Erlang Scheme Awk VBScript Ada Kotlin Crystal Lua Julia Alice Fortran Apex Bash FoxPro Clojure SAS Dart Logo Rust /> ___

Sign In or Register to comment.