mga boss i really had a problem in positioning attributes like label, combobox and etc sa applets. nganu maning inig add nako kai ang position niya kai sa center man or usahay di gani makita. lisud au i.position. tsk. pls help
paint ni ako applet
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Jonathan
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Paint extends JApplet{
private Container pane;
private JLabel label;
private int x =10 , y =10, size = 5;
public void init(){
// this.pane = getContentPane();
// this.pane.setLayout( new GridLayout( 300, 300 ) );
this.label = new JLabel( "Size" );
this.label.setBounds( 0, 30, 200, 25 );
this.pane.add( this.label );
addMouseListener( new MouseHandler() );
addMouseMotionListener( new MouseHandler2() );
}
public void paint( Graphics g ){
//super.paint( g );
g.fillOval( x, y , size , size );
g.drawOval(x, y, size, size);
}
private class MouseHandler implements MouseListener{
public void mouseClicked(MouseEvent e) {
x = e.getX();
y = e.getY();
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
}
private class MouseHandler2 implements MouseMotionListener{
public void mouseDragged(MouseEvent e) {
x = e.getX();
y = e.getY();
repaint();
}
public void mouseMoved(MouseEvent e) {
}
}
}