.setIcon () Вызывает NullPointerException - PullRequest
0 голосов
/ 05 мая 2019

Я работаю над прилично длинным кодом, который работал чудесно. Из ниоткуда это перестало работать, и я заставил других проверить это и подтвердил, что это не работает для них также. Я также попытался откатить код и даже несколько дней назад ничего не изменилось. Я поместил связку System.out.Println (), чтобы помочь мне отладить, где код ломался и получал исключение NullPointerException. Это происходит в initComponents (). Что еще более странно, так это то, что все в initComponenets было сгенерировано с NetBeans, когда я использовал GUI Builder. У меня было 15 строк с именем «Alive #», чтобы я мог легко увидеть в журналах, когда программа потерпела крах. Живой 14 был последним, что я мог видеть до крушения, Живой 15 никогда не был достигнут. Я мог только поместить фрагмент ниже. https://pastebin.com/ibPfDxMY имеет полные initComponents (). Что делает это более любопытным, так это то, что при запуске из NetBeans он работает согласованно, эта ошибка возникает только при запуске файла .jar с помощью двойного щелчка или терминала.

Я попытался запустить пустой тестовый фрейм, и он отлично работал.


public class NewFrame extends javax.swing.JFrame {

    public NewFrame() throws IOException, NullPointerException{
        System.out.println("Alive 14");
        initComponents();
        System.out.println("Alive 15");
    }


