Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 15th, 2007, 4:19 PM   #11
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
One of the purposes of form designers is to allow you to select components and place them in a framework that conforms to some particular look and feel. I'm guessing that you either have the NetBeans Metallic look and feel, or your XP theme set to Horrid Silver.

If you don't want any decorations at all, then you have to get down and dirty. I don't know if you can do that with Java.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 16th, 2007, 1:57 PM   #12
Tsar_of_Cows
Newbie
 
Join Date: Jun 2007
Posts: 15
Rep Power: 0 Tsar_of_Cows is on a distinguished road
Well if there's a way I'll do it, I can only learn more about the language by trying it. ^^
Tsar_of_Cows is offline   Reply With Quote
Old Jun 17th, 2007, 12:39 AM   #13
mrynit
Hobbyist Programmer
 
mrynit's Avatar
 
Join Date: Mar 2006
Location: WA, USA
Posts: 332
Rep Power: 3 mrynit is on a distinguished road
Send a message via AIM to mrynit Send a message via MSN to mrynit Send a message via Yahoo to mrynit Send a message via Skype™ to mrynit
for text in console you can use ncurses for C/C++ or jcurses for java.
__________________
i dont know much about programming but i try to help
mrynit is offline   Reply With Quote
Old Jun 17th, 2007, 5:13 PM   #14
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
I'll write something up and post it and see how close it is to what you want.
Harakim is offline   Reply With Quote
Old Jun 17th, 2007, 6:22 PM   #15
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
This is the class that represents a full screen window. For your purposes, you may not want to ignore repaints, but I find that it is often better to ignore repaints in games, and implement them yourself.

import java.awt.Graphics;
import java.awt.Window;
import javax.swing.JFrame;
import java.awt.image.BufferStrategy;
import java.awt.DisplayMode;
import java.awt.GraphicsEnvironment;
import java.awt.GraphicsDevice;


//You should add option for Anti-Aliasing - Graphics2D.setRenderingHint, RenderingHints.XX
public abstract class FullScreenWindow extends JFrame
{
	protected Window window;
	protected BufferStrategy page;
	protected DisplayMode displayMode;
	protected GraphicsDevice device;


	protected FullScreenWindow( int width, int height, int depth )
	{
		super();

		displayMode = new DisplayMode( width, height, depth, DisplayMode.REFRESH_RATE_UNKNOWN );


		GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
		device = environment.getDefaultScreenDevice();

		//I can't get my monitor to display other modes.
		displayMode = device.getDisplayMode();

		setUndecorated( true );
		setResizable( false );
		setIgnoreRepaint( true );
	}

	public void open()
	{
		device.setFullScreenWindow( this );
		device.setDisplayMode( displayMode );

		window = device.getFullScreenWindow();

		window.createBufferStrategy(2);

		page = window.getBufferStrategy();
	}


	public void refresh()
	{
		Graphics g = page.getDrawGraphics();
		render( g );
		g.dispose();

		//Actually show the page (makes the draw buffer displayed and gets a new draw buffer )
		if ( !page.contentsLost() )
			page.show();

		//The hell if I know how this works.
		java.awt.Toolkit.getDefaultToolkit().sync();
	}


	//not implemented yet!  Wasn't as easy as I thought
	public void save( String filename )
	{
	}


	public void close()
	{
		window.dispose();

		device.setFullScreenWindow( null );
	}


	protected abstract void render( Graphics g );
}



This is the component for the command line. It is placed inside a full screen window ( to yield commandlinewindow ).
import java.awt.Color;
import java.awt.Graphics;

import java.awt.Font;
import javax.swing.JTextArea;


public class CommandLineComponent extends JTextArea
{

	public CommandLineComponent( int rows, int columns )
	{
		super( "I am a command prompt.", rows, columns );

		setIgnoreRepaint( true );

		setBackgroundColor( Color.BLACK );
		setTextColor( Color.GREEN );

		setFontType( "Monospaced" );
		setFontSize( 20 );
	}


