Hello!
I am a student and i have this assignment to do! I must create in Java a phone! Not a "working" phone just how it looks (sort of!!)
I start it today and i have a few questions! I didnt do anything extraordinary, just create the outside and inside frames of the mobile and the frame where you write the message (in real phones)
In a few words the final output of the assignment should look something like that (a little bit more simple):
http://www.bluej.org/JavaME/Emulator.png

This is my code until so far:

MobileComponent.java

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;

import javax.swing.JComponent;

public class MobileComponent extends JComponent
{
	public void paintComponent(Graphics g)
	{
		
		Graphics2D g2 = (Graphics2D) g;
		g2.setBackground(Color.WHITE);
		
                //Outside Frame
		RoundRectangle2D outsideFrame = new RoundRectangle2D.Double(10, 10, 310, 540, 30, 30);
                //Inside Frame
                RoundRectangle2D insideFrame = new RoundRectangle2D.Double(30, 30, 270, 500, 20, 20);
                //Messaging Frame
                Rectangle2D messagingFrame = new Rectangle2D.Double(40, 40, 250, 200);
        
        
                g2.draw(outsideFrame); 
                g2.draw(insideFrame);
                g2.draw(messagingFrame);
		
	}

}

MobileViewer.java

import javax.swing.JFrame;


public class MobileViewer 
{
	public static void main(String[] args)
	{
		JFrame frame = new JFrame();
	

		
		frame.setSize(350, 600);
		frame.setTitle("Mobile Phone Emulator");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		MobileComponent component = new MobileComponent();
		frame.add(component);
		
		frame.setVisible(true);
		
		
	}

}

The first problem is that i cant change the background color of the window!
The other thing i want to ask if it is possible to "paint" the inside part/gap between OutsideFrame and Inside Frame.

Thats for now!!!

Hope someone could help!

I made some experiments and i figure it out how to fill the gap!
Here's my code:

g2.draw(outsideFrame);
        g2.setColor(Color.BLACK);
        g2.fill(outsideFrame);
        g2.draw(insideFrame);
        g2.setColor(Color.WHITE);
        g2.fill(insideFrame);
        g2.setColor(Color.BLACK);
        g2.draw(messagingFrame);

And this is the result so far:
http://i55.tinypic.com/1sb9c2.jpg

I dont need the background color now because the inside of the mobile became white with code above!!

Now i am wandering if there is a chance to make the rectangle in the messaging area/screen thikcer.
And how can i add buttons bellow the screen? I found a sort of code in the web but when i used it it disappears everything and shows only the button.
Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.