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!