Question

In: Computer Science

Write a program in Java, that creates a Jframe with a menu containing only file. Inside...

Write a program in Java, that creates a Jframe with a menu containing only file. Inside file there should be items: Open, Save, and Save As. Selecting open prompts the user to input a file name to a txt document containing employee information and displays a Jtable with the information, which can be edited. With column headers {"First Name" , "Last Name" , "Occupation" , "Office #"}

Example: Gary Osbourn Teacher 113

Michelle Ramirez Teacher 101

Ava Gomez Principal 120

The user should be able to save any changes made to the table with save. Using Save As the program should ask the user for a file name to save the new program as.

Solutions

Expert Solution

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Test
{
    public JFrame frame;
    public JTextField text;
    public JLabel message;
    public JTable table;
    public JButton save,open,saveas;

    public Test()
    {
        String cols[] = {"First Name","Last Name","Occupation","Office #"};
        frame = new JFrame("Table Software");
        frame.setLayout(new FlowLayout());
        text = new JTextField();
        text.setBounds(10,10,400,40);
        message = new JLabel("");
        table = new JTable();
        save = new JButton("Save");
        open = new JButton("Open");
        saveas = new JButton("Save As");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(500,500);
        JPanel panel = new JPanel();
        panel.setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridx = 1;
        gbc.gridy = 0;
        panel.add(open,gbc);
        gbc.gridx = 0;
        gbc.gridy = 0;
        panel.add(save,gbc);
        gbc.gridx = 2;
        gbc.gridy = 0;
        panel.add(saveas,gbc);
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridx = 0;
        gbc.gridy = 3 ;
        gbc.gridwidth = 3;
        panel.add(text,gbc);
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridx = 0;
        gbc.gridy = 5 ;
        gbc.gridwidth = 5;
        panel.add(table,gbc);
        frame.add(panel);
        frame.setVisible(true);
        open.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
        saveas.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
        save.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
    }
    public static void main(String Args[])
    {
        Test t = new Test();
    }
}

This is the base construct. Please build over this.


Related Solutions

Write a program in Java that reads a file containing data about the changing popularity of...
Write a program in Java that reads a file containing data about the changing popularity of various baby names over time and displays the data about a particular name. Each line of the file stores a name followed by integers representing the name’s popularity in each decade: 1900, 1910, 1920, and so on. The rankings range from 1 (most popular) to 1000 (least popular), or 0 for a name that was less popular than the 1000th name. A sample file...
Write a program in Java to: Read a file containing ones and zeros into a two-dimensional...
Write a program in Java to: Read a file containing ones and zeros into a two-dimensional int array. Your program must (1) read the name of the file from the command-line arguments, (2) open the file, (3) check that each line has the same number of characters and (4) check that the only characters in a line are ones and zeros. If there is no such command-line argument or no such file, or if any of the checks fail, your...
1. Write a Java program and Submit only "one .java file" calledNumbers that calls the...
1. Write a Java program and Submit only "one .java file" called Numbers that calls the following methods and displays the returned value:o Write a method called cubeIt that accepts one integer parameter and returns the value raised to the third power as an integer.2. Write a method called randomInRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive.o Write a method called larger that accepts two double parameters and...
Java Write a program that will only accept input from a file provided as the first...
Java Write a program that will only accept input from a file provided as the first command line argument. If no file is given or the file cannot be opened, simply print “Error opening file!” and stop executing. A valid input file should contain two lines. The first line is any valid string, and the second line should contain a single integer. The program should then print the single character from the string provided as the first line of input...
Write a program that creates an output file named rand_nums.txt. Open the file and write 100...
Write a program that creates an output file named rand_nums.txt. Open the file and write 100 random integers between -50 and +50 (inclusive) to the file. Be sure to handle any file IO exceptions. Remember to close the file. Write a program that opens rand_nums.txt for input. Create two output files pos.txt and neg.txt. Read through the input file, one line at a time, converting each line into an integer (no exception handling, yet). If the number is positive, write...
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this circle the word “GO” with Arial font and size 24, bold face needs to be printed. Justify your syntax.   answer within 25 min plzzz
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this circle the word “GO” with Arial font and size 24, bold face needs to be printed. Justify your syntax. I need this answer ASAP PLZ.
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this circle the word “GO” with Arial font and size 24, bold face needs to be printed. Justify your syntax.
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this circle the word “GO” with Arial font and size 24, bold face needs to be printed. Justify your syntax
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this circle the word “GO” with Arial font and size 24, bold face needs to be printed. Justify your syntax.  
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT