Design and implement an application that has 5 text boxes, a button (make its text SORT)...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Design and implement an application that has 5 text boxes, a button (make its text SORT) and a label. (example: copy the PushCounterPanel.java code and call it 'Push CounterPanelSorter.java') The user can enter 5 different numbers using the 5 text boxes. When the user clicks the SORT button, sort the 5 numbers using any of the sorting algorithms we learned in class and display the numbers separated by comma using the label for showing the output: -a sorted list. 34 23 1 57 18 Sort 1, 18, 23, 34, 57 import javax.swing.JFrame; public class PushCounter { // // Creates and displays the main program frame. // public static void main(String[] args) { } JFrame frame = new JFrame("Push Counter"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); PushCounterPanel panel = new PushCounterPanel (); frame.getContentPane().add(panel); frame pack (); frame.setVisible (true); } //end of PushCounter.java import java.awt.*; import java.awt.event.*; import javax.swing.*; public class PushCounterPanel extends JPanel { private int count; private JButton push; private JLabel label; // // Constructor: Sets up the GUI. //- public PushCounterPanel () { count = 0; push = new JButton("Push Me!"); label = new JLabel (); push.addActionListener(new ButtonListener()); add (push); add (label); setBackground (Color.cyan); setPreferredSize (new Dimension (300, 40)); } //- // Represents a listener for button push (action) events. //--- private class ButtonListener implements ActionListener { public void actionPerformed (ActionEvent event) { count++; " label.setText("Pushes: + count); } } } //end of PushCounterPanel.java Design and implement an application that has 5 text boxes, a button (make its text SORT) and a label. (example: copy the PushCounterPanel.java code and call it 'Push CounterPanelSorter.java') The user can enter 5 different numbers using the 5 text boxes. When the user clicks the SORT button, sort the 5 numbers using any of the sorting algorithms we learned in class and display the numbers separated by comma using the label for showing the output: -a sorted list. 34 23 1 57 18 Sort 1, 18, 23, 34, 57 import javax.swing.JFrame; public class PushCounter { // // Creates and displays the main program frame. // public static void main(String[] args) { } JFrame frame = new JFrame("Push Counter"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); PushCounterPanel panel = new PushCounterPanel (); frame.getContentPane().add(panel); frame pack (); frame.setVisible (true); } //end of PushCounter.java import java.awt.*; import java.awt.event.*; import javax.swing.*; public class PushCounterPanel extends JPanel { private int count; private JButton push; private JLabel label; // // Constructor: Sets up the GUI. //- public PushCounterPanel () { count = 0; push = new JButton("Push Me!"); label = new JLabel (); push.addActionListener(new ButtonListener()); add (push); add (label); setBackground (Color.cyan); setPreferredSize (new Dimension (300, 40)); } //- // Represents a listener for button push (action) events. //--- private class ButtonListener implements ActionListener { public void actionPerformed (ActionEvent event) { count++; " label.setText("Pushes: + count); } } } //end of PushCounterPanel.java
Expert Answer:
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
Developments in Technology Light is incident from air on the end face of a multimode optical fibre at angle of incidence as shown below. n n 1 2 The refractive indices of the core and cladding are...
-
Upon graduation from high school, John Abel immediately accepted a job as an electrician's assistant for a large local electrical repair company. After three years of hard work, John received an...
-
For a particular reaction, H = -32 kJ and H = - 98 kJ. Assume that and do not vary with temperature. (a) At what temperature will the reaction have G = 0? (b) If T is increased from that in part (a),...
-
56. If the maximum concentration of PbCl2 in water is 0.01M at 298 K. Its maximum concentration in 0.1M NaCl will be : (1) 4 103 M x (3) 4 102 M (2) 0.4 10M x (4) 410 M
-
Show that the following eight vectors are pairwise orthogonal: \[\begin{aligned}& s 1=(1,1,0,0,0,0,0,0)^{T} \\& s 2=(0,0,1,1,0,0,0,0)^{T} \\& s 3=(0,0,0,0,1,1,0,0)^{T} \\& s 4=(0,0,,0,0,0,1,1)^{T}...
-
Why did Toyota wait so long to publically acknowledge and replace the faulty accelerator pedals? Toyota is an extremely successful automaker that has built a reputation for quality by fostering a...
-
On January 1 of Year 1, Alpha Corporation issued $400,000 of 8% (cash payable semiannually on June 30 and December 31), three-year bonds to yield 10%. Required a. Compute the selling price of the...
-
The following list of accounts is taken from the records of Western Sales Ltd. at December 31, 2023: Account Accounts payable Accounts receivable Accumulated depreciation, PPE Admin. salaries and...
-
What is the definition of a culture?
-
What is the role of the pizza aquarium concept in Al Capizzas business model? In your opinion, how will millennials perceive this?
-
Provide a road map of how Al Capizza could compete globally.
-
What is the relationship between culture and entrepreneurship, and is it relevant?
-
Examine the impact of COVID-19 on globalization.
-
The manager of a grocery store has taken a random sample of 100 customers. The average length of time it took the customers in the sample to check out was 3.1 minutes with a standard deviation of 0.5...
-
Convert the numeral to a HinduArabic numeral. A94 12
-
Classify these Bluetooth layers using the OSI model: a. baseband; b. L2CAP; c. RFCOMM.
-
Use the power state machine of Fig. 8.12 to determine the energy used in these use cases: a. idle 1 s; receive 10 ms; idle 0.1 s; transmit 5 s; b. sleep 1 min; receive 50 ms; idle 0.1 s; receive 100...
-
What are the main phases of a design review?
Study smarter with the SolutionInn App