Win a copy of Head First Android this week in the Android forum!

Ryan Giomi

Greenhorn
+ Follow
since Jan 24, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ryan Giomi

Davy,

If I understand you correctly, then here is how I do it:

(Code below... didnt bother with the code script as this is a subsection)
#######################################################################
import java.awt.Dimension; //need this for dimension

Dimension d = new Dimension(10,24);

JTextArea t3WorkoutTextArea = new JTextArea(10,24);

t3WorkoutJP.add(t3WorkoutTextArea);//add the text area to your jpanel
t3WorkoutTextArea.setPreferredSize(d); //ThIS WHAT YOU WERE ASKING ABOUT. It
//locks your columns and rows.

#######################################################################
Hope that helps.
[ May 01, 2007: Message edited by: Ryan Giomi ]
14 years ago
Hey, John. I won't be able to think on this for a few days. As soon as I have a chance, I'll consider what you wrote, and see if I can come up with a solution. Hopefully somebody will figure it out before then.

***edit: It's been a little over a month... I did not figure it out since then, but honestly I've been preoccupied with other issue. Have you had any luck?
[ March 14, 2007: Message edited by: Ryan Giomi ]
14 years ago
John,

I took some old code that I wrote and trimmed it down to show you how I did something similar to what you are asking about. In my example I used your class names Editor and Engine. The main method is nested in class Editor. So scope on my code and tell me what you think:

Here is your Editor:



Here is your Engine code:


If anybody sees useless code that pertains directly to how to accomplish John's question please feel free to help me trim that fat. No need to point out stuff like "int x = 0". It's obvious that that isn't used. Please point out things that are needed, but can be reduced (ie general code format, etc).

Thanks.

John, let me know if this properly addresses your original question.
14 years ago
John,

This is how I did it:
-Built my GUI in one class file
-Built my engine (run all calcs pertinent to GUI selections) in its own class file
-Main Method in its own class file(just how I did it. Not needed obviously)

My engine class extends the GUI class.

In a method inside of my engine class the code that reads the combo box looks like this:


First thing, I only included the relevant code that you are asking about, except the bit with "Age". That was just to show you some transition.

textaReadOut.setText --> textaReadout = text area readout (just explaining my verbage ). This is the JTextArea for displaying your info. Apply the .setText to tell your program to print in that specific JTextArea (.setText is like System.out.println... but for GUIs).

comboSex.getSelectedItem() prints whatever was selected in the JComboBox that I called comboSex (fyi, comboSex is a selection between "male" and "female").

I hope that helps.
14 years ago
Okay, just going to take a stab at this (I'm relatively new also).

Try this:


Also, is the above method intended to be included in the Menu() class?(Just checking as there is one brace missing at the end if it is indeed supposed to be included.)

BTW, I entered your code into my editor, and added the aforementioned brace; and I did indeed get a graphical frame (which I know you did as well). So if my suggestion is incorrect and you want to share the OrdersUI file I would be happy to look further into this from my end (provided you did not find a resolution elsewhere).
[ January 27, 2007: Message edited by: Ryan Giomi ]
14 years ago
Manoj,

Here is one suggestion:
  • Google Eclipse
  • Download Eclipse
  • See Nathan's advice on how to make a .Jar file in Eclipse here (his is the second post in the thread): https://coderanch.com/t/344177/GUI/java/PNG-background-will-not-export

  • Make sure you know where you are saving the file to.
  • Locate file and double click


  • Note, if you DO NOT have any graphics in your .Jar you might not see any effects from double clicking your .Jar. So, let's say you make a text role playing game and .jar it up (JARing is like making a .EXE). If you did not add any graphics then nothing will happen when you double click your .jar.
    14 years ago
    Nathan,

    While I was typing out my reply to you I had a thought that perhaps it's not working because I did not capitalize in my code the .png. So I capitalized it, compiled it, and exported it (3 its)... and it worked. I could have sworn I came across that problem awhile ago with another program... I was cranking me brain to figure out what went wrong.

    Anyway, thank you very much for your response. You helped me knock one part of the trouble-shooting process out. I am very grateful.

    ***********
    ***********
    So here is the old code that created the confusion:


    Here is the updated code:

    The only difference is that I had to capitalize the .PNG. It came to me while looking at my background pic file. I wondered if the capitalization difference might be causing a little quirk... sure enough it was.

    Once again, Nathan, Thanks!

    [ January 25, 2007: Message edited by: Ryan Giomi ]
    [ January 25, 2007: Message edited by: Ryan Giomi ]
    14 years ago
    Hi,

    The title says it all. I have written a calculator that runs fine in eclipse, in fact here is a screen showing what it looks like:


    The problem is that when I export the code to a .jar the .jar will not run. It acts like a non gui export (ie you write console code, export it, and it will not run no matter how many times you dbl click it.)

    Here is my code. Granted, this is not all of it, but this code WILL get the gui up and running, allow you to make selections in the comboboxes, etc. You just need to make a Main.


    The code in bold, hopefully red too (I tried to make it red, wasnt sure of allowable formats) seems to cause the trouble. If I get rid of it, then it will export (without using the .png background) and will run fine as a .jar. Can anybody pt out why my graphical bground is not being included?

    Thanks,

    Ryan

    [ January 24, 2007: Message edited by: Ryan Giomi ]

    [ January 24, 2007: Message edited by: Ryan Giomi ]

    [ January 24, 2007: Message edited by: Ryan Giomi ]

    [ January 25, 2007: Message edited by: Ryan Giomi ]
    [ January 25, 2007: Message edited by: Ryan Giomi ]
    14 years ago
    Is it absolutely required that your code be exactly similar to the way you have it written?
    Also, is this for an applet or not?
    14 years ago