java - Best way to identify which button was pressed for method logic -
I have a method that is used for two different tasks, actions are identified, which button Suppresses
I am using a boolean to identify button press.
PDFButton.addSelectionListener (new selectionEditor () {Public Zero widget selected (SelectionEvent e) {buildArray (true);}}); Plot button Ad selector (new selectionEditor) (Public Zero widget selected (selection event e) {build array (wrong);}}); Public Zero Builder (Boolean Button ID) {Get Index etc ... if (true) {PDF.getInstance.buildArray (index); } Else {Plot.getInstance.buildArray (index); }} Is this the best way to do this?
Edit tip button snippet pasted, there are no 2 buttons in it. I'm trying to do IF logic has a condition set, so I know what button The buildArray method was pushed to activate. Public Zero Builder () {Get Index, Mode Code. .... if ** (button press is equal to pdf button) ** {PDF.getInstance.buildArray (index); } Else {Plot.getInstance.buildArray (index); }} I know that in a way similar to buildArray will be to create a different method. Then each button will execute its own method.
PDFButton.addSelectionListener (new selectionEducation () {Public Zero widget selected (SelectionEvent e) {PDFbuildArray (true);}}); Plot button Add Chunalier (new selection adapter) (Public Zero Widget Selected (Selection Event E) {PlotBuild Array (False);}}); But I want to strengthen as Mush Code as possible.
I have finished using action events getSource (). GetText () then the method ended up looking like this.
Obtain the public zeroTelectEvent e {int [] row = viewer.getTable (). GetSelectionIndices (); Arrays.sort (line); If (row.length & gt; 0) {for (int i = row.length-1; i> = 0; i -) {if ((button) e.getSource ()). GetText () == "Plotting") AplotPlotDataModel.getInstance (). BuildPlotArray (line [i]); Else {AplotPDFDataModel.getInstance (). BuildArray (line [i]); }}}}
Comments
Post a Comment