![]() |
|
#1
|
|||
|
|||
Trouble integrating console code into GUIWell my problem is I coded a game and got everything working nicely so I decided I wanted to make a GUI in JFrameBuilder and transfer my code into that. Well I havnt been to sleep and 24 hours later I still cant get the code to work. I made a start button and thought I could just execute all the code from there but that doesnt work and i've run out of ideas how to get it working. I want it to pause and wait for user input where needed etc...
First i'll post my main GUI code then i'll post my working game code main im trying to integrate. I'd be eternally grateful if anyone has any ideas. JAVA Code:
Heres the code im unsucessfully trying to put in there Any help would be greatly appreciated JAVA Code:
|
|
#2
|
||||
|
||||
Re: Trouble integrating console code into GUIPause and wait,for input? Unless I'm missing something, isn't that ultimately what the buttons will do? [well, the GUI 'waits', so to speak, until events are 'fired' is what I mean]
Anyway, what is the nature of these? (as they're not included in the post) JAVA Code:
EDIT: I was able to get the GUI to appear, and can see the button's action messages, but all the board and 'bd' related statements had to be commented-out. Moving to a GUI, there is really no need for the input of 21, 23, etc. -- because the buttons that you have created will/can now perform those actions (or movements), without the textbox -- unless the textbox is just for dual feature (input and/or button clicks), or some other need?? __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#3
|
|||
|
|||
Re: Trouble integrating console code into GUIOk cool, i'll post the whole code to the non GUI example at the end of this post. Yes thats my problem im very new to using GUI's and im not too sure how to let the GUI run my code im to use to linear style coding. I have an idea, but minimum experience. Like I know everything runs off click or input events, but I just can't remember how to get it working how I want. And yes your right I dont need input for 12, 32 etc, the buttons handle that, but I wasnt upto that stage so I was still fumbling around trying to get anything to work at all.
Oh and ive taken out the EasyIn packagae now too, I realised I didnt need it anymore, it just helped with Input and output but I changed my code to using JOptionPane. Heres my working non GUI example, I hope this helps, sorry for my previous lack of information.. MAIN CLASS JAVA Code:
BOARD CLASS JAVA Code:
PEG CLASS JAVA Code:
UNDERFLOW EXCEPTION CLASS JAVA Code:
LLIST CLASS JAVA Code:
LLNODE CLASS JAVA Code:
EMPTYLIST EXCEPTION CLASS JAVA Code:
|
|
#4
|
||||
|
||||
Re: Trouble integrating console code into GUITwo UnderflowException classes?
Do you still want to work from the direction started in the first post, as the starting point? (the one with the 'visualassignment2' package) EDIT: Oh, and is there a restriction, with the assignment, that the Java API's Stack, and LinkedList classes could not be used? No big deal, just curious; otherwise it'll have to be what's already done. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#5
|
|||
|
|||
Re: Trouble integrating console code into GUIUmm yep, one underflow exception is for my board package and the empty list exception is for in my linkage package. Sorry im still a bit new fi there is a better way to do that.
Well the only reason I added a start button in there was because I couldnt think of how to get my game code working on the gui. So im just into getting it running any way I can. It would be cool if the thing just started with a welcome message on the texarea screen asking if theyd like a new game [Y/N] like in my non gui version. But I just didnt know how to do it. The GUI turned out to be a bigger monster for me than I first expeced. I thought I could do it no worries, but it owned me lol. And nope no restriction on assignment. I just coded those classes myself from examples my lecturer gave us. He said I was supposed to try using circular linked lists in my board class for full marks, but ive got no idea what he means there. Im one of the very few in the class who actually managed to get linked lists working in my peg class, most of the class is just using stacks and pop and push. |
|
#6
|
||||
|
||||
Re: Trouble integrating console code into GUIThis is still incomplete, but thought I'd pass along what is done so far. Compile and run it, but note that there may be issues, but some output shows in the console window, not the GUI window, just yet.
JAVA Code:
Oh, I did disable the 'start game' button and the input textbox in the GUI, but all the Peg buttons are there -- but a small task for you, those need widening to show all the text (or reduce the text already there) to fit. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#7
|
|||
|
|||
Re: Trouble integrating console code into GUIWow youve done such a great job!! Thankyou so much. You've really pointed me in the right direction. I can see exactly what you've done and im going to spend the rest of the day(and night) working on the improvments you have made so hopefully by the time you come back to look at this tommorow i'll have a completed GUI working.
Im pretty much complete now and it would have taken me another three days to finish coding it by trial and error. Thankyou so much!! I'll post my finished code here maybe tomorrow so you can see how I put your handy work to use |
|
#8
|
|||
|
|||
Re: Trouble integrating console code into GUIThanks once again. Ive pretty much been able to complete the whole GUI thanks to your helping hand. I was just wondering if you were able to help me out with a couple of last problems im having.
Firstly im having trouble printing out my board in the JTextPane, but even after I get the board printing out in there I want the board to print vertically not horizontally. Even if you knew how to just do that on the console would be a huge help. Im also having problems implementing my progress bar to work in auto mode if you know anything about those. Ive played around with it but just cant get it going. It looks like its initialised, but I just cant get it to increment. I was trying to make it go from 0 to optimum by getting the optimum number and increment the bar every move based on how far its got to go. Lastly im having trouble with the reset button to play another game, ive made up a method called withdraw() on my main class and it basically is just popping numbers out of the linked list to clear the board but its not quite working properly. I'll print my main i've been working on all day and the function I wrote in the board class. package visualassignment2; JAVA Code:
Heres what I wrote in board class for the reset click event JAVA Code:
Hey thanks again in advance if you actually get time to take a look at this again for me. My codes bit more messy now too, cause I got tired of making it tidy as I go, im just going to go through it tommorow and straighten it up again lol. |
|
#9
|
||||
|
||||
Re: Trouble integrating console code into GUISure I can look at those later today.
Also, this is killing me a bit with the buttons, specifically: JAVA Code:
Earlier I said: Quote:
So, I can cover how the button creation and handling works together if there is/was some apprehension about breaking something. (I didn't get a chance to add all the commentary that I wanted before stopping last night, but comments will be included in the next run of change(s)) __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#10
|
|||
|
|||
Re: Trouble integrating console code into GUIAhh b7 and b8, the reason I didnt add them to the array was because I was having trouble with button P 3to2, its not working, so instead of trying to add b7 and b8, I was just going to take a look at it when I had time, but ended up spending all day working on other problems.
I've got class now and it is due tommorow so i'll add them to the button array when I get to class easy enough. Now im pretty sure I just need to get my print functions returning strings to make them setText in my GUI, I was playing around with toString last night but was having a few problems. Once I can get them returning string values I was hoping to be able put them into an array something like this to get it printing out vertically......... JAVA Code:
And output it something like..... JAVA Code:
Sorry i've got so many questions but we havnt even been taught java, i've had to teach myself in the last 4 weeks. I learnt C# last year so im familiar with what I need to do, its just hard sometimes to find the right syntax. This is a class in data structures and algorithms, my stupid university thinks it good to teach you one language, then try to teach to more advanced stuff in a language your not familiar with. Maybe its character building lol. Thanks again if you get a chance to take a look for me, much appreciated mate ![]() |
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need code to hide a console program from startup | lockd | C++ Forum | 1 | 14-Aug-2007 18:03 |
| How to sort random access file? | wmmccoy0910 | C Programming Language | 12 | 04-Sep-2006 03:40 |
| Here it is again! 35% - 40% off For Life! | my-e-space | Web Hosting Advertisements & Offers | 0 | 20-Apr-2006 14:48 |
| Guidelines for posting requests for help - UPDATED! | WaltP | C Programming Language | 0 | 21-Apr-2005 02:44 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The