import javax.swing.*; //import com.sun.java.swing.*; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.util.*; public class OperationsPanel extends JPanel { private int width, height; private Image buffer; private Graphics bg; private Color defaultComponentForeground; private Color activeComponentForeground; private Image background; private Vector dataVector; private double[] dataArray; private Container container; private Component[] components; private LayoutManager layoutManager; private JComboBox variablesBox; private JComboBox operationsBox; private JTextField currentFormula; private JButton finishButton; private JButton storeButton; private JControlPanel controlPanel; private JTable dataTable; public OperationsPanel(Container container, JTable dataTable) { super(false); this.container = container; while(!(this.container instanceof Applet) && !(this.container instanceof JApplet) && !(this.container instanceof Frame) && !(this.container instanceof JFrame)) this.container = this.container.getParent(); this.dataTable = dataTable; this.width = this.container.getSize().width; this.height = this.container.getSize().height; setVisible(false); container.add(this); background = createImage(width, height); Graphics backG = background.getGraphics(); this.container.paint(backG); backG.dispose(); if(this.container instanceof JApplet) this.container = ((JApplet)this.container).getContentPane(); if(this.container instanceof JFrame) this.container = ((JFrame)this.container).getContentPane(); setBounds(0, 0, this.width, this.height); components = this.container.getComponents(); this.container.removeAll(); this.container.add(this); buffer = createImage(width, height); bg = buffer.getGraphics(); bg.drawImage(background,0,0,this); controlPanel = new JControlPanel(); add(controlPanel); controlPanel.validate(); setVisible(true); if(this.container.getLayout() != null) layoutManager = this.container.getLayout(); this.container.setLayout(null); initializeVector(); requestFocus(); controlPanel.requestFocus(); } public void paint(Graphics g) { g.setClip(0,0,width,height); g.drawImage(buffer, 0, 0, this); g.setClip(controlPanel.getBounds()); super.paint(g); } public class JControlPanel extends JInternalFrame { JButton enterSelectionButton; JButton clearButton; JButton cancelButton; public JControlPanel() { super("Calculation", true); getContentPane().setLayout(new GridLayout(4, 1)); defaultComponentForeground = getBackground(); activeComponentForeground = new Color(153, 0, 51); JButton enterSelectionButton = new JButton("Enter Selection"); enterSelectionButton.addActionListener(new EnterSelectionButtonAdapter()); currentFormula = new JTextField(30); currentFormula.setEditable(false); currentFormula.setBackground(Color.white); storeButton = new JButton("Store"); storeButton.addActionListener(new StoreButtonAdapter()); storeButton.setEnabled(false); createComboBoxes(currentFormula.getPreferredSize().width); finishButton = new JButton("Output To Column"); JButton clearButton = new JButton("Clear"); JButton cancelButton = new JButton("Cancel"); finishButton.setEnabled(false); finishButton.addActionListener(new OutputToColumnButtonAdapter()); clearButton.addActionListener(new ClearButtonAdapter()); cancelButton.addActionListener(new CancelButtonListener()); JPanel panel1 = new JPanel(new FlowLayout()); JPanel panel2 = new JPanel(new FlowLayout()); JPanel panel3 = new JPanel(new FlowLayout()); JPanel panel4 = new JPanel(new FlowLayout()); panel1.setBorder(BorderFactory.createEmptyBorder(5,0,1,0)); panel2.setBorder(BorderFactory.createEmptyBorder(1,0,1,0)); panel3.setBorder(BorderFactory.createEmptyBorder(1,0,1,0)); panel4.setBorder(BorderFactory.createEmptyBorder(1,0,5,0)); panel1.add(variablesBox); panel1.add(operationsBox); panel2.add(enterSelectionButton); panel2.add(storeButton); panel2.add(finishButton); panel3.add(currentFormula); panel4.add(clearButton); panel4.add(cancelButton); getContentPane().add(panel1); getContentPane().add(panel2); getContentPane().add(panel3); getContentPane().add(panel4); if(getPreferredSize().width <= container.getSize().width-10) setSize(getPreferredSize().width+10, getPreferredSize().height); else setSize(new Dimension(container.getSize().width-10, getPreferredSize().height)); int controlPanelWidth = getSize().width; int controlPanelHeight = getSize().height; setLocation((container.getSize().width-controlPanelWidth)/2, (container.getSize().height-controlPanelHeight)/2); enterSelectionButton.setForeground(activeComponentForeground); cancelButton.setForeground(activeComponentForeground); clearButton.setForeground(activeComponentForeground); variablesBox.setForeground(activeComponentForeground); operationsBox.setForeground(defaultComponentForeground); finishButton.setForeground(defaultComponentForeground); storeButton.setForeground(defaultComponentForeground); /* Too much flickering -- not worth it operationsBox.setToolTipText("Use this to select the operation"); variablesBox.setToolTipText("Use this to select the variable"); enterSelectionButton.setToolTipText("Click to Submit a Choice"); currentFormula.setToolTipText("This Displays the Current Calculation"); storeButton.setToolTipText("Click to Store a Calculation in Memory"); finishButton.setToolTipText("Click to Put Current Calculation into Table"); clearButton.setToolTipText("Click to Clear Current Calculation"); cancelButton.setToolTipText("Click to Go Back to Table"); */ } public void requestFocus() { super.requestFocus(); variablesBox.requestFocus(); } } public void dispose() { try { container.setLayout(layoutManager); container.validate(); for(int i=0; i