| | |
n00b problem
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
soz bout all this posting 
i know this is a really n00b question but how do i add a black background to this prog?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CMP extends JFrame {
public void myframe() {
JFrame frm = new JFrame();
frm.setBounds(0,0,800,400);
frm.setVisible(true);
frm.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public static void main(String[] args) {
CMP pt = new CMP();
pt.myframe();
}
}

i know this is a really n00b question but how do i add a black background to this prog?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CMP extends JFrame {
public void myframe() {
JFrame frm = new JFrame();
frm.setBounds(0,0,800,400);
frm.setVisible(true);
frm.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public static void main(String[] args) {
CMP pt = new CMP();
pt.myframe();
}
}
lol 
heres my next problem
for sum reason it doesnt display the text
n e one know...lol

heres my next problem

Java Syntax (Toggle Plain Text)
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class CPB extends JFrame { public void myframe() { JFrame frm = new JFrame(); JPanel panel = (JPanel)frm.getContentPane(); panel.setBackground(Color.black); frm.setBounds(0,0,800,400); frm.setVisible(true); frm.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frm.setResizable(false); } public void paint(Graphics g) { g.setColor(color.white"); g.drawString("Text should be here :S",100,100); } public static void main(String[] args) { CPB cmp = new CPB(); cmp.myframe(); } }
for sum reason it doesnt display the text
n e one know...lol •
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
This works. It's a little bit different than yours though.
Java Syntax (Toggle Plain Text)
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class CPB extends JFrame { public CPB() { Container content = getContentPane(); setContentPane(content); setBackground(Color.black); setSize(300,300); setLayout(new FlowLayout()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public void paint(Graphics g) { g.setColor(Color.white); g.drawString("Text should be here :S",100,100); } public static void main(String[] args) { CPB cmp = new CPB(); } }
![]() |
Similar Threads
- Please Help Virus Problem (Viruses, Spyware and other Nasties)
Other Threads in the Java Forum
- Previous Thread: Importance of checking the current thread?
- Next Thread: Please anyone help tweak my code
Views: 1587 | Replies: 9
| Thread Tools | Search this Thread |
Tag cloud for Java
3d @param affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth byte c# chat class classes click client code compare component corrupted database detection draw eclipse error event exception file fractal game givemetehcodez graphics gui guitesting helpwithhomework html ide image input integer j2me java java.xls javaprojects jmf jni jpanel julia keytool linux list loop map method methods mobile netbeans newbie number object oracle os pong print problem producer program programming project projectideas read recursion reflection replaysolutions rim scanner screen server set size sms socket sort sql string swing terminal test threads time transfer tree web windows