 private void initComponents() {

        mainPane = new javax.swing.JPanel();
        headerPane = new javax.swing.JPanel();
        logoButton = new javax.swing.JButton();
        exitButton = new javax.swing.JButton();
        titleLabel = new javax.swing.JLabel();
        logoutButton = new javax.swing.JButton();
        PacketPane = new javax.swing.JTabbedPane();
        exploitPane = new javax.swing.JPanel();
        exploitScroll = new javax.swing.JScrollPane();
        exploitList = new javax.swing.JList<>();
        customPane = new javax.swing.JPanel();
        customFrame = new javax.swing.JPanel();
        customScroll = new javax.swing.JScrollPane();
        customList = new javax.swing.JList<>();
        builderPane = new javax.swing.JPanel();
        builderFrame = new javax.swing.JPanel();
        builderPlaceholder = new javax.swing.JLabel();
        InfoPane = new javax.swing.JTabbedPane();
        logPane = new javax.swing.JPanel();
        logScroll = new javax.swing.JScrollPane();
        logArea = new javax.swing.JTextPane();
        chartPane = new javax.swing.JPanel();
        chartScroll = new javax.swing.JScrollPane();
        chartTable = new javax.swing.JTable();
        monsterPane = new javax.swing.JPanel();
        monsterScroll = new javax.swing.JScrollPane();
        monsterTable = new javax.swing.JTable();
        inventoryPane = new javax.swing.JPanel();
        inventoryScroll = new javax.swing.JScrollPane();
        inventoryList = new javax.swing.JList<>();
        bankPane = new javax.swing.JPanel();
        bankScroll = new javax.swing.JScrollPane();
        bankList = new javax.swing.JList<>();
        infoPane = new javax.swing.JPanel();
        infoFrame = new javax.swing.JPanel();
        goldValue = new javax.swing.JLabel();
        acValue = new javax.swing.JLabel();
        areaIdValue = new javax.swing.JLabel();
        entValue = new javax.swing.JLabel();
        usernameValue = new javax.swing.JLabel();
        areaValue = new javax.swing.JLabel();
        playerCountValue = new javax.swing.JLabel();
        playerCountLabel = new javax.swing.JLabel();
        areaLabel = new javax.swing.JLabel();
        usernameLabel = new javax.swing.JLabel();
        entLabel = new javax.swing.JLabel();
        areaIdLabel = new javax.swing.JLabel();
        acLabel = new javax.swing.JLabel();
        goldLabel = new javax.swing.JLabel();
        togglePane = new javax.swing.JPanel();
        toggleFrame = new javax.swing.JPanel();
        afkButton = new javax.swing.JButton();
        followButton = new javax.swing.JButton();
        farmButton = new javax.swing.JButton();
        slideButton = new javax.swing.JButton();
        invisibleButton = new javax.swing.JButton();
        copyButton = new javax.swing.JButton();
        copyLabel = new javax.swing.JLabel();
        invisibleLabel = new javax.swing.JLabel();
        slideLabel = new javax.swing.JLabel();
        farmLabel = new javax.swing.JLabel();
        followLabel = new javax.swing.JLabel();
        afkLabel = new javax.swing.JLabel();
        afkValue = new javax.swing.JLabel();
        followValue = new javax.swing.JLabel();
        farmValue = new javax.swing.JLabel();
        slideValue = new javax.swing.JLabel();
        invisibleValue = new javax.swing.JLabel();
        copyValue = new javax.swing.JLabel();
        SettingsPane = new javax.swing.JPanel();
        settingsFrame = new javax.swing.JPanel();
        userLabel = new javax.swing.JLabel();
        emoteLabel = new javax.swing.JLabel();
        settingsSubmitButton = new javax.swing.JButton();
        delayLabel = new javax.swing.JLabel();
        loopLabel = new javax.swing.JLabel();
        settingsSpamButton = new javax.swing.JButton();
        emoteList = new javax.swing.JComboBox<>();
        loopField = new javax.swing.JTextField();
        userField = new javax.swing.JTextField();
        textField = new javax.swing.JTextField();
        textLabel = new javax.swing.JLabel();
        delayField = new javax.swing.JTextField();
        ChatPane = new javax.swing.JPanel();
        chatScroll = new javax.swing.JScrollPane();
        chatArea = new javax.swing.JTextPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Yumemi");
        setUndecorated(true);

        mainPane.setBackground(new java.awt.Color(30, 30, 30));
        mainPane.setPreferredSize(new java.awt.Dimension(716, 567));
        mainPane.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                mainPaneMouseDragged(evt);
            }
        });
        mainPane.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                mainPaneMousePressed(evt);
            }
        });

        headerPane.setBackground(new java.awt.Color(0, 0, 0));

        logoButton.setBackground(new java.awt.Color(0, 0, 0));
        logoButton.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        logoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/AQWBot/Icons/icon.png"))); // NOI18N
        logoButton.setBorder(null);
        logoButton.setBorderPainted(false);
        logoButton.setContentAreaFilled(false);
        logoButton.setDefaultCapable(false);
        logoButton.setFocusPainted(false);
        logoButton.setFocusable(false);
        logoButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        logoButton.setIconTextGap(0);
        logoButton.setRequestFocusEnabled(false);
        logoButton.setVerifyInputWhenFocusTarget(false);
        logoButton.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                logoButtonMouseDragged(evt);
            }
        });
        logoButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                logoButtonMousePressed(evt);
            }
        });

        exitButton.setBackground(new java.awt.Color(255, 0, 0));
        exitButton.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        exitButton.setForeground(new java.awt.Color(255, 255, 255));
        exitButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aqwbot/Icons/close.jpg"))); // NOI18N
        exitButton.setText("X");
        exitButton.setBorderPainted(false);
        exitButton.setContentAreaFilled(false);
        exitButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        exitButton.setIconTextGap(0);
        exitButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/aqwbot/Icons/close_clicked.jpg"))); // NOI18N
        exitButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/aqwbot/Icons/close_hover.jpg"))); // NOI18N
        exitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitButtonActionPerformed(evt);
            }
        });

        titleLabel.setFont(new java.awt.Font("Calibri", 1, 14)); // NOI18N
        titleLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        titleLabel.setText("Yumemi");
        titleLabel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                titleLabelMouseDragged(evt);
            }
        });
        titleLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                titleLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                titleLabelMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                titleLabelMousePressed(evt);
            }
        });

        logoutButton.setBackground(new java.awt.Color(255, 102, 0));
        logoutButton.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        logoutButton.setForeground(new java.awt.Color(255, 255, 255));
        logoutButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aqwbot/Icons/logout.jpg"))); // NOI18N
        logoutButton.setText("L");
        logoutButton.setBorderPainted(false);
        logoutButton.setContentAreaFilled(false);
        logoutButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        logoutButton.setIconTextGap(0);
        logoutButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/aqwbot/Icons/logout_clicked.jpg"))); // NOI18N
        logoutButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/aqwbot/Icons/logout_hover.jpg"))); // NOI18N
        logoutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout headerPaneLayout = new javax.swing.GroupLayout(headerPane);
        headerPane.setLayout(headerPaneLayout);
        headerPaneLayout.setHorizontalGroup(
            headerPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(headerPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(logoButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(titleLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(logoutButton, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        headerPaneLayout.setVerticalGroup(
            headerPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(headerPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(headerPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(headerPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(titleLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(logoutButton, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(logoButton, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 9, Short.MAX_VALUE))
        );

        exploitList.setModel(new javax.swing.AbstractListModel<String>() {
            String[] strings = { "Raw", "XP", "Say", "Whisper", "Role Play", "Emote", "", "Join", "Goto", "Move", "House", "", "Friend", "Follow", "Copy", "ID", "", "Party Chat", "Invite Party", "Remove Party", "Summon", "Promote", "Leave Party", "", "Guild Chat", "Create Guild", "Invite to Guild", "Remove from Guild", "Promote Guild", "Demote Guild", "Change MOTD", "Rename Guild", "", "Battle Commands", "", "Custom Commands", "Invisible", "Slide", "Farm", "Share Attack", "", "Staff Commands" };
            public int getSize() { return strings.length; }
            public String getElementAt(int i) { return strings[i]; }
        });
        exploitList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        exploitScroll.setViewportView(exploitList);

        javax.swing.GroupLayout exploitPaneLayout = new javax.swing.GroupLayout(exploitPane);
        exploitPane.setLayout(exploitPaneLayout);
        exploitPaneLayout.setHorizontalGroup(
            exploitPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(exploitPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(exploitScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                .addContainerGap())
        );
        exploitPaneLayout.setVerticalGroup(
            exploitPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, exploitPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(exploitScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE)
                .addContainerGap())
        );

        PacketPane.addTab("Commands", exploitPane);

        customList.setModel(new javax.swing.AbstractListModel<String>() {
            String[] strings = { "Accept Quest", "AutoComplete Quest" };
            public int getSize() { return strings.length; }
            public String getElementAt(int i) { return strings[i]; }
        });
        customScroll.setViewportView(customList);

        javax.swing.GroupLayout customFrameLayout = new javax.swing.GroupLayout(customFrame);
        customFrame.setLayout(customFrameLayout);
        customFrameLayout.setHorizontalGroup(
            customFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(customFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(customScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)
                .addContainerGap())
        );
        customFrameLayout.setVerticalGroup(
            customFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, customFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(customScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout customPaneLayout = new javax.swing.GroupLayout(customPane);
        customPane.setLayout(customPaneLayout);
        customPaneLayout.setHorizontalGroup(
            customPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 360, Short.MAX_VALUE)
            .addGroup(customPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(customPaneLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(customFrame, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        customPaneLayout.setVerticalGroup(
            customPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 229, Short.MAX_VALUE)
            .addGroup(customPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(customPaneLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(customFrame, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );

        PacketPane.addTab("Custom", customPane);

        builderFrame.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        builderPlaceholder.setText("Accept Args and Data and Etc");

        javax.swing.GroupLayout builderFrameLayout = new javax.swing.GroupLayout(builderFrame);
        builderFrame.setLayout(builderFrameLayout);
        builderFrameLayout.setHorizontalGroup(
            builderFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(builderFrameLayout.createSequentialGroup()
                .addGap(66, 66, 66)
                .addComponent(builderPlaceholder, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(77, Short.MAX_VALUE))
        );
        builderFrameLayout.setVerticalGroup(
            builderFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(builderFrameLayout.createSequentialGroup()
                .addGap(77, 77, 77)
                .addComponent(builderPlaceholder)
                .addContainerGap(118, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout builderPaneLayout = new javax.swing.GroupLayout(builderPane);
        builderPane.setLayout(builderPaneLayout);
        builderPaneLayout.setHorizontalGroup(
            builderPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(builderPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(builderFrame, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        builderPaneLayout.setVerticalGroup(
            builderPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(builderPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(builderFrame, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        PacketPane.addTab("Packet Builder", builderPane);

        logScroll.setBackground(new java.awt.Color(50, 50, 50));
        logScroll.setForeground(new java.awt.Color(200, 200, 200));
        logScroll.setToolTipText("");

        logArea.setEditable(false);
        logArea.setBackground(new java.awt.Color(50, 50, 50));
        logArea.setContentType("text/pl"); // NOI18N
        logArea.setForeground(new java.awt.Color(200, 200, 200));
        logScroll.setViewportView(logArea);

        javax.swing.GroupLayout logPaneLayout = new javax.swing.GroupLayout(logPane);
        logPane.setLayout(logPaneLayout);
        logPaneLayout.setHorizontalGroup(
            logPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(logPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(logScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE)
                .addContainerGap())
        );
        logPaneLayout.setVerticalGroup(
            logPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(logPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(logScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE)
                .addContainerGap())
        );

        InfoPane.addTab("Packets", logPane);

        chartScroll.setBackground(new java.awt.Color(50, 50, 50));
        chartScroll.setForeground(new java.awt.Color(200, 200, 200));
        chartScroll.setToolTipText("");

        chartTable.setBackground(new java.awt.Color(50, 50, 50));
        chartTable.setForeground(new java.awt.Color(200, 200, 200));
        chartTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        chartScroll.setViewportView(chartTable);

        javax.swing.GroupLayout chartPaneLayout = new javax.swing.GroupLayout(chartPane);
        chartPane.setLayout(chartPaneLayout);
        chartPaneLayout.setHorizontalGroup(
            chartPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(chartPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(chartScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE)
                .addContainerGap())
        );
        chartPaneLayout.setVerticalGroup(
            chartPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(chartPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(chartScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
                .addContainerGap())
        );

        InfoPane.addTab("Chart", chartPane);

        monsterScroll.setBackground(new java.awt.Color(50, 50, 50));
        monsterScroll.setForeground(new java.awt.Color(200, 200, 200));
        monsterScroll.setToolTipText("");

        monsterTable.setBackground(new java.awt.Color(50, 50, 50));
        monsterTable.setForeground(new java.awt.Color(200, 200, 200));
        monsterTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        monsterScroll.setViewportView(monsterTable);

        javax.swing.GroupLayout monsterPaneLayout = new javax.swing.GroupLayout(monsterPane);
        monsterPane.setLayout(monsterPaneLayout);
        monsterPaneLayout.setHorizontalGroup(
            monsterPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(monsterPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(monsterScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE)
                .addContainerGap())
        );
        monsterPaneLayout.setVerticalGroup(
            monsterPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(monsterPaneLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(monsterScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
                .addContainerGap())
        );

        InfoPane.addTab("Monster", monsterPane);

        inventoryList.setModel(new javax.swing.AbstractListModel<String>() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public String getElementAt(int i) { return strings[i]; }
        });
        inventoryScroll.setViewportView(inventoryList);


1 Ответ

0 голосов
/ 05 мая 2019

Я предполагаю, что эта строка вызывает NullPointerException:

logoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/AQWBot/Icons/icon.png"))); // NOI18N

У меня тоже была эта проблема, и она работала для меня, когда я прошел весь путь к изображению, например: (при условии, чтоизображение находится в пакете at.daselias.resources.icons)

logoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/at/daselias/resources/icons/icon.png"))); // NOI18N

Эта проблема возникает всегда только в файле jar, но не в IDE.

EDIT :Конечно, недостаточно исправить проблему в строке, которую я предложил, вы должны делать это во всех строках, куда вы загружаете ресурсы.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...