Program:
---------------------------------------------------------------------------------------------------------------------------------
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JTextField;
import java.awt.*;
public class Message {
JFrame dialBox;
Message(){
dialBox=new JFrame();
JOptionPane.showMessageDialog(dialBox,"Click OK to
continue");
}
}
public class Example {
static JTextField textField;
static JButton nextB,okB;
public static void main(String[] args) {
JFrame f = new JFrame("My First GUI");
f.setSize(700, 900);
f.setDefaultCloseOperation(EXIT_ON_CLOSE);
nextB=new JButton("Next");
f.add(nextB, BorderLayout.NORTH);
textfield = new JTextField("Text field");
f.add(textField, BorderLayout.SOUTH);
okB=new JButton("Ok");
f.add(okB, BorderLayout.EAST);
nextB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Message();
}
});
f.setVisible(true);
}
}
---------------------------------------------------------------------------------------------------------
Explanation:
First of all we have imported the packages that we needed in our program.
After that come directly to the Example class where our main function is present. Here we have declared two buttons and one text field which we want in our frame.
And then we start our main function. First of all we have created a JFrame having name f and we have passed the name in the constructor (whatever name we send in the constructor, it is showed on the top bar of the frame).
Then we fixed the size of frame 700*900 pixels by using setSize() function.
By default the frame will show the cross button but it does not work. So we used the setDefaultCloseOperation(EXIT_ON_CLOSE) to make it functionable.
Then we have taken taken instances of buttons okB, nextB by passing the names of Buttons which we want to show on the buttons (Ok, Next), then we attached the buttons to the frame with f.add() where 1st argument is button variable name and 2nd argument to position the buttons like NORT,SOUTH,EAST,WEST, CENTRE: there are five positions we can set.
Then we took the instance of text field and positioned it as same steps as of buttons.
Then we had to show a dialog box on clicking the next button. For that, we have attached an actionListener with the button which will execute the steps defined in it, every time it gets clicked. For the dialog box we have taken another class Message to open the dialog box where we used predefined function showMessageDialog() of JOptionPane Class( where 1st argument is the variable name of frame and 2nd is the message we want to show) to open the dialog box.
And the frame will not appear until we set its visibility as true by setVisible(true).
Java Help References Mailings Review View No Spacing Heading 1 Heading 2 Normal For following questions, please provided your solutions for each of the questions in a separate Word document to...
Mailings Review View AaBbccodte A aBbCcD AaBbceDdE Aal Normal No Spacing Heading 1 Heading 2 Tit #C Trump corporate tax; health insurance; luncheon club dilemma 1. computation of shareholder's tax rate when corporate tax rate is 35% and the dividend tax is 15% la, how does this change when corporate tax rate changes into 15%? 2. Consider an insurance policy of full coverage (all expenses covered). When a person is hospitalized, the patient bears no financial cost if her stay...
i want answers please ??? Answers to Self-Review Exercises 625 14.3 d) In a BorderLayout, two buttons added to the NORTH region will be placed side by side. e) A maximum of five components can be added to a BorderLayout ) Inner classes are not allowed to access the members of the enclosing class. B) A TextArea's text is always read-only. h) Class TextArea is a direct subclass of class Component. Find the error(s) in each of the following statements,...
Document Layout References Mailings Review View AS MADAM ABCD ABCD AaBb CODE Heading * 1) ITV Company received $36,000 cash on March 1, 2019, from XYZ Company as an advance payment for services ITV promised to perform for XYZ over the next three years on a continuous basis. Assume that ITV Company's year-end is December 31. On its 2020 income statement, ITV would report revenue of 2) On October 1, Year 1, Senegal Company paid $1,200 in advance for rent...
Project overview: Create a java graphics program that displays an order menu and bill from a Sandwich shop, or any other establishment you prefer. In this program the design is left up to the programmer however good object oriented design is required. Below are two images that should be used to assist in development of your program. Items are selected on the Order Calculator and the Message window that displays the Subtotal, Tax and Total is displayed when the Calculate...
Flooding activity online Compatibility Mode Saved Picture Tools joykaffenber Design Layout References Mailings Review View Help Format AaBbCel AaBbC AaBbCcl AaBbCcl Aa Heading 1 Paragraph Font Styles GLY 120This Dangerous Earth Flooding Activity The Corps of Engineers Presents: H:0 Overload Assignment: Floodplain Management Details: You are the developer of a new community and must decide where to construct the following: a city park, a hospital, and a self storage business. The locations chosen for each construction site should correspond with...
need answers to questions 1-4 Me 9Search ACC111 GroupProjectilnstructions_V1a.docx - Saved Help View Review Mailings References Layout AaBbCcD AaBbCcDx AaBbi AaBbCcC AaB A 1 Normal 1 No Spac. Heading 1 Heading 2 A A Aa- Ap Title A-D- A- Styles Paragraph Group Project 1 Let's examine a case using Sal's Silly Song Corporation and Greg's Tunes Corporation. It is now the end of the first year of operations and both company's want to know how well they came out at...
Java Painter Class This is the class that will contain main. Main will create a new Painter object - and this is the only thing it will do. Most of the work is done in Painter’s constructor. The Painter class should extend JFrame in its constructor. Recall that you will want to set its size and the default close operation. You will also want to create an overall holder JPanel to add the various components to. It is this JPanel that...
please help me. thank you in advance. Assignment%20#%204%20Case%20Study(11.doalCompatibility Medel-word EVIEW VIEW 1 Normal No Spacing Heading 1 Heading2 Te Subiale Sulbtle Em.. Eemphasis Intense E. S Styles Assignment # 4-Case Study-second assignmnt-using MSDS in urgent situations Must use MSDS!! You are walking down the hallway of your facility, and you see a housekeeper frantically signaling fo You approach the housekeeper and notice that her eyes are red, watery, and they are itchy. She is rubbing her hands on her face,...
JAVA Hello I am trying to add a menu to my Java code if someone can help me I would really appreacite it thank you. I found a java menu code but I dont know how to incorporate it to my code this is the java menu code that i found. import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JRadioButtonMenuItem; public class MenuExp extends JFrame { public MenuExp() { setTitle("Menu Example");...
the first question java code eclipse app the second question is java fx gui caculator please fast 1. Create project called "YourFirstName_QUID'. Eg. Aliomar_202002345 2. Create two package Q1 and Q2. 3. Add your name and studentID as comments on the top of each Java source file you submit. Question 1. Bookings APP [80 Points-six parts] Implement the following hotel booking system. Use the following class diagram to understand the structure of the system's classes, their attributes operations (or methods),...