2.7
April 22, 2008
rita1012
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, 0)
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.)where are panels displayed when a border layout is used to control their placement in a window
When we have more than one panel 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[ ] arg){
theGUI. setTitle(” Fourth GUI Program”);
the GUI.setSize(300, 200);
the GUI.setDefaultCloseOperation(JFrame. EXIT_ON_Close);
JPanel panell = new Jpanel();
panel1.setBackground(Color.White);
JPanel panel2 = new Jpanel();
panel1.setBackground(Color.black);
JPanel panel3 = new Jpanel();
panel1.setBackground(Color.gray);
JPanel panel4 = new Jpanel();
panel1.setBackground(Color.white)
container pane = theGUI.get Content Pane( );
pane.setLayout(new GridLayout(5,5));
pane.add(Panel1);
pane.add(Panel2);
pane.add(Panel3);
pane.add(Panel4);
theGUI.setVisible(true);
Entry Filed under: Uncategorized
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to comments via RSS Feed