2.7

April 24, 2008 at 1:11 pm (Uncategorized)

1-a.)White-new Color(255, 255, 255)
b.)Black-new Color(0, 0, 0)
c.)Highest Intensity Blue-new Color(200, 200, 255)
d.)Medium Gray-new Color(128, 128, 12 8)
2.)A frame is a class which the code for application windows in Java is located. A panel is a flat, rectangular area suitable for displaying other objects such as geometric shapes and images. A layout manager is an object which a frame or a panel uses in container object in Java.
3.)When we have more than one penal or other objects to display in a window, we have to be concern about how they are organized or laid out.
4.)write a code used to set the layout for adding panels to a 5-by-5 grid in a window
import javax.swing.*;
import java.awt.*;
public class GUIWindow{
public static void main(String[] args){
JFrame theGUI = new JFrame ();
theGUI.setTitle(”Fourth GUI Progrgam”);
theGUI.setSize(300, 200);
theGUI. setDefaultCloseOperation(JFrame.EXIT_OM_CLOSE_);
JPanel.panel1 = new JPanel();
panel1.setBackground(Color.white);
JPanel.panel2 = new JPanel();
panel2.setBackground(Color.black);
JPanel.panel3 = new JPanel();
panel3.setBackground(Color.gray);
JPanel.panel4 = new JPanel();
panel4.setBackground(Color.white);
Container pane = theGUI.getContentPane ();
pane.setLayout(new GridLayout (5, 5));
pane.add(panel1);
pane.add(panel2);
pane.add(panel3);
pane.add(panel4);
theGUI.setVisible(true);

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.