Write a program in Java that meets the following specifications: The program is a stand-alone GUI application (not an appleth with an interface as shown below. At the top of the window, there are three text fields. The next row contains three buttons. The bottom part of the window is a text area with a vertical scrollbar. Textio Demo output.txt input.txt Read From Text File Write to Text File Read a Record from File 102340 342343 483423 623483 923842 745234 326234 The user can enter a file name in the leftmost text field. Assume that the file name entered corresponds to an existing text file on the disk, and that the text file contains a set of account numbers, one account number in each line. When the user clicks the “Read From Text File” button, the program should read the contents from the corresponding file and display its contents in the text area as shown in the figure above. 3. The user can enter a file name in the center text field. You can assume that a file with the name entered does not exist on the disk. When the user click the “Write to Text File” button, the program should create a text file with the name entered, and write to it the all the account numbers in the text area) as integers (not strings) in an increasing order (use bubble sort for this purpose). 4. The user can enter a number in the rightmost text field to retrieve an account number from the text file created in (3). Let this number ben. When the user clicks the “Read a Record from File” button, the program should retrieve the neth account number from the text file and display it in the text area replacing any existing content in the text area. I could be 0, 1, 2, and so on, with 0 corresponding to the first account number. For example, if the user enters in the text field as shown in the picture and clicks the “Read a Record from File” button, the program should display the first account number in the text area. For simplicity, you can assume that is small enough that the n-th account number exists in the file. 5. In (2), (3), and (4), whenever an exception happens, the program should display the exception message in the text area, replacing any existing content in the text area. Here are some of th. program. some of the Apes that you may use. Note so that you probably GridLayout(int Tows, int cols) Creates a grid layout with the specified layout are given qual size. bly won’t be using all of them in the bet w e. ins. All components in the Border Layout() Constructs a new border layout with no gaps between components JTextField(int columns) Constructs a new empty text field with the specified s of cow public String getText() Returns the text contained in this JTextField JButton(string text) Creates a button with text. JTextArea() Constructs a new TextArea. public append (String str) Appends the given text to the end of the text area public void setText(String t) Sets the text of this text area to the specified text. JPanel() Creates a new JPanel with a double buffer and a flow layout. JScroll Pane (Component view) Creates a JScrollpane that displays the contents of the specified compone horizontal and vertical scrollbars appear whenever the component’s conte te contents of the specified component, where both le component’s contents are larger than the view. File (String pathname) Creates a new File instance by converting the given pathname string into an abstract pas Scanner (File source) Constructs a new Scanner that produces values scanned from the specified the boolean hasNextLine() Returns true if there is another line in the input of this scanner. void nextLine() Advances this scanner past the current line and returns the input that was skipped. void close() Closes this scanner. PrintWriter (File file) Creates a new Print Writer, without automatic line flushing, with the specified file. PrintWriter (String fileName) Creates a new Print Writer, without automatic line flushing, with the specified file name. void print(int i) Prints an integer. Show transcribed image text Write a program in Java that meets the following specifications: The program is a stand-alone GUI application (not an appleth with an interface as shown below. At the top of the window, there are three text fields. The next row contains three buttons. The bottom part of the window is a text area with a vertical scrollbar. Textio Demo output.txt input.txt Read From Text File Write to Text File Read a Record from File 102340 342343 483423 623483 923842 745234 326234 The user can enter a file name in the leftmost text field. Assume that the file name entered corresponds to an existing text file on the disk, and that the text file contains a set of account numbers, one account number in each line. When the user clicks the “Read From Text File” button, the program should read the contents from the corresponding file and display its contents in the text area as shown in the figure above. 3. The user can enter a file name in the center text field. You can assume that a file with the name entered does not exist on the disk. When the user click the “Write to Text File” button, the program should create a text file with the name entered, and write to it the all the account numbers in the text area) as integers (not strings) in an increasing order (use bubble sort for this purpose). 4. The user can enter a number in the rightmost text field to retrieve an account number from the text file created in (3). Let this number ben. When the user clicks the “Read a Record from File” button, the program should retrieve the neth account number from the text file and display it in the text area replacing any existing content in the text area. I could be 0, 1, 2, and so on, with 0 corresponding to the first account number. For example, if the user enters in the text field as shown in the picture and clicks the “Read a Record from File” button, the program should display the first account number in the text area. For simplicity, you can assume that is small enough that the n-th account number exists in the file. 5. In (2), (3), and (4), whenever an exception happens, the program should display the exception message in the text area, replacing any existing content in the text area.
Here are some of th. program. some of the Apes that you may use. Note so that you probably GridLayout(int Tows, int cols) Creates a grid layout with the specified layout are given qual size. bly won’t be using all of them in the bet w e. ins. All components in the Border Layout() Constructs a new border layout with no gaps between components JTextField(int columns) Constructs a new empty text field with the specified s of cow public String getText() Returns the text contained in this JTextField JButton(string text) Creates a button with text. JTextArea() Constructs a new TextArea. public append (String str) Appends the given text to the end of the text area public void setText(String t) Sets the text of this text area to the specified text. JPanel() Creates a new JPanel with a double buffer and a flow layout. JScroll Pane (Component view) Creates a JScrollpane that displays the contents of the specified compone horizontal and vertical scrollbars appear whenever the component’s conte te contents of the specified component, where both le component’s contents are larger than the view. File (String pathname) Creates a new File instance by converting the given pathname string into an abstract pas Scanner (File source) Constructs a new Scanner that produces values scanned from the specified the boolean hasNextLine() Returns true if there is another line in the input of this scanner. void nextLine() Advances this scanner past the current line and returns the input that was skipped. void close() Closes this scanner. PrintWriter (File file) Creates a new Print Writer, without automatic line flushing, with the specified file. PrintWriter (String fileName) Creates a new Print Writer, without automatic line flushing, with the specified file name. void print(int i) Prints an integer.
Expert Answer
Answer to Write a program in Java that meets the following specifications: The program is a stand-alone GUI application (not an ap…