Question

public class X extends JFrame JLabel AL; JTextField ATF; JButton AB; ABButtonHandler aBButtonHandler; private class ABButtonH

in java.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public class X extends JFrame{
    JLabel AL;
    JTextField ATF;
    JButton AB;
    ABButtonHandler aBButtonHandler;
    private class ABButtonHandler implements ActionListener{

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            ATF.setText(ATF.getText() + ATF.getText()); // concatenate the current text one more time on button press
        }
    }
    public X(){
        setTitle("X window");
        setSize(300, 50);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Container XwindowPane = getContentPane(); //get Content Pane of the frame
        XwindowPane.setLayout(new FlowLayout());  // set Layout to new FLowLayout
        AL = new JLabel("A");       // Initialize the Label 
        ATF = new JTextField();     //Initialize the Text field
        AB = new JButton("AB");      // initialize the Button
        // add everthing to frame
        XwindowPane.add(AL);        
        XwindowPane.add(ATF);
        XwindowPane.add(AB);
        //initialize action handler of button and add it to button
        aBButtonHandler = new ABButtonHandler();
        AB.addActionListener(aBButtonHandler);
        setVisible(true);
    }

}

Add a comment
Know the answer?
Add Answer to:
in java. public class X extends JFrame JLabel AL; JTextField ATF; JButton AB; ABButtonHandler aBButtonHandler; private...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How can i make the java class seperate into an MVC pattern? public class ChatView implements Acti...

    How can i make the java class seperate into an MVC pattern? public class ChatView implements ActionListener {    public static void main(String[] args)    {        JFrame chatFrame = new JFrame();        JFrame chatFrame1 = new JFrame();        JFrame chatFrame2 = new JFrame();               JPanel chatPanel = new JPanel();        JPanel chatPanel1 = new JPanel();        JPanel chatPanel2 = new JPanel();        chatFrame.setContentPane(chatPanel);        chatFrame1.setContentPane(chatPanel1);        chatFrame2.setContentPane(chatPanel2);        chatFrame.setLayout(new FlowLayout());        chatFrame1.setLayout(new FlowLayout());        chatFrame2.setLayout(new FlowLayout());        JTextField chatWrite = new JTextField();        JTextField chatWrite1 = new JTextField();        JTextField chatWrite2 = new JTextField();        JTextArea chatDisplay...

  • import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.swing.BorderFactory; import javax.swing.border.Border; public class Q1 extends JFrame {...

    import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.swing.BorderFactory; import javax.swing.border.Border; public class Q1 extends JFrame {    public static void createAndShowGUI() {        JFrame frame = new JFrame("Q1");        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        Font courierFont = new Font("Courier", Font.BOLD, 40);        Font arialFont = new Font("Arial", Font.BOLD, 40);        Font sansFont = new Font("Sans-serif", Font.BOLD, 20);        JLabel label = new JLabel("Enter a word"); label.setFont(sansFont);        Font font1 = new Font("Sans-serif", Font.BOLD, 40);       ...

  • Debug this java and post the corrected code. /* Creates a simple JPanel with a single...

    Debug this java and post the corrected code. /* Creates a simple JPanel with a single "quit" JButton * that ends the program when clicked. * There are 3 errors, one won't prevent compile, you have to read comments. */ import javax.swing.*; import java.awt.*; import java.awt.event.*; public class QuitIt extends JFrame {     public QuitIt() {         startIt(); //Create everything and start the listener     }     public final void startIt() {        //Create the JPanel        JPanel myPanel =...

  • Need some help fixing these compilation errors that start around line 20, thank you import javax.swing.*;...

    Need some help fixing these compilation errors that start around line 20, thank you import javax.swing.*; public class PropertyTax1 extends JFrame {    private static final int WIDTH = 400, HEIGHT = 300;       public PropertyTax1()    {        setTitle("Calculation of Property Taxes");        setSize(WIDTH, HEIGHT);        setVisible(true);        setDefaultCloseOperation(EXIT_ON_CLOSE);    } // end of the constructor method       public static void main(String[] args)    {        PropertyTax1 proptax = new PropertyTax1();   ...

  • Write a Java application that displays the following ClickMe When the user clicks on "Click Me"...

    Write a Java application that displays the following ClickMe When the user clicks on "Click Me" button, the text, "l am clicked" is displayed. ClickMe am clicked import java.awt.*; import java.awt.event.*; public class OneButton extends JFrame implements ActionListener private JButton button; private JTextField field; public static void main(String args)( OneButton myCoolButton new OneButton0;

  • import javax.swing.*; import java.awt.event.*; import java.awt.*; public class BookReview extends JFrame implements ActionListener {       private JLabel...

    import javax.swing.*; import java.awt.event.*; import java.awt.*; public class BookReview extends JFrame implements ActionListener {       private JLabel titleLabel;       private JTextField titleTxtFd;       private JComboBox typeCmb;       private ButtonGroup ratingGP;       private JButton processBnt;       private JButton endBnt;       private JButton clearBnt;       private JTextArea entriesTxtAr;       private JRadioButton excellentRdBnt;       private JRadioButton veryGoodRdBnt;       private JRadioButton fairRdBnt;       private JRadioButton poorRdBnt;       private String ratingString;       private final String EXCELLENT = "Excellent";       private final String VERYGOOD = "Very Good";       private final String FAIR = "Fair";       private final String POOR = "Poor";       String...

  • Can you help me to link two frames in Java Swing and then if you click...

    Can you help me to link two frames in Java Swing and then if you click "Proceed button" it will link to the Second Frame...Thank you :) First frame code: //First import javax.swing.*; import java.awt.event.*; import java.io.*; public class Sample extends JFrame implements ActionListener { JMenuBar mb; JMenu file; JMenuItem open; JTextArea ta; JButton proceed= new JButton("Proceed"); Sample() { open = new JMenuItem("Open File"); open.addActionListener(this); file = new JMenu("File"); file.add(open); mb = new JMenuBar(); mb.setBounds(0, 0, 400, 20); mb.add(file); ta...

  • Modify Java Code below: - Remove Button Try the Number -Instead of Try the Number button...

    Modify Java Code below: - Remove Button Try the Number -Instead of Try the Number button just hit enter on keyboard to try number -Remove Button Quit import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; // Main Class public class GuessGame extends JFrame { // Declare class variables private static final long serialVersionUID = 1L; public static Object prompt1; private JTextField userInput; private JLabel comment = new JLabel(" "); private JLabel comment2 = new JLabel(" "); private int...

  • There 2 parts to complete: import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Q4 extends JFrame...

    There 2 parts to complete: import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Q4 extends JFrame { private int xPos, yPos; public Q4() { JPanel drawPanel = new JPanel() { @Override public void paintComponent(Graphics g) { super.paintComponent(g); // paint parent's background //complete this: } }; drawPanel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { //complete this :- set the xPos, yPos }    }); setContentPane(drawPanel); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("Mouse-Click Demo"); setSize(400, 250); setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() {...

  • With the Code below, how would i add a "Back" Button to the bottom of the...

    With the Code below, how would i add a "Back" Button to the bottom of the history page so that it takes me back to the main function and continues to work? import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextField; public class RecipeFinder { public static void main(String[]...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT