LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to use the Grid Layout Function ???? (https://www.linuxquestions.org/questions/programming-9/how-to-use-the-grid-layout-function-440297/)

mema_UAE 04-30-2006 12:19 PM

How to use the Grid Layout Function ????
 
[LEFT]I face difficulty in organizing the design of my program and also I had another difficultly in labeling 3 or 4 sentences each one in a new line [LEFT]
:cry: :cry: :scratch: :scratch:

code:


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




public class answer extends Applet implements ActionListener
{
Button b1=new Button("red");
Button b2=new Button("pink");
Button b3=new Button("Black");
Button b4=new Button("blue");
Button b5=new Button("brown");




public void init ()
{

Label L1 = new Label(" button programs")
Label L2 = new Label(" This is My Program")

add(b1);
add(b2);
add(b3);
add(b4);
add(b5);



b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);



public void paint (Graphics g)
{
g.setColor(blue);

g.drawOval(30, 50, 200, 200);
g.drawOval(19, 100, 200, 200);

}


}


}

button programs (This should be center)
This is My Program (This should be new line +center)



circles
should be here and should also be in
center



finally the five buttons should be in bottom and center

mema_UAE 04-30-2006 12:20 PM

I face difficulty in organizing the design of my program and also I had another difficultly in labeling 3 or 4 sentences each one in a new line
:cry: :cry: :scratch: :scratch:

code:


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




public class answer extends Applet implements ActionListener
{
Button b1=new Button("red");
Button b2=new Button("pink");
Button b3=new Button("Black");
Button b4=new Button("blue");
Button b5=new Button("brown");




public void init ()
{

Label L1 = new Label(" button programs")
Label L2 = new Label(" This is My Program")

add(b1);
add(b2);
add(b3);
add(b4);
add(b5);



b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);



public void paint (Graphics g)
{
g.setColor(blue);

g.drawOval(30, 50, 200, 200);
g.drawOval(19, 100, 200, 200);

}


}


}

button programs (This should be center)
This is My Program (This should be new line +center)



circles
should be here and should also be in
center



finally the five buttons should be in bottom and center[/QUOTE]

mema_UAE 04-30-2006 12:21 PM

[QUOTE=mema_UAE]I face difficulty in organizing the design of my program and also I had another difficultly in labeling 3 or 4 sentences each one in a new line
:cry: :cry: :scratch: :scratch:

code:


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




public class answer extends Applet implements ActionListener
{
Button b1=new Button("red");
Button b2=new Button("pink");
Button b3=new Button("Black");
Button b4=new Button("blue");
Button b5=new Button("brown");




public void init ()
{

Label L1 = new Label(" button programs")
Label L2 = new Label(" This is My Program")

add(b1);
add(b2);
add(b3);
add(b4);
add(b5);



b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);



public void paint (Graphics g)
{
g.setColor(blue);

g.drawOval(30, 50, 200, 200);
g.drawOval(19, 100, 200, 200);

}


}


}
button programs (This should be center)

This is My Program (This should be new line +center)



circles
should be here and should also be in center

finally the five buttons should be in bottom and center

nadroj 05-02-2006 11:31 PM

1
please dont post the same thing three times. if you made a mistake, then use the edit function to change it.

2
when you post code put it within the code tags.

for the previous two reasons, im sure you have lost alot of feedback due to people not wanting to bother with this thread, based on the appearance.

3
i assume your talking about the GridLayout layout manager..? have you read around to see what layout manager to use and how it works? try here
let us know any other specific questions about the layout manager you choose.


All times are GMT -5. The time now is 03:06 PM.