Reputation: 43
I need to display result of computation that I used to compile in standard java programming (in Main clas) in java swing GUI test area in netbeans, but I always encountering problem on it. I bet the problem is because my String to be printed is not available in the GUI class, here's my part of code in swing
private void predictActionPerformed(java.awt.event.ActionEvent evt) {
TextArea1.setText(Engine.Print.printresult(toarray));
//JOptionPane.showMessageDialog(null,Engine.Print.printresult(toarray));
// TextArea1.setText(Retrieving.main(args));
}
and here's the code in package Engine, Class Print, method printresult, String[]printresult is passed from another class and it works to run directly without GUI:
public static void printresult(String[]toarray){
for(int a=0; a<toarray.length;a++){
System.out.println(toarray[a]);
}
really need help. thank you
Upvotes: 1
Views: 6675
Reputation: 285430
You state:
Actualy I need to display the value of my calculation of my console in swing Text area since this program need to be visualized using GUI, i think it is impossible to just copy all my code into GUI since it contains several class instead, so I only need to send the result into GUI swing textarea but I have no idea what to do. Can anyone tell me how to do that since this way is not working.
What you need to do first and foremost is re-write your calculation code. You don't show us any of this code, which makes it impossible to guess what it's doing or what it's doing wrong, but I suspect that it does calculations and prints them out to the console, which won't work for a GUI.
What I recommend that you do for your non-GUI calculation code:
What I recommend that you do for your GUI dislay code:
These suggestions are very generic and as such may not be as helpful to you as you or I would like, but this is of necessity given the limited information that we know about your problem. For more specific help, then please give us more specific and detailed information about your problem and your code.
Upvotes: 0