Results 1 to 2 of 2
- 05-20-2011, 08:53 AM #1
Member
- Join Date
- May 2011
- Posts
- 12
- Rep Power
- 0
help importing pictures into paint component of another class.
so I have this jpanel and it works fine- compiles and runs (unfinished) and I want to split things up so I can deal with the actions etc here but have objects in other classes to keep things clean. Here is my jpanel right now.
Java Code:import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.awt.Color; public class A3JPanel extends JPanel { //implements KeyListener, ActionListener private Timer t; public A3JPanel() { setBackground(Color.white); //t= new Timer(30,this); //addKeyListener(this); } Color lightBrown = new Color(150,60,40); Color darkBrown = new Color(100,10,40); public void paintComponent(Graphics g){ super.paintComponent(g); g.setColor(Color.GREEN); g.fillRect(0, 0, 600, 500); g.setColor(Color.BLUE); g.fillRect(0, 400, 600, 100); g.setColor(darkBrown); g.fillRect(20, 430, 15, 100); g.fillRect(100, 430, 15, 100); g.fillRect(180, 430, 15, 100); g.fillRect(260, 430, 15, 100); g.fillRect(340, 430, 15, 100); g.fillRect(420, 430, 15, 100); g.fillRect(500, 430, 15, 100); g.fillRect(580, 430, 15, 100); g.setColor(Color.BLUE); g.fillRect(0, 480, 600, 30); g.setColor(lightBrown); g.fillRect(0, 425, 600, 15); g.setColor(Color.YELLOW); g.fillRect(0, 0, 600, 20); g.setColor(Color.GREEN); g.fillRect(7,3, 30, 14); g.fillRect(44,3, 30, 14); g.fillRect(81,3, 30, 14); g.fillRect(118,3, 30, 14); g.fillRect(155,3, 30, 14); g.fillRect(192,3, 30, 14); g.fillRect(229,3, 30, 14); g.fillRect(266,3, 30, 14); g.fillRect(303,3, 30, 14); g.fillRect(340,3, 30, 14); g.fillRect(377,3, 30, 14); g.fillRect(414,3, 30, 14); g.fillRect(451,3, 30, 14); g.fillRect(488,3, 30, 14); g.fillRect(525,3, 30, 14); g.fillRect(562,3, 30, 14); } }
- 05-20-2011, 02:59 PM #2
Similar Threads
-
The Funny Pictures Thread(this means a lot of pictures...)
By joshua in forum EntertainmentReplies: 22Last Post: 07-25-2012, 10:51 PM -
Build project - paint component in Panel not visible.
By aborgeld in forum NetBeansReplies: 10Last Post: 04-11-2011, 10:34 PM -
using paint methode in another class
By imorio in forum New To JavaReplies: 8Last Post: 08-12-2010, 04:17 PM -
Custom component and paint outside of bounds
By happy_hippie in forum AWT / SwingReplies: 2Last Post: 06-30-2010, 06:41 PM -
importing class files
By bizso in forum New To JavaReplies: 6Last Post: 03-28-2009, 03:11 PM
Bookmarks