Java Programming Tutorial – 62 – JButton

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

38 responses to “Java Programming Tutorial – 62 – JButton”

  1. Abaddon Destroyer Avatar

    isn't it better to implement an interface instead of extend the class? (don't mind my stupidity if this makes no sense.. i am a newbie yet)

  2. David Shavin Avatar

    why is JFrame's constructor 'super' shouldn't the constructer be called JFrame as well?

  3. Khim Bahadur Gurung Avatar

    How to set the position of the controls in frame?

  4. Tips and Tricks Avatar

    import java.awt.FlowLayout;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JFrame;
    import javax.swing.JButton;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;

    public class Gui extends JFrame{
    private JButton reg;
    private JButton custom;

    public Gui (){
    super ("The title");
    setLayout(new FlowLayout());

    reg = new JButton ("reg Button");
    add(reg);

    Icon b = new ImageIcon(getClass().getResource("b.png"));
    Icon x = new ImageIcon(getClass().getResource("x.png"));
    custom = new JButton ("Custom",b);
    custom.setRolloverIcon(x);
    add(custom);
    }
    }

  5. Wood Woody Avatar

    The images should be in src or bin folder? It works in "bin": folder instead of "src".

  6. fevkaladeninfevki Avatar

    why doesnt he use jframe pallette, im quite sure it or smt like it  existed in 2009 too

  7. Bruh Avatar

    hi i have a question why you make a private JButton reg; why not just private JButton reg = new JButton("reg button");

  8. anil nayak Avatar

    Where is the 500th video that Bucky was talking about in the past few videos?

  9. cantor0305 Avatar

    is there someone else has "icon cannot be resolved to a type" ? i made almost all the solution in the comments section, but eclipse just don't want to use my x.png and b.png !

  10. Tommy X. Gomez Garcia Avatar

    you make all tutorials super accurate man, thank you for your effort

  11. LTmattYT Avatar

    this cat got the box copy of cod4 for pc. peace

  12. Ramy Tawfik Avatar

    how can i set the dimensions of the image ?!

  13. Rain Avatar

    Can someone explain how getClass().getResource() work as in concept? What either of them do and how do these two work together.

  14. gay mario Avatar

    That has the title "the title" on the title bar

    say that ten times fast

  15. Lasse Kiminki Avatar

    Can someone tell me where can i see all meanings to all "import" commands. And where can i find them in Eclipse?

  16. Sourav Aswal Avatar

    Exception in thread "main" java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(ImageIcon.java:217)
    at gui.<init>(gui.java:19)
    at dogList.main(dogList.java:5)
    //dogList is the class having main()
    Can anyone help me with this error?

  17. JuiceWater Avatar

    Ewwww, windows vista!

    Wait, this was 2009.

  18. Khaled Abolaynain Avatar

    Who loves GUIs? The worst part of Java coding till now!

  19. You're mom Avatar

    "Title of the title on the title bar" bars.

  20. Mahgoub Abbas Avatar

    when i type getResource(x.png)Eclipse gives an error under the word Resource can anyoune explain?

  21. eccentricArchitect Avatar

    "Welcome to your 60 second Java tutorial" hahaha Gonna learn real fast !!

  22. eric newmen Avatar

    import java.awt.FlowLayout;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JFrame;
    import javax.swing.JButton;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;

    feel free to copy and paste

  23. Puk Ka Avatar

    Can anyone explain me the logical concept behind in very simple words ***getClass().getResource?
    This programming you never too many rules all of a sudden in one line! Anyways..

  24. Arveer Singh Avatar

    4:45 now everyone knows he likes call of duty

  25. DiamondsRaider Avatar

    rather than all of those imports, just use
    import java.awt.*;
    and
    import javax.swing.*;

  26. Elay Sieukfp Avatar

    What does extends JFrame means? does it mean that i create a JFrame?

  27. Nushie Nush Avatar

    If transferring the files to bin folder doesn't work too. right click src, go to import, expand "General" then click on "File System," and then Browse your images

  28. Jie Lv Avatar

    I also have the problem about importing pictures. I solved that by moving pics to the bin folder. Not sure why this happens. I use the newest version of java. Is the version problem here?

  29. Armin Sarajlic Avatar

    I see Call of Duty 4, I press like

  30. Kenneth Taylor Avatar

    Very helpful! Thank you.

  31. vljzlj Avatar

    Am I the only one that didnt get how to import pictures ? I'm stuck with it :/ can anyone help ? 🙂

  32. Villexy herp Avatar

    Ctrl + Shift + O to import everything you need to import

  33. niCkcAMelno1 Avatar

    I didn't have time to write down all the "import"s before he collapsed the section!!

Leave a Reply

Your email address will not be published. Required fields are marked *