/* Copyright 2000 Charles G. Wright * This software may be distributed under the terms of the * GNU General Public License. * * $Id: GRAoutput.java,v 1.1 2000-06-15 10:14:57-05 chuckles Exp chuckles $ */ import java.awt.*; import java.awt.event.*; import java.io.*; /** Class displaying a selection of output screens */ public class GRAoutput extends Panel implements ActionListener{ private Button next; private Button previous; private Panel output_panel; private Panel title_panel; private Label output_title; private Label l1; private Color[] colors; private CardLayout output_panel_layout; /** Creates a panel containing several subpanels. */ public GRAoutput(Color[] colors){ this.colors = colors; //------------------------------------------------- // title panel creation title_panel = new Panel(); FlowLayout fl = new FlowLayout(FlowLayout.LEFT, 2, 2); title_panel.setLayout(fl); l1 = new Label("Output selection:"); title_panel.add(l1); previous = new Button("<"); previous.addActionListener(this); title_panel.add(previous); next = new Button(">"); next.addActionListener(this); title_panel.add(next); // End of title panel definition //---------------------------------------------- // output panel definition output_panel = new Panel(); output_panel_layout = new CardLayout(); output_panel.setLayout(output_panel_layout); // We don't add anything to it right away. //End of output panel definition //-------- top graph panel definition ----------- GridBagLayout top_output_layout = new GridBagLayout(); setLayout(top_output_layout); GridBagConstraints ct = new GridBagConstraints(); ct.fill = GridBagConstraints.BOTH; ct.gridwidth = GridBagConstraints.REMAINDER; ct.weightx = 1.0; ct.weighty = 0.0; ct.gridx = 0; ct.insets = new Insets(3,3,3,3); top_output_layout.setConstraints(title_panel, ct); GridBagConstraints cb = new GridBagConstraints(); ct.weighty = 1.0; top_output_layout.setConstraints(output_panel, ct); add(title_panel); add(output_panel); } public void paint(Graphics g){ setForeground(Color.blue); Dimension d = getSize(); g.drawRect(0, 0, d.width - 1, d.height - 1); } public void addOutputPanel(Component p, String name){ output_panel.add(p, name); } // Come here when a button is pressed, to page through graphs. public void actionPerformed(ActionEvent ae){ Object sel = ae.getSource(); // Handle interactions between month and day selectors. if (sel == previous){ output_panel_layout.previous(output_panel); } else if (sel == next){ output_panel_layout.next(output_panel); } } }