Mimicing dont send report - illustration of box layout

0 views
Skip to first unread message

Justin

unread,
Aug 5, 2006, 8:02:01 AM8/5/06
to Exam Bells !!! - Group for Sem exam preparation
/* The following program mimics the send report of windows.

The main use of this program is to illustrate rigid area and other box
layout stuff*/

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
class DontSend extends JFrame
{
JButton buttonDontSend, buttonSend;
JLabel labelWarning;
JLabel labelNote;
JPanel labelPane , buttonPane ;
DontSend()
{
super("Error Report");
Container c = getContentPane();

labelPane = new JPanel();
buttonPane = new JPanel();


labelPane.setLayout( new BoxLayout(labelPane, BoxLayout.PAGE_AXIS));

labelWarning = new JLabel("<html>There seems to be some unkowm error
while trying to do what you did"+
"<br>This is an unknown error and
Windooose recommends you do smoething about it "+
"<br>or you will have to face the consequences");
labelWarning .setBackground(Color.RED);
labelWarning .setForeground(Color.BLACK);
labelWarning .setFont(new Font("SansSerif" , Font.PLAIN, 15));


labelNote = new JLabel("<html>If you are so concerned with this great
error ,we would recommend you to inform"+
"<br>someone about this fantastic error. Click send report to inform
windoose about this "+
"<br>wonderful error.It will be a feast for our eyes<html>");
labelNote.setBackground(Color.white);
labelNote.setFont(new Font("SansSerif" , Font.PLAIN, 15));

labelPane.add(labelWarning);
labelPane.add(Box.createRigidArea(new Dimension(0,25)));
labelPane.add(labelNote);


//setting the layout and also putting the buttons

buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

buttonSend = new JButton("Send report");
buttonDontSend = new JButton("Don't Send");

buttonPane.add(Box.createHorizontalGlue());
buttonPane.add(buttonSend );
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPane.add(buttonDontSend );


c.add(labelPane , BorderLayout.CENTER);
c.add(buttonPane, BorderLayout.PAGE_END);

} // end of constructor


} // end of class

class DontSendTest
{
public static void main(String args[])
{
DontSend ds = new DontSend ();
ds.setSize(550,280);
ds.setVisible(true);
ds.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
//*************************************************************************

Reply all
Reply to author
Forward
0 new messages