A restaurant chain that has 3 locations in Portland is trying to determine which of their 3 locations they should keep open on New Year’s Eve. They survey a random sample of customers at each location and ask each whether or not they plan on going out to eat on New Year’s Eve. The results are below. Run a test for independence to decide if the proportion of customers that will go out to eat on New Year’s Eve is dependent on location. Use α=0.05.
|
NW Location |
NE Location |
SE Location |
|
|
Will Go Out |
66 |
40 |
45 |
|
Won’t Go Out |
20 |
25 |
20 |
Can it be concluded that the choice to go out on New Year's Eve is dependent on restaurant location?
No, it cannot be concluded that the choice to go out on New Year's Eve is dependent on restaurant location because the p-value = 0.8706
Yes, it can be concluded that the choice to go out on New Year's Eve is dependent on restaurant location because the p-value = 0.8706
Yes, it can be concluded that the choice to go out on New Year's Eve is dependent on restaurant location because the p-value = 0.1294.
No, it cannot be concluded that the choice to go out on New Year's Eve is dependent on restaurant location because the p-value = 0.1294.
In: Statistics and Probability
Conversion is the process of switching from the old (computer or manual) system to the new Information System. There are four conversion methods.
· Parallel conversion. Where you run both the new and the old for a time before switching off the old.
· Pilot conversion. Where you implement and test the new system, on a small scale in one business unit, then you expand the conversion to include all of the other business units.
· Phased conversion. Where over time you gradually use more of the new and less of the old until you are completely converted.
· Direct (Plunge in diagram) conversion. Where you switch off the old and switch on the new at the same time.
1. Explain which of the conversion methods would be suitable for the following. Justify your choice:
2. List four reasons why your participation as a user of an information system is critical during the systems development life cycle, linking the concepts of user involvement and change management in a software implementation project.
3. Why is it so important to understand how a business process works when trying to develop a new information system?
In: Computer Science
Each student should choose a company and create a new product or service for the company chosen (It can be any company). The new product or service must be consistent with the company’s current offerings. An example of an inconsistent product offering would be if Chrysler (an automotive company) began to sell chocolate. The final project should consist of the following items:
1. Executive Summary
This section should focus on providing a concise overview of your new product or service and how the company will benefit by offering this new product or service.
2. Company and Product/Service Description
This section should consist of an overview of the company you have selected. What is the company’s current focus? In what industry does the company currently compete? What product/service do you think the company should introduce? How does this product/service fit in with the company’s current product/service offerings?
3. Strategic Focus
Think about the core benefits of your new product or service. Focus on how your new product or service meets consumer’s wants and needs.
4. Situation Analysis (think of factors affecting both your company as a whole and the new product/service).
What are the (internal and external) environmental factors to think about? For example,
1) the potential investment required to introduce your product or service
2) the competition for the new product or service.
5. Marketing Program (for your new product)
STP: How is the market for this product segmented? What is the target market for your product or service? Is this a target market the company is already focusing on or would this be a new target market for the company? What will be your product's positioning?
The 4Ps: How do you plan to market your new product or service? Is your product or service something that the company will sell on its own or will it be sold in addition to one of the company’s current products or services? What will be your Marketing Mix Strategies (the 4 Ps)?
6. Works Cited Page
Please provide a works-cited page in MLA format.
The final paper should be about 6-pages doubled spaced, Times New Roman, 12pt font.
In: Operations Management
Java homework problem:
I need the code to be able to have a message if I type in a letter instead of a number. For example, " Please input only numbers". Then, I should be able to go back and type a number.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class LoginGui {
static JFrame frame = new JFrame("JFrame
Example");
public static void main(String s[]) {
JPanel panel = new JPanel();
panel.setLayout(null);
final JLabel label3 = new
JLabel("Adult ticket $50.Children ticket $25");
label3.setBounds(150, 15, 500,
30);
JLabel label1 = new JLabel("Enter
the number of adult ticket: ");
label1.setBounds(200, 50, 300,
30);
final JTextField adult = new
JTextField(10);
adult.setBounds(400, 50, 100,
30);
JLabel label2 = new
JLabel("Enter the number of children ticket: ");
label2.setBounds(200, 100, 250,
30);
// password field
final JTextField children = new
JTextField(10);
children.setBounds(400, 100, 100,
30);
JButton login = new
JButton();
login.setText("Calculate total
cost");
login.setBounds(200, 150, 250,
20);
JLabel total = new JLabel("Total
Price: ");
total.setBounds(200, 200, 300,
30);
final JTextField totalPrice =
new JTextField(10);
totalPrice.setBounds(400, 200, 100,
30);
totalPrice.setEditable(false);
JButton exit = new
JButton();
exit.setText("Exit");
exit.setBounds(320, 150, 100,
20);
login.addActionListener(new ActionListener() {
@Override
public void
actionPerformed(ActionEvent aE) {
String a = adult.getText();
String c = children.getText();
int ad = 0;
if (a.trim().length() != 0)
ad =
Integer.parseInt(a);
int ac = 0;
if (c.trim().length() != 0)
ac =
Integer.parseInt(c);
totalPrice.setText((ac * 25 + ad * 50) +
"");
}
});
panel.add(label1);
panel.add(label2);
panel.add(label3);
panel.add(adult);
panel.add(children);
panel.add(login);
panel.add(exit);
panel.add(totalPrice);
panel.add(total);
frame.add(panel);
frame.setSize(600, 300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
In: Computer Science
Currently, Forever Flowers Inc. has a capital structure consisting of 30% debt and 70% equity. Forever's debt currently has an 7% yield to maturity. The risk-free rate (rRF) is 4%, and the market risk premium (rM- rRF) is 8%. Using the CAPM, Forever estimates that its cost of equity is currently 12%. The company has a 40% tax rate. The data has been collected in the Microsoft Excel Online file below. Open the spreadsheet and perform the required analysis to answer the questions below. Do not round intermediate calculations.
Open spreadsheet
| Recapitalization | ||||||
| % debt in original capital structure, wd | 30.00% | |||||
| % common equity in original capital structure, wc | 70.00% | |||||
| Yield to maturity on debt, rd | 7.00% | |||||
| Risk-free rate, rRF | 4.00% | |||||
| Market risk premium (rM - rRF) | 8.00% | |||||
| Cost of common equity, rs | 12.00% | |||||
| Tax rate | 40.00% | |||||
| % debt in new capital structure, wd New | 40.00% | |||||
| % common equity in new capital structure, wc New | 60.00% | |||||
| Changed yield to maturity on debt, rd New | 10.00% | |||||
| Current WACC calculation: | Formulas | |||||
| WACC | #N/A | |||||
| Current beta calculation: | ||||||
| Levered beta, bL | #N/A | |||||
| Unlevered beta calculation: | ||||||
| bU | #N/A | |||||
| Cost of equity calculation with changed capital structure: | ||||||
| Levered beta, bL | #N/A | |||||
| Cost of equity with new capital strucutre, rs New | #N/A | |||||
| WACC calculation with new capital structure: | ||||||
| WACC New | #N/A | |||||
| Recommendation on capital structure: | #N/A | |||||
| Change or Do Not Change | ||||||
What is Forever's current WACC? Round your answer to two decimal places.
%
What is the current beta on Forever's common stock? Round your answer to two decimal places.
What would Forever's beta be if the company had no debt in its capital structure? (That is, what is Forever's unlevered beta, bU?) Round your answer to two decimal places.
Forever's financial staff is considering changing its capital structure to 40% debt and 60% equity. If the company went ahead with the proposed change, the yield to maturity on the company's bonds would rise to 10%. The proposed change will have no effect on the company's tax rate.
What would be the company's new cost of equity if it adopted the proposed change in capital structure? Round your answer to two decimal places.
%
What would be the company's new WACC if it adopted the proposed change in capital structure? Round your answer to two decimal places.
%
Based on your answer to part e, would you advise Forever to adopt the proposed change in capital structure?
| Recapitalization | ||||||
| % debt in original capital structure, wd | 30.00% | |||||
| % common equity in original capital structure, wc | 70.00% | |||||
| Yield to maturity on debt, rd | 7.00% | |||||
| Risk-free rate, rRF | 4.00% | |||||
| Market risk premium (rM - rRF) | 8.00% | |||||
| Cost of common equity, rs | 12.00% | |||||
| Tax rate | 40.00% | |||||
| % debt in new capital structure, wd New | 40.00% | |||||
| % common equity in new capital structure, wc New | 60.00% | |||||
| Changed yield to maturity on debt, rd New | 10.00% | |||||
| Current WACC calculation: | Formulas | |||||
| WACC | #N/A | |||||
| Current beta calculation: | ||||||
| Levered beta, bL | #N/A | |||||
| Unlevered beta calculation: | ||||||
| bU | #N/A | |||||
| Cost of equity calculation with changed capital structure: | ||||||
| Levered beta, bL | #N/A | |||||
| Cost of equity with new capital strucutre, rs New | #N/A | |||||
| WACC calculation with new capital structure: | ||||||
| WACC New | #N/A | |||||
| Recommendation on capital structure: | #N/A | |||||
| Change or Do Not Change |
In: Finance
Sandy Sucker, manager and owner of an advertising company in Port Hope, Ontario, had arranged a meeting with Bill Confused, the chief accountant of a large, local competitor. The two are lifelong friends. They grew up together in a small town and attended the same university. Bill was a competent, successful accountant but currently was experiencing some personal financial difficulties. The problems were created by some investments that had turned sour, leaving him with a $25,000 personal loan to pay off just at the time his oldest son was scheduled to enter college. Sandy, on the other hand was struggling to establish a successful advertising business. She had recently acquired the rights to open a branch of a large regional advertising firm headquartered in Windsor, Ontario. During her first two years, she had managed to build a small, profitable practice; however, the chance to gain a significant foothold in the Port Hope advertising community hinged on the success of winning a bid to represent the province of Ontario in a major campaign to attract new industry and tourism. The meeting she had scheduled with Bill concerned the bid she planned to submit. Sandy: “Bill, I'm at a critical point in my business venture. If I can win the bid for the state’s advertising dollars, I'll be set. Winning the bid will bring $750,000 to $1,000,000 of revenues into the firm. On top of that, I estimate that the publicity will bring another $350,000 to $400,000 of new business.” Bill: “I understand. My boss is anxious to win that business as well. It would mean a huge Increase in profits for my firm. It's a competitive business, though. As new as you are, I doubt that you'll have much chance of winning." Sandy: "You may be wrong. You're forgetting two very important considerations. First, I have the backing of all the resources and talent of a regional firm. Second, I have some political connections. Last year, I was hired to run the publicity side of the governor's campaign. He was impressed with my work and would like me to have this business. I am confident that the proposals I submit will be very competitive. My only concern is to submit a bid that beats your firm. If I come in with a lower bid and good proposals, the governor can see to it that I get the work." Bill: "Sounds promising. If you do win, however, there will be a lot of upset people. After .. all, they are going to claim that the business should have been given to local advertisers, not to some out-of-state firm. Given the size of your office, you'll have to get support from Atlanta. You could take a lot of heat." . Sandy: "True. But I am the owner of the branch office. That fact alone should blunt most of the criticism. Who can argue that I'm not local? Listen, with ·your help, I think I can win this bid. Furthermore, if I do win it, you can reap some direct benefits. With that kind of business; I can afford to hire an accountant, and I'll make it worthwhile for you to transfer jobs. I can offer you an up-front bonus of $25,000. On top of that, I'll increase 2 your annual salary by 20 percent. That should solve most of your financial difficulties. After all, we have been friends since day one and what are friends for?" Bill: "Sandy, my wife would be ecstatic if I were able to improve our financial position as Quickly as this opportunity affords. I certainly hope that you win the bid. What kind of help can I provide?" Sandy: "Simple, to win, all I have to do is beat the bid of your firm. Before 1 submit my bid, I would like you to review it. With the financial skills you have, it should be easy for you to spot any excessive costs that I may have included. Or perhaps I included the wrong kind of costs. By cutting excessive costs and eliminating costs that may not be directly related to the project, my bid should be competitive enough to meet or beat your firm's bid."
Required: a) What would you do if you were Bill Confused? Explain the reasons for your decision and apply the code of ethics to the proposal given, to Bill assume that Bill is a member of a professional accounting body.
In: Accounting
Discussion: (Do not attempt to solve if you can not answer all)
When educators attend conferences or workshops they are often inspired by the many new and exciting ideas they learn about and are prepared to put some of the newfound strategies into practice in the near future. Upon returning to the workplace, however, the computer or print file filled with handouts/notes is placed nearby on a shelf or in the corner of a desk. Then… reality sets in. The teacher reads the summary of the day(s) left by the substitute and determines what follow-up(s) must take place; she checks emails to see what immediate action must take place or which phone calls must be returned. The folder with all those exciting ideas sits lonely and neglected.When educators attend conferences or workshops they are often inspired by the many new and exciting ideas they learn about and are prepared to put some of the newfound strategies into practice in the near future. Upon returning to the workplace, however, the computer or print file filled with handouts/notes is placed nearby on a shelf or in the corner of a desk. Then… reality sets in. The teacher reads the summary of the day(s) left by the substitute and determines what follow-up(s) must take place; she checks emails to see what immediate action must take place or which phone calls must be returned. The folder with all those exciting ideas sits lonely and neglected.
We cannot be criticized for not implementing new ideas in a timely manner since our professional lives are filled with unexpected events and frequent interruptions. And let’s not forget… change is not easy.
On the other hand, it is important to remember that teaching is a profession, and in all professions, it is unrealistic to remain static and cling to ideas that may not be as effective in promoting student learning. We must be introducing new concepts/ideas into our repertoires. The file folder from the conference that holds new ways of thinking, deserves attention; thus, it is critical that we open that folder while the ideas are fresh in our minds. Remember, the ideas that were introduced in the workshop, regardless of how good they are, will have no impact on learning until we act on them. As a wise man once said, “It is not good enough to think outside the box, you must act outside the box as well.”
The
Gap
The inability to put new ideas into practice is called the
knowing-doing gap. It is a widely used moniker that is not unique
to education; it is taught in college courses, a vital part of
leadership training, and is a mainstay in the world of business. In
the words of Dale Carnegie, “Knowledge isn’t power until it is
applied.”
The
Wisdom
In a recent webinar, British researcher Dylan Wiliam provides a
great deal of insight about how teachers can reduce or even
eliminate the gap. The title of a recent blog by Dr. Wiliam says it
all: “Changing What Teachers Do is More Important Than Changing
What They Know.” The article focuses on the importance of teachers
reducing the achievement gap by embedding formative assessment
practices into their range of options. He states, “It’s not about a
magical intervention to help the kids this year; it’s about helping
teachers make decisions based on the level of understanding of all
students. That’s how you close the achievement gap.”
The
Strategies
Basing his conclusions on 35 years of experience in the field of
education, Wiliam recently shared five strategies he believes are
essential for the successful application of formative assessments
into a teacher’s instructional delivery. He proposes the following
practices:
Each and every student must understand what their learning experiences will entail and how success will be determined. Teachers must be specific and present practical examples that students will understand as they are explaining the lesson outcomes. When teachers clarify what success will look and sound like, students are much more likely to achieve it.
It is not good enough that students hear about the success criteria shared by their teacher; they must have the opportunity to participate in discussions with peers and share possible examples of success with one another. Thus, as a bi-product of the discussions, students will have a clear picture of success indicators.
Learning is being formed as students are engaged in specific activities to master the content. Simultaneously, the teacher can be observing and interacting with students to provide on-the-spot feedback in order to keep progress moving in the right direction. Remember… student engagement + feedback = success.
Students are often an excellent resource for one another as each individual works toward his “aha moment.” Discussions, critical thinking, and problem solving are all excellent sources of formative assessment data and they keep students actively involved in their learning process.
Teachers must repeatedly promote the understanding that all students are accountable for their individual learning. When students know, from the get-go, that they must take responsibility for their own learning, Wiliam has concluded that learning will dramatically increase.
The more options teachers have at their disposal, the deeper their discussions will be with their fellow teachers, and the stronger their use of formative assessment will become. Following Wiliam’s five steps will help to transfer educators more quickly and permanently from knowers to doers.
The
Actions
In his writing, Dr. Wiliam offers further suggestions that will
help teachers move into the action phase and move closer to reduce
or even eliminate the gap. He believes that teachers must get into
the “habit changing business.” He suggests the following
practices:
Choice – Instead of having top-down requirements for all teachers, giving individuals a choice about a practice they wish to implement will increase the likelihood that the implementation will become a permanent fixture. Wiliam writes, “When teachers themselves make the decision about what it is they wish to prioritize for their own professional development, they are more likely to make it work.” When teachers have the power to choose, they increase their level of expertise and take more responsibility to apply a strategy again and again.
Flexibility – Teaching styles differ and the students who make up individual classes can vary greatly. For this reason, when teachers learn a new strategy, they do not have to implement it in a lock-step manner. Wiliam believes that what is important is that the instructor is moving to action. He cautions, however, that a teacher should not change the essence of the idea to the point where it becomes ineffective.
Small Steps – Research evidence shows that teachers in general are slow to change their practice primarily because change is “genuinely difficult” and “immensely challenging.” Most educators become accustomed to doing things a certain way and it supports their comfort level. In order for the change to occur, Wiliam recommends moving slowly. He writes, “Small steps grow new expertise which makes the new behaviors “hard wired,” and thus more lasting. He further advocates for having a checklist of specific actions with “Plan B options” so the idea is not seen as a failure. It can be an emotional letdown for a practitioner to have a new idea go poorly; thus, small, manageable steps may be the ticket.
Accountability – “All teachers need to improve their practice – not because they are not good enough, but because they can get better,” is a strong-held belief from Wiliam. He believes that it is appropriate for teachers to be accountable for their personal improvement. He endorses the idea of a teacher having an action plan with indicators showing how the new idea benefits students. The plans do not have to be long and complicated but should be in writing, contain a small number of changes that will take place, and include what the teacher will reduce or give up in order to make room for the new ideas.
Support – In his work, Wiliam has concluded that a support system along with a model for providing the support is essential. In Embedding Formative Assessment: A Two Year Professional Development Pack, he prescribes monthly meetings with peers in order to make the move from knowing to doing more permanent. He calls the gatherings Teacher Learning Communities (TLC); He has determined that when teachers have a consistent protocol, when they make a commitment to peers, when they receive support and feedback from other practitioners, when there is time set aside to introduce new ideas, and when each individual specifically states what she will do before the next meeting, it becomes a powerful mechanism for change. As Wiliam states, the model is “currently being used successfully by thousands of teachers in hundreds of schools all over the world.”
The
Insights
Other writers have weighed in on the knowing-doing gap and offer
advice that supports Wiliam’s thinking as well as providing
additional helpful observations. In their book, The
Knowing-Doing Gap: How Smart Companies Turn Knowledge Into
Action, authors Jeffrey Pfeffer and Robert Sutton
explain that some people are “drowning in a sea of good intentions”
because they spend an inordinate amount of time talking about an
idea (“word spinning”) instead of making any progress. They state
that “the gap between knowing and doing is more important than
between ignorance and knowing.” According to the authors, some
people delude themselves into thinking they are making progress
simply because they keep talking about the idea. In order to move a
plan into the action stage, they caution that a plan may get
derailed early on if there are too many details in the beginning.
They further endorse the practice of celebrating “moments of
excitement” as a plan unfolds. It is likewise important to not
spend time focusing on snags that may occur and to focus on what
worked instead.
Binghamton University (SUNY) Professor Surinder Kahai has added additional insights in his book, Closing the Knowing-Doing Gap in Leadership.” He writes about if and when the initial enthusiasm about a new idea wanes, we resort to old behaviors. He writes, “This relapse is often caused by time pressure, peer pressure, anxiety over one’s capabilities, and sometimes by joyful circumstances (e.g., feelings that things are going well already when, in reality, they are not as good as one might think. Kahai supports the idea of goal setting with specific steps:
Creating a list of desirable behaviors
Setting targets for achieving the behaviors
Monitoring progress as the behavior change
Making sure the behaviors are specific enough and not overly general
He also shares a rather unique idea when he suggests setting up an email alert system as reminders of when important goals should be achieved. He recommends the use of Google calendar for weekly or twice weekly reminders.
The literature on the knowing-doing gap reveals further food for thought including the following options:
When teachers’ work becomes more difficult, they often resort to “primal scripts” based on the way they were taught as students. These were not necessarily the best teaching and learning practices.
Making a commitment to action planning focuses the teacher on devising concrete steps and keeping a written record about how the steps worked.
Studies found that feedback from peer to peer is most effective when the feedback did not stop at telling the fellow teacher what to do but more specifically how to go about it.
As teachers roll out new learning approaches, an important point is that to maximize student learning the focus needs to be on individual growth rather than on a comparison with fellow students.
When a teacher realizes that a successful new idea or approach is counter to existing school policy, the teacher should share formative achievement data with school leaders so that the existing structure can change.
We all know that change is difficult. But we cannot remain stagnant in our instructional practices. The above information contains numerous ways that teachers can make specific moves to ensure that the knowing-doing gap ceases to exist. The ball is in your court.
Answer the following DISCUSSION questions:
1) Why do organizations have this problem?
2) Do individuals share the same problem?
3) What have you learned from Covey's book or other materials thus
far in the course that can help BOTH individuals AND organizations
overcome this problem effectively?
In: Operations Management
Exercise 18-9 (Algo) New equity issues; offerings announcements [LO18-4]
When companies offer new equity security issues, they publicize
the offerings in the financial press and on Internet sites. Assume
the following were among the equity offerings reported in December
2021:
| New Securities Issues |
| Equity |
| American Materials Transfer Corporation (AMTC)—8.5 million
common shares, $0.001 par, priced at $13.952 each through
underwriters led by Second Tennessee Bank N.A. and Morgan, Dunavant
& Co., according to a syndicate official. |
| Proactive Solutions Inc. (PSI)—Offering of 9 million common
shares, $0.01 par, was priced at $14.80 a share via lead manager Stanley Brothers, Inc., according to a syndicate official. |
Required:
Prepare the appropriate journal entries to record the sale of both
issues to underwriters. Ignore share issue costs. (If no
entry is required for a transaction/event, select "No journal entry
required" in the first account field. Enter your answers in whole
dollars.
In: Accounting
JAVA LANGUAGE
ArrayList<Integer> al = new ArrayList<Integer>();
HashSet<Integer> hs = new HashSet<Integer>();
HashMap<Integer, Integer> hm = new HashMap<Integer,Integer>();
for (int i= 0; i<2; i++) {
al.add(i);
al.add(i+1);
hs.add(i);
hs.add(i+1);
hm.put(al.get(i), al.get(i+1));
hm.put(hm.get(i), hm.get(i+1));
}
System.out.println(al);
System.out.println(hs);
System.out.println(hm); // {key=value}.
----------------------------------
What output is produced by the following code and why?
In: Computer Science
I'm have trouble change JRadioButton and do not want to select all at the same time just one at a time. if one of them is unselected, then set the font as plain. Set font size as 20.
run the program and change the font and you see what I'm talking about
also this there anyway to shorten my code
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Font;
import java.awt.event.*;
import java.net.URL;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import javax.swing.JCheckBox;
import javax.swing.JColorChooser;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
//MyMenuFrame will use Jframe with actionlistener
public class MyMenuFrame extends JFrame implements
ActionListener{
//creating the main menu items
JMenu menuEdit = new JMenu("Edit");
JMenu menuPrint = new JMenu("Print");
JMenu mnFile = new JMenu("File");
JMenu menuHelp = new JMenu("Help");
//creating the submenu items here because we are gonna use these
across the code
JRadioButton subMenuItem1 = new JRadioButton("Times New
Roman");
JRadioButton subMenuItem2 = new JRadioButton("Arial");
JRadioButton subMenuItem3 = new JRadioButton("Serif");
JCheckBox subMenuItem4 = new JCheckBox("Bold");
JCheckBox subMenuItem5 = new JCheckBox("Italic");
//provide scrollable view of a component
JScrollPane scrollPane;
//creating notePadArea for notepad to input the text
JTextArea notePadArea;
public MyMenuFrame() {
//setting the border layout for JFrame
this.setLayout(new BorderLayout());
// create menu bar named menuBar
JMenuBar menuBar = new JMenuBar();
this.setJMenuBar(menuBar);//adding the menubar to JFrame
// create File menu
mnFile.setMnemonic(KeyEvent.VK_F);//Alt+F
menuBar.add(mnFile);//adding the menufile
// create Open menu item
JMenuItem mntmOpen = new JMenuItem("Open");//creating the Open menu
mntmOpen.setMnemonic(KeyEvent.VK_O);//Alt+O command
mntmOpen.setActionCommand("open");//when the command equals to 'open' then the corresponding action will be performed
mntmOpen.setAccelerator(KeyStroke.getKeyStroke('O', KeyEvent.CTRL_DOWN_MASK));//respond when user clicks Ctrl+O
mntmOpen.addActionListener(this);//adding actionLister to the Menu Option Open
// create Save menu item
JMenuItem mntmSave = new JMenuItem("Save");//creating the Save menu
mntmSave.setMnemonic(KeyEvent.VK_S);//Alt+S command
mntmSave.setActionCommand("save");//when the command equals to 'save' then the corresponding action will be performed
mntmSave.setAccelerator(KeyStroke.getKeyStroke('S', KeyEvent.CTRL_DOWN_MASK));//respond when user clicks Ctrl+S
mntmSave.addActionListener(this);//adding actionLister to the Menu Option Save
// create Exit menu item
JMenuItem mntmExit = new JMenuItem("Exit");//creating the Exit menu
mntmExit.setMnemonic(KeyEvent.VK_X);//Alt+X command
mntmExit.setActionCommand("exit");//when the command equals to 'exit' then the corresponding action will be performed
mntmExit.setAccelerator(KeyStroke.getKeyStroke('X', KeyEvent.CTRL_DOWN_MASK));//respond when user clicks Ctrl+X
mntmExit.addActionListener(this);//adding actionLister to the Menu Option Exit
// add open, save and exit menu to menu-bar
mnFile.add(mntmOpen);
mnFile.addSeparator();//adding separator between open and save
mnFile.add(mntmSave);
mnFile.addSeparator();//adding separator between save and exit
mnFile.add(mntmExit);
// create Edit menu
menuEdit.setMnemonic(KeyEvent.VK_E);//creating shortcut menu when user press Alt+E
menuBar.add(menuEdit);//adding the Edit to the menubar
JMenu submenu1 = new JMenu("Color");//creating the new menu
which comes under Edit
submenu1.setMnemonic(KeyEvent.VK_C);//creating shortcut menu when
user press Alt+C
JMenuItem menuItem0 = new JMenuItem("Change Color");//creating
submenu item called change color
menuItem0.setAccelerator(KeyStroke.getKeyStroke('C',
KeyEvent.CTRL_DOWN_MASK));//it responds when user click
Ctrl+C
menuItem0.setActionCommand("color");//setting the command used to
call the correcponding action when user click this
menuItem0.addActionListener(this);//adding actionlistener
submenu1.add(menuItem0);//adding this menu item to submenu
menuEdit.add(submenu1);//adding this submenu to editmenu
menuEdit.addSeparator();//creating separator between Color and
Font
JMenu submenu = new JMenu("Font");//creating the new menu which
comes under Edit
submenu.setMnemonic(KeyEvent.VK_F);//creating shortcut menu when
user press Alt+F
subMenuItem1.setMnemonic(KeyEvent.VK_T);//creating shortcut menu
when user press Alt+T for Times New Roman
subMenuItem1.setActionCommand("times_new_roman");//setting the
command used to call the correcponding action when user click
this
subMenuItem1.addActionListener(this);//adding actionlistener
submenu.add(subMenuItem1);//adding to the submenu
subMenuItem2.setMnemonic(KeyEvent.VK_A);//creating shortcut key
Alt+A
subMenuItem2.setActionCommand("arial");//respond when the command
equals to arial
subMenuItem2.addActionListener(this);//adding action listener
submenu.add(subMenuItem2);//adding it to the submenu
subMenuItem3.setMnemonic(KeyEvent.VK_S);
subMenuItem3.setActionCommand("serif");
subMenuItem3.addActionListener(this);
submenu.add(subMenuItem3);
submenu.addSeparator();
subMenuItem4.setMnemonic(KeyEvent.VK_B);
subMenuItem4.setActionCommand("bold");
subMenuItem4.addActionListener(this);
submenu.add(subMenuItem4);
subMenuItem5.setMnemonic(KeyEvent.VK_I);
subMenuItem5.setActionCommand("italic");
subMenuItem5.addActionListener(this);
submenu.add(subMenuItem5);
menuEdit.add(submenu);
// create Print menu
menuPrint.setMnemonic(KeyEvent.VK_P);
menuBar.add(menuPrint);
JMenuItem menuItemPrint = new JMenuItem("Send To Printer");
menuItemPrint.setAccelerator(KeyStroke.getKeyStroke('P', KeyEvent.CTRL_DOWN_MASK));
menuItemPrint.setActionCommand("print");
menuItemPrint.addActionListener(this);
menuPrint.add(menuItemPrint);
// create Help menu
menuHelp.setMnemonic(KeyEvent.VK_H);
menuBar.add(menuHelp);
JMenuItem menuItemHelp = new JMenuItem("About");
menuItemHelp.setAccelerator(KeyStroke.getKeyStroke('A', KeyEvent.CTRL_DOWN_MASK));
menuItemHelp.setActionCommand("about");
menuItemHelp.addActionListener(this);
JMenuItem menuItemVisitHomePage = new JMenuItem("Visit Home Page");
menuItemVisitHomePage.setAccelerator(KeyStroke.getKeyStroke('V', KeyEvent.CTRL_DOWN_MASK));
menuItemVisitHomePage.setActionCommand("visithomepage");
menuItemVisitHomePage.addActionListener(this);
menuHelp.add(menuItemHelp);
menuHelp.addSeparator();
menuHelp.add(menuItemVisitHomePage);
notePadArea = new JTextArea();
// set no word wrap
notePadArea.setWrapStyleWord(false);
// create scrollable pane
scrollPane = new JScrollPane(notePadArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS , JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
this.add(scrollPane,BorderLayout.CENTER);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("exit")) {
System.exit(0);
}else if (e.getActionCommand().equals("open")) {
JFileChooser file = new JFileChooser();
String fileName = "";//initial filename was empty
// show open file dialog
if (file.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
fileName = file.getSelectedFile().getAbsolutePath();
} else {
return;
}
try(BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName));) {
// load file content into text area
StringBuffer stringBuffer = new StringBuffer();//creating a string buffer for reading data from file
String lines = "";//for reading the lines from the selecting file
while((lines = bufferedReader.readLine() ) != null) {//it'll read untill the file ends
stringBuffer.append(lines).append("\n");//for every line read insert new line in stringBuffer
}
bufferedReader.close();//after reading of file done, the bufferedReader will be close
notePadArea.setText(stringBuffer.toString());//converting the read text to string and inserting this text into textArea
} catch (Exception error1) {//if any exception occures
System.out.println(error1.toString());//convert the expection into string and print it
}
} else if (e.getActionCommand().equals("save")) {//if the user click the save command then the file will gonna saved
JFileChooser file = new JFileChooser();//creating the file
chooser
String fileName = "";//initial file name is empty
// show open file dialog
if (file.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {//if the user select file and clicks OK button
fileName = file.getSelectedFile().getAbsolutePath();
} else {//other wise will be closed
return;
}
try(BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(fileName));) {
// write editor's content to selected file.
bufferedWriter.write(notePadArea.getText());//get the text
entered in textarea
bufferedWriter.flush();//clear the writer
} catch(Exception ex1) {}
} else if (e.getActionCommand().equals("color")) {
Color select_color = JColorChooser.showDialog(this, "Select a
color", Color.RED);
notePadArea.setForeground(select_color);
} else if (e.getActionCommand().equals("times_new_roman"))
{
if(subMenuItem1.isSelected())
notePadArea.setFont(new Font("Times New Roman", Font.PLAIN,
20));
} else if (e.getActionCommand().equals("arial")) {
if(subMenuItem2.isSelected())
notePadArea.setFont(new Font("Arial", Font.PLAIN, 20));
} else if (e.getActionCommand().equals("serif")) {
if(subMenuItem3.isSelected())
notePadArea.setFont(new Font("Serif", Font.PLAIN, 20));
} else if (e.getActionCommand().equals("bold")) {
if(subMenuItem4.isSelected()){
if(subMenuItem5.isSelected()){
notePadArea.setFont(new Font("Serif", Font.BOLD+Font.ITALIC,
12));
}else{
notePadArea.setFont(new Font("Serif", Font.BOLD, 12));
}
}else{
if(!subMenuItem5.isSelected())
notePadArea.setFont(new Font("Serif", Font.PLAIN, 12));
}
} else if (e.getActionCommand().equals("italic")) {
if(subMenuItem5.isSelected()){
if(subMenuItem4.isSelected()){
notePadArea.setFont(new Font("Serif", Font.BOLD+Font.ITALIC,
12));
}else{
notePadArea.setFont(new Font("Serif", Font.ITALIC, 12));
}
}else{
if(!subMenuItem4.isSelected())
notePadArea.setFont(new Font("Serif", Font.PLAIN, 12));
}
} else if (e.getActionCommand().equals("print")) {
int output = JOptionPane.showConfirmDialog(this, "Do you want to
print the File","Confirmation", JOptionPane.YES_NO_OPTION);
if(output==0){
JOptionPane.showMessageDialog(this, "The file is successfully
printed","Confirmation", JOptionPane.INFORMATION_MESSAGE);
}
} else if (e.getActionCommand().equals("changecolor")){
System.out.println("Color clicked");
}
else if (e.getActionCommand().equals("about")) {
JOptionPane.showMessageDialog(this, "This software is developed in 2019\nVersion is 1.0","About", JOptionPane.INFORMATION_MESSAGE);
} else if (e.getActionCommand().equals("visithomepage")) {
openWebpage("http://www.microsoft.com");
}
}
private void openWebpage (String urlString) {
try {
Desktop.getDesktop().browse(new URL(urlString).toURI());
}
catch (Exception e) {
e.printStackTrace();
}
}
}
import javax.swing.JFrame;
public class MyMenuFrameTest {
public static void main(String[] args) {
MyMenuFrame frame = new MyMenuFrame();
frame.setTitle("MyNotepad");
//for the title of the box
frame.setSize(600, 400);
//for the size of the box
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
In: Computer Science