New and Used Car Talk Reviews Hot Cars Comparison Automotive Community

The Largest Car Forum in the Philippines

Page 1 of 2 12 LastLast
Results 1 to 20 of 21
  1. Join Date
    Oct 2002
    Posts
    4,388
    #1
    mga java programmers, tulong naman po. may project kami sa java, gawa kami ng paint. may konting problema lang po kasi kami e, yung ginawa naming menubar kapag kiniclick mo na e sa ilalim ng canvas pumupunta imbes na sa ibabaw ng canvas. kaya tuloy nde makita yung laman ng menu bar. swing nga pala ginamit namin sa mga menubar.

    salamat!!

  2. Join Date
    Oct 2002
    Posts
    4,614
    #2
    maybe posting the relevant code would help...

    (hmm... paint? CS21B ba ito sa admu by any chance? :D)

  3. Join Date
    Oct 2002
    Posts
    4,388
    #3
    eto po yung code, salamat!!
    mapua-makati, sl-275... salmata ulit

    private void launchFrame() {
    f.setJMenuBar(menuBar);



    //FILE MENU
    menuBar.add(fileM);
    newMi.setAccelerator(KeyStroke.getKeyStroke(KeyEve nt.VK_N, InputEvent.CTRL_MASK));
    newMi.setText("New");
    fileM.add(newMi);
    openMi.setAccelerator(KeyStroke.getKeyStroke(KeyEv ent.VK_O, InputEvent.CTRL_MASK));
    openMi.setText("Open...");
    fileM.add(openMi);
    saveMi.setAccelerator(KeyStroke.getKeyStroke(KeyEv ent.VK_S, InputEvent.CTRL_MASK));
    saveMi.setText("Save");
    fileM.add(saveMi);
    saveAsMi.setText("Save As...");
    fileM.add(saveAsMi);
    fileM.add(fileSeparator1);
    printMi.setAccelerator(KeyStroke.getKeyStroke(KeyE vent.VK_P, InputEvent.CTRL_MASK));
    printMi.setText("Print...");
    fileM.add(printMi);
    fileM.add(fileSeparator2);
    exitMi.setAccelerator(KeyStroke.getKeyStroke(KeyEv ent.VK_F4, InputEvent.ALT_MASK));
    exitMi.setText("Exit");
    fileM.add(exitMi);

    //EDIT MENU
    menuBar.add(editM);
    undoMi.setAccelerator(KeyStroke.getKeyStroke(KeyEv ent.VK_Z, InputEvent.CTRL_MASK));
    undoMi.setText("Undo");
    editM.add(undoMi);
    redoMi.setAccelerator(KeyStroke.getKeyStroke(KeyEv ent.VK_Y, InputEvent.CTRL_MASK));
    redoMi.setText("Redo");
    editM.add(redoMi);
    editM.add(editSeparator1);
    cutMi.setAccelerator(KeyStroke.getKeyStroke(KeyEve nt.VK_X, InputEvent.CTRL_MASK));
    cutMi.setText("Cut");
    editM.add(cutMi);
    copyMi.setAccelerator(KeyStroke.getKeyStroke(KeyEv ent.VK_C, InputEvent.CTRL_MASK));
    copyMi.setText("Copy");
    editM.add(copyMi);
    pasteMi.setAccelerator(KeyStroke.getKeyStroke(KeyE vent.VK_V, InputEvent.CTRL_MASK));
    pasteMi.setText("Paste");
    editM.add(pasteMi);

    //VIEW MENU
    menuBar.add(viewM);
    toolBoxCb.setAccelerator(KeyStroke.getKeyStroke(Ke yEvent.VK_T, InputEvent.CTRL_MASK));
    toolBoxCb.setText("Tool Box");
    viewM.add(toolBoxCb);
    colorBoxCb.setAccelerator(KeyStroke.getKeyStroke(K eyEvent.VK_L, InputEvent.CTRL_MASK));
    colorBoxCb.setText("Color Box");
    viewM.add(colorBoxCb);
    viewM.add(viewSeparator1);
    viewBitmapMi.setAccelerator(KeyStroke.getKeyStroke (KeyEvent.VK_F, InputEvent.CTRL_MASK));
    viewBitmapMi.setText("View Bitmap");
    viewM.add(viewBitmapMi);

    //COLORS MENU
    menuBar.add(colorsM);
    editColorsMi.setText("Edit Colors");
    colorsM.add(editColorsMi);

    //HELP MENU
    menuBar.add(helpM);
    helpTopicsMi.setAccelerator(KeyStroke.getKeyStroke (KeyEvent.VK_F1, 0));
    helpTopicsMi.setText("Help");
    helpM.add(helpTopicsMi);
    helpM.add(helpSeparator1);
    aboutQuillMi.setText("About Quill");
    helpM.add(aboutQuillMi);

    //BUTTONS PANEL
    f.getContentPane().add(buttonsPanel, BorderLayout.WEST);
    buttonsPanel.setBorder(new javax.swing.border.EtchedBorder());
    buttonsPanel.setForeground(new java.awt.Color(0, 0, 0));
    buttonsInnerPanel.setLayout(new java.awt.GridLayout(3, 2, 3, 2));

    penB.setText("P");
    buttonGroup1.add(penB);
    penB.setBorder(new javax.swing.border.EtchedBorder());
    penB.setMargin(new java.awt.Insets(0, 0, 0, 0));
    penB.setMaximumSize(new java.awt.Dimension(25, 10));
    penB.setMinimumSize(new java.awt.Dimension(25, 10));
    penB.setPreferredSize(new java.awt.Dimension(25, 10));
    buttonsInnerPanel.add(penB);

    eraserB.setText("E");
    buttonGroup1.add(eraserB);
    eraserB.setBorder(new javax.swing.border.EtchedBorder());
    eraserB.setMargin(new java.awt.Insets(0, 0, 0, 0));
    eraserB.setMaximumSize(new java.awt.Dimension(25, 10));
    eraserB.setMinimumSize(new java.awt.Dimension(25, 10));
    eraserB.setPreferredSize(new java.awt.Dimension(25, 10));
    buttonsInnerPanel.add(eraserB);

    lineB.setText("L");
    buttonGroup1.add(lineB);
    lineB.setBorder(new javax.swing.border.EtchedBorder());
    lineB.setMargin(new java.awt.Insets(0, 0, 0, 0));
    lineB.setMaximumSize(new java.awt.Dimension(25, 10));
    lineB.setMinimumSize(new java.awt.Dimension(25, 10));
    lineB.setPreferredSize(new java.awt.Dimension(25, 10));
    buttonsInnerPanel.add(lineB);

    squareB.setText("S");
    buttonGroup1.add(squareB);
    squareB.setBorder(new javax.swing.border.EtchedBorder());
    squareB.setMargin(new java.awt.Insets(0, 0, 0, 0));
    buttonsInnerPanel.add(squareB);

    circleB.setText("C");
    buttonGroup1.add(circleB);
    circleB.setBorder(new javax.swing.border.EtchedBorder());
    circleB.setMargin(new java.awt.Insets(0, 0, 0, 0));
    buttonsInnerPanel.add(circleB);

    brushB.setText("B");
    buttonGroup1.add(brushB);
    brushB.setBorder(new javax.swing.border.EtchedBorder());
    brushB.setMargin(new java.awt.Insets(0, 0, 0, 0));
    buttonsInnerPanel.add(brushB);
    buttonsPanel.add(buttonsInnerPanel, java.awt.BorderLayout.NORTH);

    colorsPanel.setBorder(new javax.swing.border.EtchedBorder());
    colorsPanel.setMinimumSize(new java.awt.Dimension(8, 30));
    colorsPanel.setPreferredSize(new java.awt.Dimension(334, 30));
    mouseCoordinate.setEditable(false);
    colorsPanel.add(mouseCoordinate,BorderLayout.WEST) ;

    //paper is the drawing canvas
    paper.addMouseMotionListener(this);
    paper.addMouseListener(this);

    f.getContentPane().add(paper, BorderLayout.CENTER);
    f.getContentPane().add(colorsPanel, java.awt.BorderLayout.SOUTH);

    f.setSize(500,500);
    f.addWindowListener(this);
    f.setVisible(true);



    }

  4. Join Date
    Oct 2002
    Posts
    10,620
    #4
    PajeroKid is the man

  5. Join Date
    Oct 2002
    Posts
    10,603
    #5
    i'll give you answers mamaya flakez.

  6. Join Date
    Oct 2002
    Posts
    10,603
    #6
    flakez, anong version gamit mo? 1.3 or 1.4?

    also, paki kumpleto source code mo... puro kulang eh. Kahit yung object declarations lang.

    HIndi ko kabisado kasi lahat ng classes for rendering menus, pero I suspect that you just need to find a method which changes the appearance settings. Meron ka bang object ng BasicMenuBarUI or MultiMenuBarUI classes?
    Last edited by pajerokid; November 24th, 2003 at 02:44 PM.

  7. Join Date
    Oct 2002
    Posts
    10,603
    #7
    try mo ito...

    BasicMenuBarUI myObject = newBasicMenuBarUI();
    myObject.installDefaults();

    Of course you have to change the object name from "myObject" to whatever youre using.

  8. Join Date
    Oct 2002
    Posts
    4,614
    #8
    pajerokid,

    napaka high tech naman niyang classes mo... diba basic JMenuBar lang yung kelangan in swing? (???) hehe

  9. Join Date
    Oct 2002
    Posts
    10,603
    #9
    Yup, but the JMenuBar class doesnt contain any method which changes its look and feel. i checked with Javadocs, wala akong nakita.

    BTTT, kung walang UI classes set to the JMenuBar object...

    paki try ito...

    System.out.println(menuOBJ.getUIClassID());

    replace "menuOBJ" with your JMenuBar object name and tell me kung ano lumalabas.

    Honestly, i have little experience with menus

  10. Join Date
    Oct 2002
    Posts
    10,603
    #10
    BasicMenuBarUI myObject = newBasicMenuBarUI();
    myObject.installDefaults();
    JMenuBar menuObj.setUI(myObject);

    Setting the L&F object to the JMenuBar. Worth a try.

  11. Join Date
    Oct 2002
    Posts
    10,603
    #11
    what is object f? a JFrame?

    mbt, java man ka pala

  12. Join Date
    Oct 2002
    Posts
    4,614
    #12
    pajerokid,

    BS Comp Sci ako nung first year hehe... tapos nag shift ako sa pre-med :D

  13. Join Date
    Oct 2002
    Posts
    10,603
    #13
    aaah. ;) Another future doctor! At least i know im in good hands when i get all creaky and leaky hehehe

  14. Join Date
    Jul 2003
    Posts
    3,042
    #14
    huwa... im lost :confused: :confused: hehe

  15. Join Date
    Oct 2002
    Posts
    4,614
    #15
    pissword,

    never fear, javameister pajerokid is here!!! hehehe :D

  16. Join Date
    Oct 2002
    Posts
    4,388
    #16
    *pajerokid, 1.4 gamit ko.
    MenuBarUI lumabas System.out.println(menuOBJ.getUIClassID());

    error po dito:
    BasicMenuBarUI myObject = newBasicMenuBarUI();
    myObject.installDefaults();
    JMenuBar menuObj.setUI(myObject);
    cannot resolve symbol... BasicMenuBarUI
    ano po kelangan ko import?

    ano yung l&f object?
    f is JFrame

    salamat!!!

  17. Join Date
    Oct 2002
    Posts
    4,388
    #17
    eto po yung object declaration.. haba kasi e, nde allowed, limited yung characters. salamat!! kelangan ko pa po bang sama yung canvas class(paper)??



    public class RunQuill implements WindowListener, MouseListener, MouseMotionListener{
    private JFrame f;
    private JButton clear;
    private Paper paper;

    private JTextField mouseCoordinate;

    //BUTTONS PANEL
    private JPanel buttonsPanel;
    private JPanel buttonsInnerPanel;
    private ButtonGroup buttonGroup1;
    private JToggleButton eraserB;
    private JToggleButton circleB;
    private JToggleButton lineB;
    private JToggleButton penB;
    private JToggleButton brushB;
    private JToggleButton squareB;

    //COLORS PANEL
    private JPanel colorsPanel;

    //MENU BAR
    private JMenuBar menuBar;

    //FILE MENU
    private JMenu fileM;
    private JMenuItem newMi;
    private JMenuItem openMi;
    private JMenuItem saveMi;
    private JMenuItem saveAsMi;
    private JSeparator fileSeparator1;
    private JMenuItem printMi;
    private JSeparator fileSeparator2;
    private JMenuItem exitMi;

    //EDIT MENU
    private JMenu editM;
    private JMenuItem redoMi;
    private JMenuItem undoMi;
    private JSeparator editSeparator1;
    private JMenuItem cutMi;
    private JMenuItem copyMi;
    private JMenuItem pasteMi;

    //VIEW MENU
    private JMenu viewM;
    private JCheckBoxMenuItem toolBoxCb;
    private JCheckBoxMenuItem colorBoxCb;
    private JSeparator viewSeparator1;
    private JMenuItem viewBitmapMi;

    //COLORS MENU
    private JMenu colorsM;
    private JMenuItem editColorsMi;

    //HELP MENU
    private JMenu helpM;
    private JMenuItem aboutQuillMi;
    private JSeparator helpSeparator1;
    private JMenuItem helpTopicsMi;

    public RunQuill(){
    clear = new JButton("Clear");
    f = new JFrame("QUILL");
    paper = new Paper();

    //BUTTONS
    buttonGroup1 = new ButtonGroup();
    buttonsPanel = new JPanel();
    buttonsInnerPanel = new JPanel();
    penB = new JToggleButton();
    eraserB = new JToggleButton();
    lineB = new JToggleButton();
    squareB = new JToggleButton();
    circleB = new JToggleButton();
    brushB = new JToggleButton();

    //PANEL FOR COLORS POSITION OF MOUSE
    colorsPanel = new JPanel();
    mouseCoordinate = new JTextField(30);

    //MENUBAR OBJ
    menuBar = new JMenuBar();

    //FILE MENU OBJ
    fileM = new JMenu("File");
    newMi = new JMenuItem();
    openMi = new JMenuItem();
    saveMi = new JMenuItem();
    saveAsMi = new JMenuItem();
    fileSeparator1 = new JSeparator();
    printMi = new JMenuItem();
    fileSeparator2 = new JSeparator();
    exitMi = new JMenuItem();

    //EDIT MENU OBJ
    editM = new JMenu("Edit");
    undoMi = new JMenuItem();
    redoMi = new JMenuItem();
    editSeparator1 = new JSeparator();
    cutMi = new JMenuItem();
    copyMi = new JMenuItem();
    pasteMi = new JMenuItem();

    //VIEW MENU OBJ
    viewM = new JMenu("View");
    toolBoxCb = new JCheckBoxMenuItem();
    colorBoxCb = new JCheckBoxMenuItem();
    viewSeparator1 = new JSeparator();
    viewBitmapMi = new JMenuItem();

    //COLORS OBJ
    colorsM = new JMenu("Colors");
    editColorsMi = new JMenuItem();

    //HELP MENU OBJ
    helpM = new JMenu("Help");
    helpTopicsMi = new JMenuItem();
    helpSeparator1 = new JSeparator();
    aboutQuillMi = new JMenuItem();


    }

  18. Join Date
    Oct 2002
    Posts
    10,603
    #18
    Grabe, ano yung Paper class? Ngayon ko lang nakita yan ah.

    After 2 years with Java.. it still gives me surprises. Sorry flakes, im strictly a v1.3 guy, pero i'll try my best to help you.. anyway, sana hindi kasama yung classes na pinaguusapan natin sa version change.

    Class MenuBarUI comes from the package javax.swing.plaf.*

    Pare are you familiar with javadocs? looks like hindi tinuturo ng prof mo. This is actually the first stuff i teach my studes.... it makes them think and practice their research skills

    click --> http://java.sun.com/j2se/1.4.1/docs/api/

    you'll find all v1.4 classes, methods etc there.

    email mo na lang kaya complete code sakin? mann2*i-manila.com.ph

    i'll work on it in my spare time. Pero i cant give any assurances kung kelan coz im workng two jobs at the moment.

  19. Join Date
    Oct 2002
    Posts
    4,388
    #19
    salamat po. yung paper class anop lang po yun, gawa lang namin... yun po yung canvas kung san ka magddrawing... don nangyayari lahat ng drawing....

    salamat po sa lahat. email ko na lang yung package ng mga classes.

    salamat ulit.

  20. Join Date
    Oct 2002
    Posts
    4,614
    #20
    flakez,

    yup you should look at the javadocs if you haven't yet

Page 1 of 2 12 LastLast
java programmers... tulong!!