Results 1 to 2 of 2

Thread: sape terel java swing???

  1. #1
    Join Date
    Apr 2002
    Location
    pantai bukit taman
    Posts
    31
    Rep Power
    0

    sape terel java swing???

    tolong saya compile java prog nih..anik pining kapla....




    import java.awt.*;
    import java.awt.event.*;

    import javax.swing.*;
    import javax.swing.event.*;


    public class MenuKeyEventDemo extends JFrame {
    public MenuKeyEventDemo() {
    super ("Menu Event Demo");

    Container contentPane = getContentPane();

    Font f14 = new Font ("SansSerif", Font.PLAIN, 14);
    Dimension dim = new Dimension(0, 10);

    JMenu menu1 = new JMenu ("Menu 1");

    MenuMonitor menuMonitor = new MenuMonitor();

    menu1.addMenuListener(menuMonitor);

    JMenuItem mi1 = new JMenuItem("Menu Item 1");
    mi1.setMnemonic('1');
    JMenuItem mi2 = new JMenuItem("Menu Item 2");
    mi2.setMnemonic('2');
    JMenuItem mi3 = new JMenuItem("Menu Item 3");
    mi3.setMnemonic('3');

    JMenu menu1_1 =new JMenu("Nested Menu");


    menu1_1.addMenuListener(menuMonitor);

    JMenuItem mi1_1 = new JMenuItem ("15 Love");
    mi1_1.setHorizontalAlignment(SwingConstants.LEFT);
    JMenuItem mi1_2 = new JMenuItem ("30 Love");
    JMenuItem mi1_3 = new JMenuItem ("40 Love");
    JMenuItem mi1_4 = new JMenuItem ("Game");


    menu1_1.add(mi1_1);
    menu1_1.add(mi1_2);
    menu1_1.add(mi1_3);
    menu1_1.add(mi1_4);

    menu1.add(mi1);
    menu1.add(mi2);
    menu1.add(mi3);
    menu1.addSeparator();
    menu1.add(menu1_1);


    JMenu menu2 = new JMenu("Menu 2");

    menu2.addMenuListener(menuMonitor);


    JMenu menu3 = new JMenu ("Menu 3");
    menu3.addMenuListener(menuMonitor);

    JCheckBoxMenuItem cbmi1 = new JCheckBoxMenuItem ("Check box 1");
    JCheckBoxMenuItem cbmi2 = new JCheckBoxMenuItem ("Check box 2");
    JCheckBoxMenuItem cbmi3 = new JCheckBoxMenuItem ("Check box 3");

    menu2.add(cbmi1);
    menu2.add(cbmi2);
    menu2.add(cbmi3);
    menu2.addSeparator();

    JRadioButtonMenuItem rbmi1 = new JRadioButtonMenuItem ("Radio 1");
    JRadioButtonMenuItem rbmi2 = new JRadioButtonMenuItem ("Radio 2");
    JRadioButtonMenuItem rbmi3 = new JRadioButtonMenuItem ("Radio 3");

    ButtonGroup bg = new ButtonGroup();
    bg.add(rbmi1);
    bg.add(rbmi2);
    bg.add(rbmi3);

    menu2.add(rbmi1);
    menu2.add(rbmi2);
    menu2.add(rbmi3);

    JMenuBar menuBar = new JMenuBar();

    menuBar.add(menu1);
    menuBar.add(menu2);
    menuBar.add(menu3);

    setJMenuBar(menuBar);
    }



    public Dimension getPreferredSize() {
    return new Dimension (300, 400);
    }

    public static void main(String [] args) {
    MenuKeyEventDemo app = new MenuKeyEventDemo();
    WindowListener wL = new WindowAdapter() {

    public void windowClosing(WindowEvent e) {
    e.getWindow().dispose();
    System.exit(0);
    }
    };
    app.addWindowListener(wL);

    app.pack();
    app.setVisible(true);
    }
    }

    class MenuMonitor implements MenuListener {

    public void menuCanceled(MenuEvent e) {
    System.out.println("Menu \"" + ((JMenu) e.getSource()).getText() + "\" canceled");
    }

    public void menuDeselected(MenuEvent e) {
    System.out.println("Menu \"" + ((JMenu) e.getSource()).getText() + "\" deselected");
    }

    public void MenuSelected(MenuEvent e) {
    System.out.println("Menu \"" + ((JMenu) e.getSource()).getText() + "\" selected");

    }
    }

    class MenuKeyMonitor implements MenuKeyListener {
    public void menuKeyPressed(MenuKeyEvent e) {
    System.out.println("MenuKeyEvent: Menu key pressed.");
    System.out.println("Menu item path: " + e.getPath().toString());
    System.out.println();
    }


    public void menuKeyReleased(MenuKeyEvent e) {
    System.out.println("MenuKeyEvent: Menu key released.");
    System.out.println("Menu item path: " + e.getPath().toString());
    System.out.println();
    }

    public void menuKeyTyped(MenuKeyEvent e) {
    System.out.println("MenuKeyEvent: Menu key typed.");
    System.out.println("Menu item path: " + e.getPath().toString());
    System.out.println();
    }

    }


    class MenuDragMouseEventMonitor implements MenuDragMouseListener {

    public void menuDragMouseDragged(MenuDragMouseEvent e) {
    System.out.println("MenuDragMouseEvent: Menu drag mouse dragged.");
    System.out.println("Menu item path: " + e.getPath().toString());
    System.out.println();
    }


    public void menuDragMouseEntered(MenuDragMouseEvent e) {
    System.out.println("MenudragMouseEvent: Menu drag mouse entered.");
    System.out.println("Menu item path:" + e.getPath().toString());
    System.out.println();
    }

    public void menuDragMouseExited(MenuDragMouseEvent e) {
    System.out.println("MenuDragMouseEvent: Menu drag mouse exited.");
    System.out.println("Menu item path:" + e.getPath().toString());
    System.out.println();
    }

    public void menuDragMouseReleased(MenuDragMouseEvent e) {
    System.out.println("MenuDragMouseEvent: Menu drag mouse released.");
    System.out.println("Menu item path:" + e.getPath().toString());
    System.out.println();
    }
    }
    aku merase diriku amat kecik sekali..

  2. #2
    Join Date
    Jul 2001
    Location
    KL, Malaysia
    Posts
    277
    Rep Power
    229
    Can;t compile ke?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 05-10-2007, 12:57 AM
  2. sape tau??
    By beih107 in forum Website Programming
    Replies: 8
    Last Post: 06-08-2007, 06:41 PM
  3. sape tau java..??
    By MizFiFA in forum Website Programming
    Replies: 2
    Last Post: 05-04-2007, 01:49 PM
  4. sape terel ASP.NET?
    By marisa in forum Website Programming
    Replies: 1
    Last Post: 22-10-2004, 08:10 AM
  5. ..:: Sape Leh Tolong ::..
    By ra3ali in forum Website Programming
    Replies: 9
    Last Post: 26-02-2004, 01:25 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
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32