java - ActionListener Event Handling -


There is a code for a checkbox that agrees with the terms of service and accepts and rejects the button.

I need help to deal with the exception that

If the user has not been selected as a checkbox, then when he accepts the user, An error message occurs, which is not selected by the checkbox

How would I like to handle the error using these 2 arguments?

  import javax.swing. *; Import javax.swing.JOptionPane; Import java.awt. *; Import java.awt.event. *; Import java.lang.Math. *; Import java.lang.Integer *; Import java.lang.Object. *; Import java.util. *; Import java.util.Random; Import java.io * *; Import java.text *; Import java.text.DecimalFormat. *; Public Class JFrameWithPanel JFrame applies ActionListener, ItemListener {int packageIndex; Double price; Double [] prices = {49.9 9, 39.99, 34.99, 99.99}; Decimalfilm currency = new profit ("$ 0.00"); Zellabell Price Labels = New JLabel ("Total Value:" + Value); Pocket button = new pocket ("check price"); JComboBox Package Choice = new JComboBox (); Font newfont = new font ("hellevica", font .ba, 14); Zipel panel = new zpn (); Textfield text = new textfield (5); Pebble accepts new newton ("accept"); Jebton fall = new pocket ("reject"); JCheckBox serviceTerms = new JCheckBox ("I agree to the terms of service.", False); JTextArea termsOfService = New JTextArea ("This is a text field", 5, 10); Public JFrameWithPanel () {Super ("Jeffram with Panel"); SetDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); Pane.add (packageChoice); SetContentPane (panel); SetSize (250,250); SetVisible (true); PackageChoice.addItem ("A + Certification"); PackageChoice.addItem ("Network + Certification"); PackageChoice.addItem ("Security + Certification"); PackageChoice.addItem ("CIT full test package"); Pane.add (button); Button.addActionListener (this); Pane.add (text); Text.setEditable (wrong); Text.setBackground (Color.WHITE); Text.addActionListener (this); Pane.add (termsOfService); TermsOfService.setEditable (False); TermsOfService.setBackground (Color.lightGray); Pane.add (serviceTerms); ServiceTerms.addItemListener (this); Pane.add (accept); Accept.addActionListener (this); Pane.add (fall); Decline.addActionListener (this); } Public Zero Functionality (Action EVE) {packageIndex = packageChoice.getSelectedIndex (); Price = value [package index]; Text.setText ("$" + value); Object source = e.getSource (); If (source == accept) {JOptionPane.showMessageDialog ("Thank you for choosing our tests, please!"); } And if (source == decline) {System.exit (0); }} Public Zero ItemState Change (item event e) {int select = e.getStateChange (); If (Select == ItemEvent.DESELECTED) {JOptionPane.showMessageDialog (blank, "Please agree to the terms of service."); } Other {}}}  

can it be true?

  if (service! Tarmesis selected) Show Messagidoug (empty, "you have not accepted the conditions.");  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -