Professional Documents
Culture Documents
1. Transfer text one frame to another frame text area or text box or
lable
TextReceive.jTextArea1.setText(jTextField1.getText()+ ""+
jTextField2.getText());
receive.setVisible(true);
For closure
System.exit(0)
frame.setSize(700,500);
frame.setLocation(100,50);
frame.setTitle("My JFrame");
Container c = frame.getContentPane();
c.setBackground(Color.RED);
frame.setResizable(false);
11. How to set Font style and Font size of a JLabel Text
If the size of image is not known, we can set the image size by
following program
label.setBounds(100,50,icon.setIconWidth(),icon.setIconHeight());
c.add(label); // add the
label in container
label.setBounds(100,50,100,30);
mytext.setBackground(color.YELLOW);
mytext.setForeground(color.RED)
16. How to set RGB Font color and background color of a JTextField
mytext.setBackground(clr);
mytext.setForeground(color.RED)
btn.setText("Get");
btn.setBackgroung(clr);
btn.setForegroung(Color.YELLOW);
Another curser(crosshair)
Another curser(WAIT)
MyFrame()
{
c=this.getContentPane();
c.setLayout(null)
btn.setBounds(100,50,100,50);
btn.addActionLIstner(this);
c.add(btn);
}
public void actionPerformed(ActionEvent e)
{ c.setBackground(color.YELLOW);
}
}
class ActionDemo
{
public static void main(String[] args)
{
MyFrame f= new MyFrame();
f.setTitle("Action Demo");
f.setVisible(true)
f.defaultCloseOperatin(JFrame.EXIT_ON_CLOSE);
f.setBounds(100,50,700, 500);
Container c;
MyFrame()
{
c=this.getContentPane();
c.setLayout(null)
btn1.setBounds(100,50,100,50);
btn2.setBounds(250,50,100,50);
btn3.setBounds(400,50,100,50);
btn1.addActionLIstner(this);
btn2.addActionLIstner(this);
btn3.addActionLIstner(this);
c.add(btn1);
c.add(btn2);
c.add(btn3);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btn1){
c.background(color.RED);
}
if(e.getSource()==btn2){
c.background(color.YELLOW);
}
if(e.getSource()==btn3){
c.background(color.GREEN);
}
}
}
class ActionDemo
{
public static void main(String[] args)
{
MyFrame f= new MyFrame();
f.setTitle("Action Demo");
f.setVisible(true)
f.defaultCloseOperatin(JFrame.EXIT_ON_CLOSE);
f.setBounds(100,50,700, 500);
class ActionDemo2
{
Static Container c;
c=frame.getContentPane();
c.setBackground(color.YELLOW);
red.addActionListner(new ActionListner(){
public void actionPerformed(ActionEvent event){
redButtoneAction(event);
}
})