Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- public class ab extends JFrame implements ActionListener {
- JLabel yEqu = new JLabel("Y= ");
- JTextField equation = new JTextField(20);
- JButton graphB =new JButton("Graph");
- public static void main(String[] args0){
- ab grapher = new ab();
- }
- public ab(){
- this.setLocationRelativeTo(null);
- this.setVisible(true);
- this.setTitle("Grapher");
- this.setSize(800,700);
- this.setDefaultCloseOperation(EXIT_ON_CLOSE);
- this.setLayout(new FlowLayout());
- this.add(yEqu);
- this.add(equation);
- this.add(graphB);
- graphB.addActionListener(this);
- }
- public ab(Graphics g){
- super.paintComponents(g);
- Graphics2D g2 = (Graphics2D)g;
- g2.fillRect(100,200,300,100);
- }
- public void actionPerformed(ActionEvent e) {
- if(e.getSource() == this.graphB){
- equation.setText("yay");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement