import java.applet.*; import java.awt.*; import java.awt.event.*; public final class AreaOff extends Applet { // main class for showing pages public final void init() { setBackground(Color.gray); NewOrModifyPage newOrModifyPage = new NewOrModifyPage(this); add(newOrModifyPage); } final void changeTo(int newPage) { removeAll(); if (newPage == AgreementPage.PAGE_NUMBER) { AgreementPage agreementPage = new AgreementPage(); add(agreementPage); } validate(); } static final void constrain(Container container, Component component, int grid_x, int grid_y, int grid_width, int grid_height, int anchor, int topPad, int leftPad, int bottomPad, int rightPad, int fill, double weightx, double weighty) { GridBagConstraints c = new GridBagConstraints(); c.gridx = grid_x; c.gridy = grid_y; c.gridwidth = grid_width; c.gridheight = grid_height; c.anchor = anchor; c.insets.top = topPad; c.insets.left = leftPad; c.insets.bottom= bottomPad; c.insets.right = rightPad; c.fill = fill; c.weightx = weightx; c.weighty = weighty; ((GridBagLayout)container.getLayout()).setConstraints(component, c); container.add(component); } } // END OF Class AreaOff final class NewOrModifyPage extends Panel implements ActionListener { static Button initialButton; static int pad = 6; static AreaOff areaOff; NewOrModifyPage(AreaOff areaOff) { this.areaOff = areaOff; setLayout(new GridBagLayout()); initialButton = new Button("Enter my humble applet"); initialButton.addActionListener(this); AreaOff.constrain(this, initialButton, 0, 1, 1, 1, GridBagConstraints.NORTH, 40, 0, 0, 0, GridBagConstraints.NONE, 0, 0); } public void actionPerformed(ActionEvent ae) { if (ae.getSource() == initialButton) { areaOff.changeTo(AgreementPage.PAGE_NUMBER); } } } // END OF Class NewOrModifyPage final class AgreementPage extends Panel { static final int PAGE_NUMBER = 1; static int pad = 6; static Button agreeButton, disagreeButton; static final String[] NARRATIVE_STRING = { "Here are some of the layout problems with Macintosh OS X with Java 1.4.1 Update 1.", "1. TextArea text gets clipped at ends of lines, and display starts in middle.", "2. Components such as the title (orange) overlap other components (e.g. green).", "3. Lines such as those on the green panel get clipped though there is space. ", "4. The two buttons that should appear below (on a yellow panel) do not appear", "These problems do not occur in other environments, including Mac OS X with Java 1.3."}; AgreementPage() { setLayout(new GridBagLayout()); Panel textPanel = new Panel(); textPanel.setLayout(new GridBagLayout()); AreaOff.constrain(this, textPanel, 0, 0, 1, 1, GridBagConstraints.SOUTH, 0, 0, 0, 0, GridBagConstraints.NONE, 0, 1); Label topLineLabel = new Label("AWT layout problems with Mac Java 1.4.1"); topLineLabel.setFont(new Font("Serif", Font.BOLD, 19)); topLineLabel.setBackground(Color.orange); AreaOff.constrain(textPanel, topLineLabel, 0, 0, 1, 1, GridBagConstraints.CENTER, 0, 0, 0, 0, GridBagConstraints.NONE, 0, 0); Label[] conditionsLabel = new Label[NARRATIVE_STRING.length]; for (int i=0; i