	public void setFontType( String type )
	{
		Font oldFont = getFont();

		Font font = new Font( type, oldFont.getStyle(), oldFont.getSize() );

		setFont( font );
	}


	public void setFontSize( int size )
	{
		Font oldFont = getFont();

		Font font = new Font( oldFont.getName(), oldFont.getStyle(), size );

		setFont( font );
	}


	public void setBackgroundColor( Color c )
	{
		setBackground( c );
	}


	public void setTextColor( Color c )
	{
		setForeground( c );
	}


	public void setSize( int width, int height )
	{
		super.setSize( width, height );

		//You may wish to compute rows and columns, font size, or both.
	}


	public void paintAll( Graphics g )
	{
		super.paintAll( g );
	}

}





This is the command line window. It is a full screen window that acts kind of like a command line.
import java.awt.Color;
import java.awt.Graphics;


public class CommandLineWindow extends FullScreenWindow
{
	protected CommandLineComponent prompt;

	public CommandLineWindow( int width, int height, int depth )
	{
		super( width, height, depth );

		prompt = new CommandLineComponent( 20, 40 );

		prompt.setSize( width, height );

		add( prompt );
	}


	public void setBackgroundColor( Color c )
	{
		prompt.setBackground( c );
	}


	public void setTextColor( Color c )
	{
		prompt.setForeground( c );
	}


	public void render( Graphics g )
	{
		prompt.paintAll( g );
	}
}




This is the main class. It just creates a CommandLineWindow and draws it.
public class Test
{
	public static void main( String... args )
	{
		CommandLineWindow window = new CommandLineWindow(  800, 600, 24  );

		window.open();

		window.refresh();
	}






	public static void sleep( int millisekonds )
	{
		try{
			Thread.sleep( millisekonds );
		}
		catch(Exception e)
		{
			System.out.println( "Failed to sleep for " + millisekonds + " millisekond(s)." );
		}
	}
}



This code is far from done, but it will give you an idea of what you need to do. There are probably some bugs with the repainting. As you can see, I have disabled repaints, yet it keeps repainting anyway... go figure.

I hope this shows you what can be done in Java with a little experience. : )
Harakim is offline   Reply With Quote
Old Jun 17th, 2007, 6:47 PM   #16
Tsar_of_Cows
Newbie
 
Join Date: Jun 2007
Posts: 15
Rep Power: 0 Tsar_of_Cows is on a distinguished road
Wow, ok I wasn't expecting that! O_O

I'll take a look through this when i get a spare moment, cheers.
Tsar_of_Cows is offline   Reply With Quote
Old Jun 21st, 2007, 9:51 AM   #17
Tsar_of_Cows
Newbie
 
Join Date: Jun 2007
Posts: 15
Rep Power: 0 Tsar_of_Cows is on a distinguished road
Just managed to get a moment to test this, that's along the lines that I was looknig for.

You've been really helpful, thanks.

Last edited by Tsar_of_Cows; Jun 21st, 2007 at 10:34 AM.
Tsar_of_Cows is offline   Reply With Quote
Old Jun 22nd, 2007, 1:52 PM   #18
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
If you have other quetions feel free to ask me. <my username>@gmail.com by email or thegreatvegeta@hotmail.com for msn messenger.

Sometimes I get stuck on how to do something which usually takes one or two lines of code. It's better to just ask someone who knows. Hopefully, if you ask I will know!
Harakim is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB 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
Text Based Game demon101 PHP 8 Jan 6th, 2008 3:46 PM
Programmers wanted for an online text based game esimagin Paid Job Offers 1 May 18th, 2006 5:13 PM
Text based game jayme Existing Project Development 25 Dec 15th, 2005 7:26 AM
Text based game jayme C++ 12 Nov 22nd, 2005 11:03 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:53 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC