// Create the display inside the "Replay" tab. private JPanel createReplayPanel() { // Create the overall panel with a space between each component. JPanel panel = new JPanel(new BorderLayout(20, 20)); // Create container for the bottom buttons. JPanel bottomButtons = new JPanel(); bottomButtons.setLayout(new BoxLayout(bottomButtons, BoxLayout.X_AXIS)); // Create the buttons and label. JButton run = new JButton("Run"); run.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { runTests(); } }); JButton close = new JButton("Close"); close.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { closeProgram(); } }); JButton add = new JButton("Add"); add.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { addTest(); } }); JButton remove = new JButton("Remove"); remove.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { removeTest(); } }); JLabel testLabel = new JLabel("Tests:"); // Create the test box and make it scrollable. testBox = new JTextPane(); testBox.setLayout(new BoxLayout(testBox, BoxLayout.Y_AXIS)); testBox.setEditable(false); JScrollPane scroll = new JScrollPane(testBox); // Add the test label and box. panel.add(testLabel, BorderLayout.PAGE_START); panel.add(scroll, BorderLayout.CENTER); // Add the buttons to bottom container and add that to overall. bottomButtons.add(add); bottomButtons.add(Box.createRigidArea(new Dimension(10, 0))); bottomButtons.add(remove); bottomButtons.add(Box.createRigidArea(new Dimension(10, 0))); bottomButtons.add(run); bottomButtons.add(Box.createRigidArea(new Dimension(10, 0))); bottomButtons.add(close); panel.add(bottomButtons, BorderLayout.PAGE_END); // Add space in between edge of tab page. panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); return panel; }
public CaptureReplay() { // Define layout of overall window, create space, then components. super(new BorderLayout(10, 10)); setBorder(BorderFactory.createEmptyBorder(15, 3, 0, 0)); createMainPanel(); // Define classes used to collect and save test data. efgtstCapture = new JFCXTestCase(); guiCapture = new CaptureAsYouGo( new MouseListener() { public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseClicked(MouseEvent e) { efgtstCapture.addComponent((Component) e.getSource()); } public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} }); guiCapture.addComponentInspector( new CaptureAsYouGo.ComponentInspector() { private ActionListener actionCapture = new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("ActionPerformed"); efgtstCapture.addComponent((Component) e.getSource()); } }; public boolean inspect(Component component) { boolean add = component instanceof AbstractButton && !(component instanceof JMenu); if (add) ((AbstractButton) component).addActionListener(this.actionCapture); return add; } public String getReplayableActionType() { return "edu.umd.cs.guitar.event.JFCActionHandler"; } /* public void inspectComponent(Component component, ComponentTypeWrapper componentType) { if(component instanceof AbstractButton && !(component instanceof JMenu)) { ((AbstractButton)component).addActionListener(this.actionCapture) ; componentType.addAttribute("ReplayableAction", "edu.umd.cs.guitar.JFCActionHandler") ; } } */ }); guiCapture.addComponentInspector( new CaptureAsYouGo.ComponentInspector() { private ActionListener actionCapture = new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("ActionPerformed"); efgtstCapture.addComponent((Component) e.getSource()); } }; public boolean inspect(Component component) { boolean add = component instanceof Button; if (add) ((Button) component).addActionListener(this.actionCapture); return add; } public String getReplayableActionType() { return "edu.umd.cs.guitar.event.JFCActionHandler"; } }); guiCapture.addComponentInspector( new CaptureAsYouGo.ComponentInspector() { private MenuListener menuCapture = new MenuListener() { public void menuCanceled(MenuEvent e) {} public void menuDeselected(MenuEvent e) {} public void menuSelected(MenuEvent e) { System.out.println("MenuSelected"); efgtstCapture.addComponent((Component) e.getSource()); } }; public boolean inspect(Component component) { boolean add = component instanceof JMenu; if (add) ((JMenu) component).addMenuListener(this.menuCapture); return add; } public String getReplayableActionType() { return "edu.umd.cs.guitar.event.JFCSelectionHandler"; } }); // Define list of test name for replaying. tests = new ArrayList<JCheckBox>(); }
// Create the display inside the "Capture" tab. private JPanel createCapturePanel() { // Create the overall panel with a space between each component. JPanel panel = new JPanel(new BorderLayout(20, 20)); // Create container for the bottom buttons. JPanel bottomButtons = new JPanel(); bottomButtons.setLayout(new BoxLayout(bottomButtons, BoxLayout.X_AXIS)); // Create the bottom buttons and top label. recordButton = new JButton("Record"); recordButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { record(); } }); stopButton = new JButton("Stop"); stopButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { stopRecord(); } }); JButton save = new JButton("Save Test"); save.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { saveTest(); } }); JButton close = new JButton("Close"); close.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { closeProgram(); } }); JLabel updateLabel = new JLabel("Recent Actions:"); // Create the update box and make it scrollable. updateBox = new JTextPane(); updateBox.setText("Welcome to the JFC Capture/Replay Tool!"); JScrollPane scroll = new JScrollPane(updateBox); updateBox.setEditable(false); // Add the update label and box. panel.add(updateLabel, BorderLayout.PAGE_START); panel.add(scroll, BorderLayout.CENTER); // Add the buttons to bottom container and add that to overall. bottomButtons.add(recordButton); bottomButtons.add(Box.createRigidArea(new Dimension(10, 0))); bottomButtons.add(stopButton); bottomButtons.add(Box.createRigidArea(new Dimension(10, 0))); bottomButtons.add(save); bottomButtons.add(Box.createRigidArea(new Dimension(10, 0))); bottomButtons.add(close); panel.add(bottomButtons, BorderLayout.PAGE_END); stopButton.setEnabled(false); // Add space in between edge of tab page. panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); return panel; }