import javax.swing.*; import java.awt.*; class SajatPanel extends JPanel { SajatPanel() { setBackground(Color.blue); setBounds(100, 100, 300, 300); } public void paint(Graphics g) { g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(getForeground()); Color szin = new Color(0,0,255); g.setColor(szin); g.drawString("valami", 50, 10); } } class Program extends JFrame { SajatPanel panel; Program() { panel = new SajatPanel(); panel.setBackground(Color.blue); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(null); add(panel); setSize(800, 600); setVisible(true); } public static void main(String[] argv) { new Program(); } }