1. DocumentViewer.java
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.io.File;
class DocumentViewer {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final JFrame f = new JFrame("Document Viewer");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JFileChooser fileChooser = new JFileChooser();
final FileNameExtensionFilter filter = new FileNameExtensionFilter("TEXT FILES", "txt", "text");
fileChooser.setFileFilter(filter);
JPanel gui = new JPanel(new BorderLayout());
final JEditorPane document = new JEditorPane();
document.setEditable(false);
document.setFont(new Font("Serif", Font.BOLD, 15));
gui.add(new JScrollPane(document), BorderLayout.CENTER);
JButton open = new JButton("Open");
open.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
int result = fileChooser.showOpenDialog(f);
if (result == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
try {
document.setPage(file.toURI().toURL());
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
gui.add(open, BorderLayout.NORTH);
f.setContentPane(gui);
f.pack();
f.setSize(700, 700);
f.setLocationByPlatform(true);
f.setVisible(true);
}
});
}
}
The Output is attached below:-
Please let me know in case of any clarifications required. Thanks!
In Java please, thank you! Design a GUI application as shown below and perform the following...
In Java please Create a GUI application that accepts student registration data. The GUI with valid data Shudent Fagtrtion x Rt Name Haold Moore Lst Name Yar of Brth 2001 Temporary PesowordHal200 Wlcome Harald Moore! RegsterEt The GUI with invalid data Shudent Fegtrtion DX Fect Name Haold Last Name ar of Brth 2001 Tempoay Pawod Haold 200 Pesse eer St and lact name and ye of bith Regster Et Specifications Use FXML to create the GUI The text box that...
Java GUI Help! Hi, I have a Java GUI exercise that I need to complete and was wondering if I could have a little bit of help... you can see it below. Create a simple graphical application that will enable a user to perform push, pop and peek operations on a stack and display the resulting stack (using toString) in a text area. Any help would be much appreciated! Thank you.
Write a java program that demonstrates recursion. This program can be in a java GUI frame or as a console application. On this one it is up to you. (It would probably work better as a console program for this particular program.) The input for this program is a number of boxes. Ask the user for this with a textbox or a prompt on the command line. Demonstrate recursion with a function called LoadTruck() that takes a number of boxes...
In Java. Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...
In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student information system. The application should allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID. The user should be able to view/edit an existing student. Do not allow student to edit ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique...
USING JAVA and NOTTT using BufferedReader or BufferedWriter Write an application that implements a simple text editor. Use a text field and a button to get the file. Read the entire file as characters and display it in a TextArea. The user will then be able to make changes in the text area. Use a Save button to get the contents of the text area and write that over the text in the original file. Hint: Read each line from...
in java plz and not using bufferedreader or bufferedwriter!! Write an application that implements a simple text editor. Use a text field and a button to get the file. Read the entire file as characters and display it in a TextArea. The user will then be able to make changes in the text area. Use a Save button to get the contents of the text area and write that over the text in the original file. Hint: Read each line...
Please design a Java GUI application with two JTextField for user to enter the first name and last name. Add two JButtons with action events so when user click on one button to generate a full name message from the user input and put it in a third JTextField which is not editable; and click on the other button to clear all three JTextField boxes. Please run the attached nameFrame.class file (Note: because there is an actionhandler inner class in...
Write a GUI-based Java application that implements the "Math Game" shown below. The program asks the user to enter the answer of multiplying two one-digit random integers. If the user enters a correct answer, a message will be displayed at the bottom of the frame, and the text field will be cleared. If the user enters a wrong answer, a message will be displayed at the bottom of the frame asking for another answer. If the user...