Question #12

Prepare an applet called FourCorners. Draw a circle in the top left corner; an oval in the bottom right; a rectangle in the top right and a line in the bottom left. Put you're name centered on the applet. The program is started below. Please remember to include You're code in reply and a screen shot.:

import.java.applet.*;

import.java.awt.*;

public class FourCorners extends Applet

{

public void paint(Graphics g)

{

g.fillOval(0,0,50,50);

[492 byte] By [Josh_Chicagoa] at [2007-10-2 20:48:48]
# 1
> Please remember to include You're code in reply and a screen shot.:Did your teacher really write "you're code" in the homework assignment?
sjasjaa at 2007-7-13 23:32:48 > top of Java-index,Java Essentials,Java Programming...
# 2

I don't see what the problem is here. The problem is practically solved for you already.

The circle is already drawn (that's the oval with the same height and widht).

The oval can be drawn the same way, but by varying the height and width from each other.

The rectangle can be done with the fillRect method of g

The line can be drawn with the drawLine method of g.

Your name can be put in place with the drawString method of g.

so all you really need to do is determine WHERE to put the components, which is simple geometry.

if you need help with the parameters for those methods, you should consult the API for Graphics. I'm not going to supply you with those. You need to do SOME of this homework for yourself.

guitar_man_Fa at 2007-7-13 23:32:48 > top of Java-index,Java Essentials,Java Programming...
# 3
DOYOUROWNHOMEWORK
Norweeda at 2007-7-13 23:32:48 > top of Java-index,Java Essentials,Java Programming...
# 4

> Prepare an applet called FourCorners. Draw a circlein the top left

> corner; an oval in the bottom right; a rectangle in the top right and a

> line in the bottom left. Put you're name centered on the applet. The

> program is started below. Please remember to include You're code in

> reply and a screen shot.:

No, my religion forbids me to do that.

kind regards,

Jos

JosAHa at 2007-7-13 23:32:48 > top of Java-index,Java Essentials,Java Programming...
# 5

Question #1 should have been something like "Are you sure you have the right natural skillset for becoming a software developer?"

And your answer should have been a resounding "NO, I am a lazy student hoping to get others to do my work for me!"

And then there would have been no need to move on to the other questions, including Question #12.

warnerjaa at 2007-7-13 23:32:48 > top of Java-index,Java Essentials,Java Programming...
# 6
> No, my religion forbids me to do that.Which one, The Cult of The Holy Grolsch or The Church of The Last Answer?
CeciNEstPasUnProgrammeura at 2007-7-13 23:32:48 > top of Java-index,Java Essentials,Java Programming...
# 7
> > No, my religion forbids me to do that.> > Which one, The Cult of The Holy Grolsch or The Church> of The Last Answer?Yes.kind regards,Jos (seven times seventyseven amens brother, amen ;-)
JosAHa at 2007-7-13 23:32:48 > top of Java-index,Java Essentials,Java Programming...
# 8

There, there now! Don't let those nasty people upset you. This code is exactly what you need.import javax.swing.*;

import java.awt.*;

public class Question12 extends JPanel

{

public Question12()

{

GridBagConstraints c = new GridBagConstraints();

GridBagConstraints end;

JPanel panel;

JLabel label = new JLabel();

Font labelFont = label.getFont().deriveFont(Font.BOLD + Font.ITALIC, 60.0F);

// Set constraints for panel

c.weightx = 1;

c.weighty = 1;

end = (GridBagConstraints) c.clone();

end.gridwidth = GridBagConstraints.REMAINDER;

// Set layout for panel

setLayout(new GridBagLayout());

// add top left (circle)

panel = new JPanel();

label = new JLabel(揬u0044\u004F?;

label.setFont(labelFont);

panel.add(label);

add(panel, c);

// add top center (empty)

panel = new JPanel();

add(panel, c);

// add top right (rectangle)

panel = new JPanel();

label = new JLabel(揬u0059\u004F\u0055\u0052?;

label.setFont(labelFont);

panel.add(label);

add(panel, end);

// add middle left (empty)

panel = new JPanel();

add(panel, c);

// add middle center (your name)

panel = new JPanel();

panel.add(new JLabel(?your name here)?);

add(panel, c);

// add middle right (empty)

panel = new JPanel();

add(panel, end);

// add bottom left (line)

panel = new JPanel();

label = new JLabel(揬u004F\u0057\u004E?;

label.setFont(labelFont);

panel.add(label);

add(panel, c);

// add bottom center (empty)

panel = new JPanel();

add(panel, c);

// add bottom right (oval)

panel = new JPanel();

label = new JLabel(揬u0048\u004F\u004D\u0045\u0057\u004F\u0052\u004B\u0021?;

label.setFont(labelFont);

panel.add(label);

add(panel, end);

}

public static void main(String args[])

{

JFrame mainFrame = new JFrame();

mainFrame.getContentPane().add(new Question12());

mainFrame.setSize(new Dimension(640, 400));

mainFrame.setVisible(true);

// So you can close the application

mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

}

}

DougDeana at 2007-7-13 23:32:48 > top of Java-index,Java Essentials,Java Programming...
# 9
> There, there now! Don't let those nasty people upset you. This code is > exactly what you need.> GridBagConstraints c = new GridBagConstraints();racist.kind regards,Jos ;-)
JosAHa at 2007-7-13 23:32:48 > top of Java-index,Java Essentials,Java Programming...