Java Programming Tutorial - 62 - JButton
Why Stack Overflow recommends it
Stack Overflow users link it when they are following along to build Swing buttons with icons and hit errors such as null image paths or missing resources in Eclipse.
Recommended by 1 people across 1 different months, 2013 to 2018.
What it is
An 8-minute beginner tutorial from thenewboston's Java series on creating JButtons in Swing, including buttons with custom image icons. It is presented as a screen-recorded walkthrough in Eclipse.
What people said
Recommends nPwn · 2013-01 · Stack Overflow · on “How to add an icon to a JButton”
I was watching this tutorial: On how to create custom JButtons [this video] and I put my file in the C < Users < MyUserName < workspace < ProjectName < src like the tutorial said and I got this error Exception in thread "main" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(Unknown Source) at Gui.<init>(Gui.java:20) at tuna.main(tuna.java:6) On a comment on the next tutorial it said to put it in C < Users < MyUserName < workspace < ProjectName < bin so I tried that and I still get the same error. I am using eclipse and I have a newer version of it than used in the tutorial. Any help? Additional Information: The files are .png tuna: Gui item = new Gui(); item.setSize(300,300); item.
Cites Vaclovas Rekašius Jr. · 2015-02 · Stack Overflow · on “Eclipse can`t find my photo for button”
[this video] look, the guy from tutorial sees those photos on the left, and in my eclipse there are no photos shown, although I`ve saved them into my source file with the right format. Thanks for helping me out!
Cites TVlassi · 2018-06 · Stack Overflow · on “Invalid Method Declaration? Return Type Required?”
import java.util.*; 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; //----------I could just do import java.awt.*; and import java.swing.*; but, when the program get larger, this could cause glitches, so it's better not to---------- public class Gui extends JFrame{ public class QA //THIS IS WHERE I'M GETTING THE ERROR MESSAGE { private int x; private JButton reg; private JButton custon; public Gui(); public QA() { I coppied code from a youtube video ( [this video] ), but I'm not sure what the problem is.