GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #11  
Old 14-May-2008, 16:19
TurboPT's Avatar
TurboPT TurboPT is online now
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Trouble integrating console code into GUI


No problem.

Oh, the '3 to 2' button quit working because this was modified and left behind:
JAVA Code:
    gameButtons[5].setEnabled(false);  // disabled the button.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #12  
Old 14-May-2008, 20:53
Barman007 Barman007 is offline
New Member
 
Join Date: May 2008
Posts: 10
Barman007 is on a distinguished road

Re: Trouble integrating console code into GUI


roger that, and hey whatd'ya know, that buttons magically come back lol.

Thanks
  #13  
Old 14-May-2008, 21:01
TurboPT's Avatar
TurboPT TurboPT is online now
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Trouble integrating console code into GUI


Quote:
Originally Posted by Barman007
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.
[secondly]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
The third item ( the reset ) seems to be working. There were a few things needed.
I modified withdraw() to this: (requires a change in the peg class)
JAVA Code:
	public void withdraw(){
        try{
           	peg1.removeAll();
            peg2.removeAll();
            peg3.removeAll();
        }catch (Exception e){
		 	System.out.println("Error clearing pegs!: " + e);
        }
    }
...and to support that change, this function was added to the peg class:
JAVA Code:
public void removeAll() throws Exception
{
	while ( countPeg > 0 )
	{
		pop();
	}
}
... AND there are a few changes in the Main class, but I'll post that in a few moment(s), possibly in another post.

Will scrolling text be expected in the text window? Is this also where the vertical output is expected? (along with the other messages?)
Also there doesn't appear to be a label3 on the GUI?

Other than that, still looking at the first two items, and have an idea for the vertical print, but not sure where you are expecting it to be shown?

EDIT:
Oh, does the image you have fill that entire top area?
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #14  
Old 14-May-2008, 21:28
Barman007 Barman007 is offline
New Member
 
Join Date: May 2008
Posts: 10
Barman007 is on a distinguished road

Re: Trouble integrating console code into GUI


Nice work on the reset button, works like a charm.

Yes board and all messages on text pane, except for the number of discs choice and manual or auto mode, I like how you did that. Saves having an input on the gui.No scrolling isnt needed on the textpane. I was thining everytime there is a message it just re-displays it. And everytime there was a board change it just replaces what was on there. I dont mind either way though, which ever is easiest scrolling or not. Im sitting here working on it and ive been racking my brain for the last two days how to get the board displaying on the JTextPane but im failing everytime. So if you can get it doing that i'd be well impressed.
  #15  
Old 14-May-2008, 21:40
TurboPT's Avatar
TurboPT TurboPT is online now
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Trouble integrating console code into GUI


Still a work-in-progress, but here's the main class again...

The changes from your last post (when you posted this class) include:
1. buttons 7 & 8 have been added to the array
(see the 'titles' string, and function actionPerformed(), and #5, below )
2. Function reset() modifed
(removed loop -- change to withdraw() makes it unnecessary)
3. Added new function: newGame()
(called by the constructor, AND reset() )
4. Removed the statement that disabled the button.
5. Added commentary for the button array areas:
(see the 'titles' array, the 'button loop' [just after where the progress bar is colored], function actionPerformed(), and the section where the components are added to the content pane. )
JAVA Code:
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.text.*;
 import javax.swing.*;
 import boardage.*;
 import java.io.*;
 import java.lang.Object.*;
 import java.util.StringTokenizer;


  class Error extends Exception {
    public Error() {
        super("*******ERROR*******\n");
        }
}
// Non operator exception class
class nonOperator extends Exception {
    public nonOperator(String x) {
        super("*******ERROR*******\n       " + x + " is not an operator\n....Please Try Aagain....");
        }
}

class badInput extends Exception {
    public badInput() {
        super("Wrong Input type...  Please try again!\n");
        }
}

 public class Main extends JFrame implements ActionListener
 {
 	// Declared variables
        private static final String[] titles = {
				"Peg 1 to 2",
				"Peg 1 to 3",
				"Peg 2 to 1",	// button texts.
				"Peg 2 to 3",
				"Peg 3 to 1",
				"Peg 3 to 2",
				"RESET",
				"Instructions"};
 	private JLabel jLabel1;
	private JLabel jLabel3;
	private JLabel jLabel4;
 	private JTextPane display;
 	private JScrollPane jScrollPane3;
	private JProgressBar progressBar;
 	private JButton[] gameButtons = new JButton[8];
 	private JPanel  contentPane;
	private board   bd;
	boolean useManual = true;
	int count = 0;
	int discNum = 0;
	int optimum = 0;
        // End of variables declaration

        //Constructor
 	public Main()
 	{
 		super();
 		initializeComponent();
 		this.setVisible(true);
		bd = new board();
		newGame();
 	}

    private void getMode()
	{
		Object[] choices= {"Manual", "Auto"};
		Object o = JOptionPane.showInputDialog(null, "Manual or Auto mode?",
												null, JOptionPane.QUESTION_MESSAGE,
												null, choices, choices[0]);
		if (o.toString().equals(choices[0]))
		{
                        bd.pushPeg();

			display.setText("\nManual mode selected\n\nPlease enter your move\n\n\n");
                        bd.printBoard();

		}
		else if (o.toString().equals(choices[1]))
		{
			display.setText("Auto mode selected");

		        processAutomatic();
		}
	}

    private void getDiscCount()
	{
		String d = JOptionPane.showInputDialog("How many discs would you like to use?");
		discNum = Integer.parseInt(d);

		bd.board(discNum);
	 	optimum = (int)Math.pow(2,discNum)-1 ;
		String winMoves = "The optimum number of moves to win in is " + optimum;
		JOptionPane.showMessageDialog(null, winMoves );
	}


        //This method is called from within the constructor to initialize the form.
 	private void initializeComponent()
 	{
 		jLabel1 = new JLabel();
		jLabel3 = new JLabel();
		jLabel4 = new JLabel();
 		display = new JTextPane();
 		jScrollPane3 = new JScrollPane();
		progressBar = new JProgressBar();
 		contentPane = (JPanel)this.getContentPane();
		progressBar = new JProgressBar(0, optimum = (int)Math.pow(2,discNum)-1);
		progressBar.setValue(0);
		progressBar.setStringPainted(true);


 		// jLabel1
 		// setting image location
 		jLabel1.setIcon(new ImageIcon("K:\\Portable Start Menu\\Documents\\BInfoTech\\2nd Year\\Java\\visualassignment2\\build\\hanoititle.jpg"));

        // jLabel4
 		//
 		jLabel4.setText("PROGRESS");

 		//
        display.setBackground(new Color(255, 255, 255));
 		display.setForeground(new Color(0, 0, 0));
 		display.setEditable(false);
 		StyledDocument doc = display.getStyledDocument();

        MutableAttributeSet standard = new SimpleAttributeSet();
		StyleConstants.setAlignment(standard, StyleConstants.ALIGN_CENTER);
		doc.setParagraphAttributes(0, 0, standard, true);

		display.setText("INSTRUCTIONS\n\nThe object is to move all the disks from the left to the right pole.\nYou can only move one disk at a time and you must follow size order\n(a bigger disk can't go on a smaller disk).\nIf using manual mode please use the 'P' buttons to make your moves.\n\n\n");

 		//
 		// jProgressBar1
 		// sets the color of the progress bar
 		progressBar.setForeground(new Color(246, 5, 21));

       	/*
       	   Loop that will...
       	   1. create the button objects
       	   2. apply color to the first six buttons.
       	   3. add Action Listeners to all buttons
       	   4. set button lables using the 'title' array.
       	*/
       	for ( int i = 0; i < gameButtons.length; ++i )
		{
		  // #1
		  gameButtons[i] = new JButton();

		  // #2
		  if ( i < 6 ) // the 'peg move' buttons.
		  {
			gameButtons[i].setBackground(new Color(255, 255, 255));
			gameButtons[i].setForeground(new Color(0, 0, 0));
		  }

		  // #3
		  gameButtons[i].addActionListener(this);

		  // #4
		  gameButtons[i].setText(titles[i]);
		}

 		//
 		// contentPane
 		//
 		contentPane.setLayout(null);
 		contentPane.setBackground(new Color(155, 155, 209));
 		addComponent(contentPane, jLabel1, -1,0,526,282);
        addComponent(contentPane, jLabel3, 11,475,65,18);
        addComponent(contentPane, jLabel4, 4,280,98,18);
 		addComponent(contentPane, display, 1,299,523,145);
        addComponent(contentPane, jScrollPane3, 1,299,523,145);
        addComponent(contentPane, progressBar, 83,282,443,13);

		// add all the gameButtons...
 		addComponent(contentPane, gameButtons[0], 247,450,83,28);
 		addComponent(contentPane, gameButtons[1], 246,485,83,28);
 		addComponent(contentPane, gameButtons[2], 338,450,83,28);
 		addComponent(contentPane, gameButtons[3], 338,485,83,28);
 		addComponent(contentPane, gameButtons[4], 430,450,83,28);
 		addComponent(contentPane, gameButtons[5], 430,485,83,28);
        addComponent(contentPane, gameButtons[6], 20,472,90,28);
        addComponent(contentPane, gameButtons[7], 133,472,90,28);

 		//
 		// jScrollPane3
 		//
 		jScrollPane3.setViewportView(display);

 		//
 		// Main
 		//
		this.setTitle("The Towers of Hanoi");
 		this.setLocation(new Point(112, 32));
 		this.setSize(new Dimension(538, 555));
 		this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 		this.setResizable(false);
 	}




 	/** Add Component Without a Layout Manager (Absolute Positioning) */
 	private void addComponent(Container container,Component c,int x,int y,int width,int height)
 	{
 		c.setBounds(x,y,width,height);
 		container.add(c);
 	}


 	public void actionPerformed(ActionEvent e)
     {
		/* retrieve a button's text as the 'command'. */
		String command = e.getActionCommand();

		boolean validMove = true; // initially, assume all good moves.

		if ( command.equals( titles[0] ) )
		{
			try{
			  bd.movePeg12();
			}catch (Exception ee){
			   validMove = false;
			   display.setText("\n\n*** Bad Input, please try again! \n");
			}

		}
		else if ( command.equals( titles[1] ) )
		{
			try{
			  bd.movePeg13();
			}catch (Exception ee){
			   validMove = false;
			   display.setText("\n\n*** Bad Input, please try again! \n");
			}

		}
		else if ( command.equals( titles[2] ) )
		{
			try{
			  bd.movePeg21();
			}catch (Exception ee){
			   validMove = false;
			   display.setText("\n\n*** Bad Input, please try again! \n");
			}

		}
		else if ( command.equals( titles[3] ) )
		{
			try{
			  bd.movePeg23();
			}catch (Exception ee){
			   validMove = false;
			   display.setText("\n\n*** Bad Input, please try again! \n");
			}

		}
		else if ( command.equals( titles[4] ) )
		{
			try{
			  bd.movePeg31();
			}catch (Exception ee){
			   validMove = false;
			   display.setText("\n\n*** Bad Input, please try again! \n");
			}

		}
		else if ( command.equals( titles[5] ) )
		{
			try{
			  bd.movePeg32();
			}catch (Exception ee){
			   validMove = false;
			   display.setText("\n\n*** Bad Input, please try again! \n");
			}

		}
		else if ( command.equals( titles[6] ) )
		{
			// don't move with a reset.
			validMove = false;
			reset();
		}
		else if ( command.equals( titles[7] ) )
		{
			validMove = false; // only show instructions, don't move.
			display.setText("INSTRUCTIONS\n\nThe object is to move all the disks from the left to the right pole.\nYou can only move one disk at a time and you must follow size order\n(a bigger disk can't go on a smaller disk).");
		}

        // if this was not set false in by any condition
        // above, then we make a move.
        if ( validMove )
		{
			processManual();
		}
     }

        private void newGame()
        {
            count = 0;
            discNum = 0;
            optimum = 0;
            getDiscCount();
            getMode();
		}

        private void reset()
        {
            bd.withdraw(); // withdraw changed to remove all pegs.
		newGame();
        }

		private void notifyWin()
		{
		    if (count==optimum){
				display.setText("!!!!!WOOTAAAH!!!!!!\nYou finished in the optimum moves possible.\n\nYou have attained the rank of:\n\nTOWERS OF HANOI JEDI MASTER");
			}
			if (count-optimum<3&&count-optimum>0){
				display.setText("\nYou finished the game a few moves over what you needed.\n\nNot to bad I guess, but try harder next time\n\nYou have attained the rank of:\n\nTOWERS OF HANOI CASUAL PLAYER");
			}
			if (count-optimum>3&&count-optimum<8){
				display.setText("\nYou finished the game quite a few moves over what you needed.\n\nBetter luck next time ay\n\nYou have attained the rank of:\n\nTOWERS OF HANOI STABLE HAND");
			}
			if (count-optimum>8){
				display.setText("\nYou finished the game majorly behind.\nI suggest you get in alot of practice.  You need it!\n\nYou have attained the rank of:\n\nTOWERS OF HANOI TOILET CLEANER");
			}
			String conGratMessage = "Congratulations!!  You have completed the game!!\n\n" +
						"The optimum number of moves was: " + optimum +
						"\nIt took you " + count + " moves to finish.\nPress reset to try again";

		JOptionPane.showMessageDialog(null, conGratMessage );
	}

        private void processManual(){

                count++;

		bd.printBoardVertically(discNum);
		if (bd.gameFINISH())
		{
                    bd.printBoard();
			notifyWin();
		}
		else
		{

                    display.setText ("So far you have made " + count +  " moves.\nPlease choose another peg move");
                        bd.printBoard();

		}
	}

        private void processAutomatic()
	{
		bd.pushPeg();

		try
		{
			bd.initSolve(discNum);

		}
		catch (Exception ee)
		{
			display.setText("\n\n*** Bad Input, please try again! \n");
		}
	}

        public static void main(String[] args){
            JFrame.setDefaultLookAndFeelDecorated(true);
 		JDialog.setDefaultLookAndFeelDecorated(true);
 		try
 		{
 			UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
                        //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
 		}
 		catch (Exception ex)
 		{
 			System.out.println("Failed loading L&F: ");
 			System.out.println(ex);
 		}
 		new Main();
        }
 }
Let me know if the reset works as expected (or not). I'll have to do more tomorrow -- out of time again!
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #16  
Old 14-May-2008, 22:09
Barman007 Barman007 is offline
New Member
 
Join Date: May 2008
Posts: 10
Barman007 is on a distinguished road

Re: Trouble integrating console code into GUI


All good the resest button works perfectly. Assignment is due by this time tommorow just to give you a timeframe. No worries if you dont have time to help out anymore but just letting you know if you do anything you post after this time tommorow will be unuseable for me. Progress bar, printing vertically and printing to the gui screen are the only things left. Hopefully i'll have have solved atleast one of them by tommorow, but i'll post back and let you know how im going.

I know I sound like a broken record, but thanks again
  #17  
Old 15-May-2008, 06:34
Barman007 Barman007 is offline
New Member
 
Join Date: May 2008
Posts: 10
Barman007 is on a distinguished road

Re: Trouble integrating console code into GUI


Just in case you get another chance to take a look for me I just worked out how to print vertically and ive nearly finished writing the code for that, I should have that complete before I go to sleep.

Now its just a matter of getting the board displaying on the JTextPane(which ive tried a million different ways but just cant crack it) and the progress bar.


:::::::::********EDIT***********:::::::::::::

Scratch that, I thought I had it lol. Its printing out the first board state ok, but after that it just dies.

JAVA Code:
public void printBoard(){      
      
                  
                   System.out.print("\n\n\n\n\n\n\n\n");
          
           for ( int i = 0; i < discNUM; ++i ){     
                
                                   
                try{                  
                   if(!peg2.pegEmpty()&&!peg3.pegEmpty()&&peg1.pegEmpty()){
                    int b = peg2.pop();
                   peg5.push(b);
                   int c = peg3.pop();
                   peg6.push(c);
                                          
                   System.out.print("\t \t"+b+"\t"+c+"\n");               
                                                          
                   }if(!peg2.pegEmpty()&&peg3.pegEmpty()&&peg1.pegEmpty()){
                    int b = peg2.pop();
                   peg5.push(b);
                   
                                          
                   System.out.print("\t \t"+b+"\t \n");               
                                                          
                   }if(peg2.pegEmpty()&&!peg3.pegEmpty()&&peg1.pegEmpty()){
                    int c = peg3.pop();
                   peg6.push(c);
                   
                                          
                   System.out.print("\t \t \t"+c+"\n");               
                                                          
                   }
                   if (!peg1.pegEmpty()&&!peg2.pegEmpty()&&!peg3.pegEmpty()){           
                                                  
                     int a = peg1.pop();
                   peg6.push(a);                         
                    int b = peg2.pop();
                   peg5.push(b);
                   int c = peg3.pop();
                   peg6.push(c);
                                          
                   System.out.print("\t"+a+"\t"+b+"\t"+c+"\n"); 
                   }
                   if(!peg1.pegEmpty()&&!peg2.pegEmpty()&&peg3.pegEmpty()){
                    int a = peg1.pop();
                   peg4.push(a);
                   int b = peg2.pop();
                   peg5.push(b);
                                          
                   System.out.print("\t"+a+"\t"+b+"\t \n");               
                                                          
                   }
                   if(!peg1.pegEmpty()&&peg2.pegEmpty()&&peg3.pegEmpty()){
                    int a = peg1.pop();
                   peg4.push(a);
                   
                                          
                   System.out.print("\t"+a+"\t  \t \n");               
                                                          
                   }
                   if(!peg1.pegEmpty()&&peg2.pegEmpty()&&!peg3.pegEmpty()){
                    int a = peg1.pop();
                   peg4.push(a);
                   int c = peg3.pop();
                   peg6.push(c);
                                          
                   System.out.print("\t"+a+"\t \t"+c+"\n");               
                                                          
                   }
                                     
                    }             
                    catch (Exception e) {                    

                    }
               }  System.out.print("\t--");
                   System.out.print("\t-- ");
                   System.out.print("\t--");
                   System.out.println("\n\t-----------------------");   
        
          
               while( !peg5.pegEmpty()||!peg6.pegEmpty()||!peg4.pegEmpty() ){
                   try{
                       int a = peg4.pop();                     
                        peg1.push(a);
                        int b = peg5.pop();
                        peg2.push(b);               
                        int c = peg6.pop();
                        peg3.push(c); }
                        catch (Exception e){

                       }
                   }          
                   
    }                  
  #18  
Old 15-May-2008, 11:48
TurboPT's Avatar
TurboPT TurboPT is online now
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Trouble integrating console code into GUI


You said:
Quote:
Originally Posted by Barman007
...how to get the board displaying on the JTextPane... So if you can get it doing that i'd be well impressed.
Ok, well a few items needed, but here it is:

Elements for the llist class: (see the comments as to what's new)
JAVA Code:
StringBuffer nodeDataList = new StringBuffer(); // New: class variable.

public void printList() {
    nodeDataList.setLength(0); // New: clear the buffer, regardless
    printNode(head);
    System.out.println();
}

public void printNode(llnode node) {

    if (node != null) {
        nodeDataList.append( node.dataVal() + "," ); // New: append to buffer
        printNode(node.nextNode());
        System.out.print(node.dataVal() + " ");
    }
}

// New function: return the buffer as a string.
public String getDataList()
{
    return nodeDataList.toString();
}
New function for the peg class:
JAVA Code:
    public String getList()
    {
        return getDataList();
    }
New function for the board class:
JAVA Code:
// Build a string for vertical board display.
public String printBoardVertically( int numDiscs )
{
    StringBuffer verticalBoard = new StringBuffer();

    if ( numDiscs <= 0 ) // sanity check!
    {
        return "";
    }
    else
    {
        String[] p1 = null; // array for each peg.
        String[] p2 = null;
        String[] p3 = null;
        String place_holder = "-\t\t"; // no-value place holder.
        String value_spacer = "\t\t"; // keep alignment.
        int columnHeight = 0;

        /* Any peg containing value(s)
            1. print the peg (populates a buffer)
            2. get the buffer's string, and split into array.
        */
        if( peg1.countPeg() > 0 )
        {
            peg1.print();                   // #1
            p1 = peg1.getList().split(","); // #2
        }

        if( peg2.countPeg() > 0 )
        {
            peg2.print();
            p2 = peg2.getList().split(",");
        }

        if( peg3.countPeg() > 0 )
        {
            peg3.print();
            p3 = peg3.getList().split(",");
        }

        /*
            This loop will
            1. determine a reducing column height (applies to all pegs)
                This is to know if the 'height', so to speak, is larger
                than what an array contains.

            Then for each peg:
            2. is associated array null? append place holder
            3. column exceeds array size? append place holder
            4. otherwise, append array values with a value spacer.

            After each iteration of peg processing
            5. append newline.
        */
        for ( int i = 0; i < numDiscs; ++i )
        {
            columnHeight = numDiscs - i;        // #1

            if ( p1 == null )                   // #2
            {
                verticalBoard.append( place_holder );
            }
            else if ( columnHeight > p1.length )// #3
            {
                verticalBoard.append( place_holder );
            }
            else                                // #4
            {
                                        /* note the index calculation */
                verticalBoard.append( p1[p1.length - columnHeight] + value_spacer );
            }

            if ( p2 == null )                   // (#2 through #4 again)
            {
                verticalBoard.append( place_holder );
            }
            else if ( columnHeight > p2.length )
            {
                verticalBoard.append( place_holder );
            }
            else
            {
                verticalBoard.append( p2[p2.length - columnHeight] + value_spacer );
            }

            if ( p3 == null )                   // (#2 through #4 again)
            {
                verticalBoard.append( place_holder );
            }
            else if ( columnHeight > p3.length )
            {
                verticalBoard.append( place_holder );
            }
            else
            {
                verticalBoard.append( p3[p3.length - columnHeight] + value_spacer );
            }

            verticalBoard.append("\n");         // #5
       }

        System.out.println( verticalBoard.toString() );  // debug print
    }

    return verticalBoard.toString();
}
Finally, in the Main class, I made these changes:
Inside function processManual():
JAVA Code:
  // BEFORE the if, I left this in-place for debug
  bd.printBoardVertically(discNum); // leaving for console print
inside the 'else' portion, this line:
JAVA Code:
  display.setText ("So far you have made " + count +  " moves.\nPlease choose another peg move");
was modified to this:
JAVA Code:
  display.setText ("So far you have made " + count +
                   " moves.\nPlease choose another peg move" +
                   "\n" + bd.printBoardVertically(discNum) );
Inside function getMode(), in the 'if' portion, this line:
JAVA Code:
  display.setText("\nManual mode selected\n\nPlease enter your move\n\n\n");
was modified to this:
JAVA Code:
  display.setText("\nManual mode selected\nPlease enter your move\n\n" +
                 bd.printBoardVertically(discNum) );
Try it out, see how it works.
Here's sample output from the TextPane:
At start:
Code:
Manual mode selected Please enter your move 1 - - 2 - - 3 - -
Peg 1 to 3:
Code:
So far you have made 1 moves. Please choose another peg move - - - 2 - - 3 - 1
A couple minor notes to know: (not problems, just expected behavior)
1. A vertical scroll bar appears with 5+ discs
2. When the #discs exceeds nine, the double digits make the columns appear slightly off-alignment.

HTH
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #19  
Old 15-May-2008, 14:05
TurboPT's Avatar
TurboPT TurboPT is online now
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Trouble integrating console code into GUI


(if not seen yet, check post #18 for the vertical print)

As to the progress bar...

Is the progress bar supposed to work in manual mode too? You only mentioned automatic.

Anyway, the automatic solver, being recursive that it is, within another class, there is not a way (as it stands right now) to make updates to the progress status, as it only returns after solving. Also, while in this recursive mode, there won't be a way to get regular board updates back to the GUI for display either.

I don't know how much time I'll get to look at this part today, but maybe this insight (if not already known) might give some insight as to what might need to be done for an alternative?
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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 19:03
How to sort random access file? wmmccoy0910 C Programming Language 12 04-Sep-2006 04:40
Here it is again! 35% - 40% off For Life! my-e-space Web Hosting Advertisements & Offers 0 20-Apr-2006 15:48
Guidelines for posting requests for help - UPDATED! WaltP C Programming Language 0 21-Apr-2005 03:44

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:06.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.