i am new to swings and i don't properly know where and how to use drawString in swings !! please help!!
import java.awt.Graphics;
import java.awt.*;
import java.awt.Graphics2D;
public class Main extends javax.swing.JFrame implements Runnable {
String m1="hello";
Thread t =null;
boolean flag;
/** Creates new form NewJFrame */
public Main() {
initComponents();
}
public void start()
{
t=new Thread(this);
flag=false;
t.start();
}
public void run()
{
char ch1;
for(; ;)
{try
{
repaint();
Thread.sleep(500);
ch1=m1.charAt(0);
m1=m1.substring(1,m1.length());
m1+=ch1;
if(flag)
break;
}
catch(InterruptedException e)
{
}
}
}
public void stop()
{
flag=true;
t=null;
}
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 290, Short.MAX_VALUE)
);
getContentPane().add(jPanel1);
jPanel1.setBounds(0, 0, 400, 290);
pack();
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Main().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JPanel jPanel1;
// End of variables declaration
}
i want that string m1 should run as a banner across the screen .!!