![]() |
|
#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:
|