Image on JButton

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import javax.imageio.ImageIO;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

public class Test extends JPanel {
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            constructGUI();
        }
    });
}

private static void constructGUI() {
    JFrame frame = new JFrame("Testy");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    JPanel centerPanel = new JPanel();
    centerPanel.setBackground(Color.DARK_GRAY);
    centerPanel.setPreferredSize(new Dimension(100, 400));
    frame.add(centerPanel, BorderLayout.CENTER);

    Test eastPanel = new Test();
    frame.add(eastPanel, BorderLayout.EAST);

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

public Test() {

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    Dimension d = new Dimension(50,50);

    JButton button1 = new JButton("");
    button1.setPreferredSize(d);

    button1.setIcon(new ImageIcon(this.getClass().getResource("/Pictures/ellipse.png")));

    button1.setMaximumSize(new Dimension(Integer.MAX_VALUE, button1.getMinimumSize().height));
    add(button1);

    JButton button2 = new JButton("");
    button2.setPreferredSize(d);

    button2.setIcon(new ImageIcon(this.getClass().getResource("/Pictures/ellipse.png")));

    button2.setMaximumSize(new Dimension(Integer.MAX_VALUE, button2.getMinimumSize().height));
    add(button2);

    JButton button3 = new JButton("");
    button3.setPreferredSize(d);

    button3.setIcon(new ImageIcon(this.getClass().getResource("/Pictures/ellipse.png")));

    button3.setMaximumSize(new Dimension(Integer.MAX_VALUE, button3.getMinimumSize().height));
    add(button3);

    add(Box.createVerticalGlue());


}

}

enter image description here

In my program I am trying to put the ellipse picture on top of all my buttons. As you can see in the image I posted, the ellipse.png is in the “Pictures” source folder. However, I am getting a runtime error for some reason that says:

Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
at javax.swing.ImageIcon.(ImageIcon.java:217)

I have read many posts but I can’t see a way to solve my problem.

Also, here is a link to the actual ellipse picture:

https://maxcdn.icons8.com/Share/icon/Editing//ellipse_stroked1600.png

How to integrate ProGuard in Jar Project using maven shade plugin

I have a project use maven shade plugin to package file. Now, I found proguard can obfuscate code. But proguard package .class file to a new jar file.
I need integrate ProGuard and maven shade plugin.
Can you give me some tips or help me do this?
My environment:
1. web project (use maven fronted plugin to package .js and css file).
2. use maven shade plugin package file to jar.
3. jar file use guice and jesery construct web server.

How can I let a user input their info?

Is it possible to let a user input their first, middle initial, and last name in one method and then return all the fields?

    import java.util.Scanner;

    public class name {
        // firstName middleInitial and lastName
        // toUpperCase for names

    String firstName, midddleInitial, lastName;

    public name(String firstName, String middleInitial, String lastName) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter First Name:");
        String firstName = scanner.nextLine();

        System.out.println("Enter Middle Initial:");


        System.out.println("Enter Last Name:");

        return firstName;
        return middleInital;
        return lastName;
    }
} // end of name class

How to avoid memory leaks when using arraylist with for each on android?

private ArrayList<OutputInputPair> pairs = new ArrayList<OutputInputPair>();
public void process() {
    while (!stopped) {
        for (OutputInputPair pair : pairs) {
            processCommandPairs(pair);
        }
    }
}

first when user click stop button, stopped = true so, if user not click button,
always execute processCommandPairs method.

when stop button click

@Override
public void stop() {
    Log.d(TAG, "STOP memory leak");
    pairs.clear();
    pairs = null;
    stopped = true;
}

I have only 1 question, if user does not not click button, occur memory leak in array list is right?

if not, how to avoid memory leak on arraylist?

thanks.
enter image description here

Is it possible to exclude all the bugs reported by findbugs using Regex?

I am completely new to Maven. I am trying to exclude all the bugs reported by the findbugs plugin from all the classes in a project by a regex in findbugs filter file which matches everything such as ~.* as shown in the below code, but it isn’t working. Is this possible at first place? if so how? Thanks in advance!

<FindBugsFilter>
    <Class name="~.*"/>
    <Bug pattern="~.*"/>
</FindBugsFilter>

Code for setIconImage() won’t work

I am new to Java and NetBeans. However, I have done some C/C++ before.

I wanted to change the icon of my application. So, I had a look on the internet and I found this: Changing the icon of my java application. But when I put in the code (e.g., into the constructor of my JFrame) I always get an error saying “Cannot find symbol: Class Image”. Even when I add “import Image” in the beginning of the file.

What’s wrong here?