![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#12 |
|
Newbie
Join Date: Jun 2007
Posts: 15
Rep Power: 0
![]() |
Well if there's a way I'll do it, I can only learn more about the language by trying it. ^^
|
|
|
|
|
|
#13 |
|
Hobbyist Programmer
|
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 |
|
|
|
|
|
#14 |
|
Hobbyist Programmer
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3
![]() |
I'll write something up and post it and see how close it is to what you want.
|
|
|
|
|
|
#15 |
|
Hobbyist Programmer
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3
![]() |
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. : ) |
|
|
|
|
|
#16 |
|
Newbie
Join Date: Jun 2007
Posts: 15
Rep Power: 0
![]() |
Wow, ok I wasn't expecting that! O_O
I'll take a look through this when i get a spare moment, cheers. |
|
|
|
|
|
#17 |
|
Newbie
Join Date: Jun 2007
Posts: 15
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#18 |
|
Hobbyist Programmer
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3
![]() |
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! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |