java - How to use ActionListener when the button function is in another class -


I have three different classes: main, window-frame dynamics and validation of number-of-man-call window -frame dementines This main square window -frame demat Is - call (well I'm trying to call) Validation number is a class that creates a frame, pane, label for the box, and button for the program. Validation off number - it is all that calculates for number recognition. Originally this class confirms that the numbers used are within the limit of 1..100,000. Goal: The goal is to connect WindowFrameDimetnions with the verification using the ActionListener.

  Package BlueBlueMainFiles; Import javax.swing.JButton; Import javax.swing.JFrame; Import javax.swing.JLabel; Import javax.swing.JPanel; Import javax.swing.JTextField; Public square WindowFrameDimentations JFrame (final static int WINDOW_WITH = 950; // pixel in the window final static bit WINDOW_HEIGH = 650; // Fixed height of the window in pixel; JPanel panel; // Panel to refresh the JLabel message label; // Use labels to static JTextField textField; // static JButton to use calcButton; // referencing the reference button to use public windowFrameDimentions () {// TODO automatically generated creator stub} public A fixed zeros window FraameDimentions () {// Create a new window Jeffreem window = Add a name to the new GeFram (); // window window.setTitle ("BLUE BLUE"); // Set the size of the window window .Set size WINDOW_WITH, WINDOW_HEIGH); // Specify what happens when the close button window is pressed.Create the SetDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); // panel and add it to the frame construction panel (); // Frame Content Add panel to pan window.add (panel); // window window pane Set .SetVijay (true); } Public Static Zero BuildPanel () {// Create a label for displaying message message = New JLabel ("Enter Number from 1.0000"); // Create a text field of 10 characters textField = new JTextField (10); // Create panel calcButton = new JButton ("calculation"); // Listen to an action button. Currently, I can not work it // Create a JPNL object and referencing the panel field to the panel = New JPNL (); Panel.add (messageLabel); Panel.add (field); Panel.add (calcButton); }}  

Now this is the second code:

  package TheValidationFiles; Public class validation number of {constant integer MAX_NUMBER_TO_VAL = 10000000; Public static zero GetValidationOfNumbers (boolean isTrue, string s) {string [] numberAre = new string [MAX_NUMBER_TO_VAL]; Boolean number matching = false; (For int i = 0; i & lt; MAX_NUMBER_TO_VAL; i ++) (numbers aerate [i] = integer.Testring (i); if (numbers are [i]. Axles (s) {System.out.println ( "The number you typed matches the array value of" + s + ":" + number is [i]); System.exit (0); breakdown;} and {numberMatching = true;}} if (number matches } {Validationfile ValidationFolder (s);}}}}  

If you have an unknown object action You can try to create:

  panel.ed (new pocket (new AI Assessment action ("name of the button") {public zero verb implemented (action dot e) {// dot dot here}}));  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -