Question

Extend Your Interface Review Exercise Extend your GUI list application using Eclipse and WindowBuilder to include the followi

I want to extend this GUI application in java language. Thanks for the help in advance.

import java.awt.EventQueue;

import javax.swing.JFrame;

import javax.swing.JButton;

import java.awt.event.ActionListener;

import java.awt.event.ActionEvent;

public class FormWindow {

    private JFrame frame;

    /**

     * Launch the application.

     */

    public static void main(String[] args) {

        EventQueue.invokeLater(new Runnable() {

            public void run() {

                try {

                    FormWindow window = new FormWindow();

                    window.frame.setVisible(true);

                } catch (Exception e) {

                    e.printStackTrace();

                }

            }

        });

    }

    /**

     * Create the application.

     */

    public FormWindow() {

        initialize();

    }

    /**

     * Initialize the contents of the frame.

     */

    private void initialize() {

        frame = new JFrame();

        frame.setBounds(100, 100, 450, 300);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        frame.getContentPane().setLayout(null);

       

        JButton btnNewButton = new JButton("Exit App!");

        btnNewButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {

                System.exit(0);

            }

        });

        btnNewButton.setBounds(149, 104, 127, 73);

        frame.getContentPane().add(btnNewButton);

       

        JButton btnNewButton_1 = new JButton("Write Output");

        btnNewButton_1.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {

                System.err.println("Output Test");

            }

        });

        btnNewButton_1.setBounds(149, 59, 127, 34);

        frame.getContentPane().add(btnNewButton_1);

    }

}


Student.java Account.java Sys def Write Output Exit App!

Extend Your Interface Review Exercise Extend your GUI list application using Eclipse and WindowBuilder to include the following new features. 1. Add items to the list using a text field on your form 2. Remove items by index using a different text field on your form 3. Add 100 randomly generated items to the list Upload your Window.java file as well as a Word document with screen-shots of your application.
Student.java Account.java Sys def Write Output Exit App!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

package say.swing;

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.awt.event.ActionEvent;

public class FormWindow {
   private JFrame frame;

   /**
   * Launch the application.
   */

   List<String> listItem = new ArrayList<String>();

   public static void main(String[] args) {
       EventQueue.invokeLater(new Runnable() {
           public void run() {
               try {
                   FormWindow window = new FormWindow();
                   window.frame.setVisible(true);
               } catch (Exception e) {
                   e.printStackTrace();
               }
           }
       });
   }

   /**
   * Create the application.
   */
   public FormWindow() {
       initialize();
   }

   /**
   * Initialize the contents of the frame.
   */
   private void initialize() {
       //UI componenets
       frame = new JFrame();
       frame.setBounds(100, 100, 450, 300);
       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       frame.getContentPane().setLayout(null);

       JTextField addItem = new JTextField("Add Item");
       JTextField removeItem = new JTextField("Remove Item");

       JButton addItemButton = new JButton("Add Item");
       JButton removeItemButton = new JButton("Remove Item");
       //Event listner
       removeItemButton.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
               if (removeItem.getText().trim().length() != 0) {
                   //Check index and display message or delete
                   int index = Integer.parseInt(removeItem.getText().trim());
                   if(index > listItem.size()) {
                       JOptionPane.showMessageDialog(null, "Index out of range. Enter index with in " + (listItem.size()-1));
                   }else {
                       listItem.remove(index);
                   }
               }
                  
               else
                   JOptionPane.showMessageDialog(null, "Write something in add item box then click button");
           }
       });
       addItem.setBounds(50, 10, 100, 25);
       removeItem.setBounds(200, 10, 100, 25);
       frame.getContentPane().add(addItem);
       frame.getContentPane().add(removeItem);
       ////Event listner
       addItemButton.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
               //Check index and display message or add
               if (addItem.getText().trim().length() != 0)
                   listItem.add(addItem.getText().trim());
               else
                   JOptionPane.showMessageDialog(null, "Write something in add item box then click button");
           }
       });

       addItemButton.setBounds(10, 104, 127, 73);
       frame.getContentPane().add(addItemButton);
       removeItemButton.setBounds(300, 104, 127, 73);
       frame.getContentPane().add(removeItemButton);
       JButton btnNewButton = new JButton("Exit App!");
       ////Event listner
       btnNewButton.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
               //Exit
               System.exit(0);
           }
       });
       btnNewButton.setBounds(149, 174, 127, 73);
       frame.getContentPane().add(btnNewButton);
       //Write output
       JButton btnNewButton_1 = new JButton("Write Output");
       //Event listner
       btnNewButton_1.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
               //Loop thru all item
               StringBuffer sb = new StringBuffer();
               for(String s: listItem) {
                   sb.append(s+" ");
                   //Print to console
                   System.out.println(s);
               }
               //Display
               JOptionPane.showMessageDialog(null, sb.toString());
           }
       });
       btnNewButton_1.setBounds(149, 59, 127, 34);
       frame.getContentPane().add(btnNewButton_1);
   }
}

-----------

FormWindow [Java Application] C: te cation. ne Two Four Five 3 Write Output Bro of the frame ontents lize() { Message Add Ite

Add a comment
Know the answer?
Add Answer to:
I want to extend this GUI application in java language. Thanks for the help in advance. import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JButton; import java.awt.event.Action...
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
  • I am getting this Error can you please fix my Java code. import java.awt.Dialog; import java.awt.Label;...

    I am getting this Error can you please fix my Java code. import java.awt.Dialog; import java.awt.Label; import java.awt.TextArea; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class Fall_2017 {    public TextArea courseInput;    public Label textAreaLabel;    public JButton addData;    public Dialog confirmDialog;    HashMap<Integer, ArrayList<String>> students;    public Fall_2017(){    courseInput = new TextArea(20, 40);    textAreaLabel = new Label("Student's data:");    addData = new JButton("Add...

  • Simple java GUI language translator. English to Spanish, French, or German import javax.swing.*; import java.awt.*; import...

    Simple java GUI language translator. English to Spanish, French, or German import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class translatorApp extends JFrame implements ActionListener {    public static final int width = 500;    public static final int height = 300;    public static final int no_of_lines = 10;    public static final int chars_per_line = 20;    private JTextArea lan1;    private JTextArea lan2;    public static void main(String[] args){        translatorApp gui = new translatorApp();...

  • 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);       ...

  • I have currently a functional Java progam with a gui. Its a simple table of contacts...

    I have currently a functional Java progam with a gui. Its a simple table of contacts with 3 buttons: add, remove, and edit. Right now the buttons are in the program but they do not work yet. I need the buttons to actually be able to add, remove, or edit things on the table. Thanks so much. Here is the working code so far: //PersonTableModel.java import java.util.List; import javax.swing.table.AbstractTableModel; public class PersonTableModel extends AbstractTableModel {     private static final int...

  • 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...

  • please help me debug this Create a GUI for an application that lets the user calculate...

    please help me debug this Create a GUI for an application that lets the user calculate the hypotenuse of a right triangle. Use the Pythagorean Theorem to calculate the length of the third side. The Pythagorean Theorem states that the square of the hypotenuse of a right-triangle is equal to the sum of the squares of the opposite sides: alidate the user input so that the user must enter a double value for side A and B of the triangle....

  • This is the java GUI program. I want to add an icon to a button, but...

    This is the java GUI program. I want to add an icon to a button, but it shows nothing. Can you fix it for me please? import java.awt.BorderLayout; import java.awt.Container; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; class Icon extends JFrame{ public static void main(String args[]){ Icon frame = new Icon("title"); frame.setVisible(true); } Icon(String title){ setTitle(title); setBounds(100, 100, 300, 250); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(); ImageIcon icon1 = new ImageIcon("https://static.thenounproject.com/png/610387-200.png"); JButton button1 = new JButton(icon1); p.add(button1); Container contentPane...

  • Using the template below create a GUI with a push button event. Use a JTextArea to...

    Using the template below create a GUI with a push button event. Use a JTextArea to display which button was selected. /******************* Name: Date: Notes:     *******************/ import javax.swing.*; import java.awt.*; import java.awt.event.*; class Actions extends JFrame implements ActionListener { Create the components (textarea and buttons)    public Actions()    {      create the window (include a close operation)              create the container (include FlowLayout)           add the event listeners (button.addActionListener)           add the components      }           public...

  • 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...

  • GUI in java: Run the below code before doing the actionlistener: import java.awt.*; import javax.swing.*; public...

    GUI in java: Run the below code before doing the actionlistener: import java.awt.*; import javax.swing.*; public class DrawingFrame extends JFrame {    JButton loadButton, saveButton, drawButton;    JComboBox colorList, shapesList;    JTextField parametersTextField;       DrawingFrame() {        super("Drawing Application");        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        JToolBar toolbar = new JToolBar();        toolbar.setRollover(true);        toolbar.add(loadButton=new JButton("Load"));        toolbar.add(saveButton=new JButton("Save"));        toolbar.addSeparator();        toolbar.add(drawButton=new JButton("Draw"));               toolbar.addSeparator();        toolbar.addSeparator();        toolbar.add(new...

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