Results 1 to 3 of 3

Thread: JApplet problem

  1. #1
    Elite Member
    Join Date
    May 2011
    Gender
    Male
    Posts
    1,465

    Default JApplet problem


    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) {
        }
        }
        
        
    }

  2. #2

    Default Re: JApplet problem

    Ang sa akoa gamiton nako Jpanel that implements MouseListener sa Swing,

    Code:
    public SamplePanel()
        {
            // display panel
            JPanel displayPanel = new JPanel();
            displayPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    
    // payment label
            paymentLabel = new JLabel("Monthly Payment:");
            displayPanel.add(paymentLabel);
    
    
            // payment text field
            investmentTextField = new JTextField(10);
            displayPanel.add(investmentTextField);
    
     // add panels to frame
            setLayout(new BorderLayout());
            add(displayPanel, BorderLayout.CENTER);

  3. #3
    Elite Member
    Join Date
    May 2011
    Gender
    Male
    Posts
    1,465

    Default Re: JApplet problem

    bro, dili frame. applet man.


    OT: tinuod di ka ka set sa location sa mga attributes sa applet? liboga oe, di man pareha sa jframe

  4.    Advertisement

Similar Threads

 
  1. SGPT Problem
    By Ferl in forum Fitness & Health
    Replies: 78
    Last Post: 03-25-2013, 11:44 AM
  2. Problem with your Symbian Cellphone Software?
    By Seņor Joze in forum Gizmos & Gadgets (Old)
    Replies: 421
    Last Post: 08-28-2010, 05:15 PM
  3. Replies: 221
    Last Post: 06-02-2009, 01:22 AM
  4. Playstation 2 Problem
    By baldog in forum Gizmos & Gadgets (Old)
    Replies: 18
    Last Post: 03-02-2006, 08:28 AM
  5. m125 problem
    By eliel73173 in forum Gizmos & Gadgets (Old)
    Replies: 6
    Last Post: 04-29-2005, 01:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top