#help for my 1st game please
15 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @elfin bear! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Please format your code to make it more readable.
For java, it should look like this:
````java
public void foo() {
}
````
package CarrotClicker;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class CarrotMain {
JLabel counterLabel, perSecLabel;
int carrotCounter;
Font font1, font2;
public static void main(String[] args) {
CarrotMain carrot = new CarrotMain();
carrot.createUI();
}
public CarrotMain(){
carrotCounter = 0;
createFont();
createUI();
}
public void createFont(){
font1 = new Font("Comic sans MS", Font.PLAIN, 32);
font2 = new Font("Comics sans MS", Font.PLAIN, 15);
} ```
public void createUI(){
JFrame window = new JFrame();
This message has been formatted automatically. You can disable this using /preferences.
window.setSize(800, 600);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setBackground(Color.black);
window.setLayout(null);
JPanel carrotPanel = new JPanel();
carrotPanel.setBounds(100, 220, 200, 200);
carrotPanel.setBackground(Color.black);
window.add(carrotPanel);
ImageIcon carrot = new ImageIcon(getClass().getClassLoader().getResource("Carrot.jpg"));
JButton carrotButton = new JButton();
carrotButton.setBackground(Color.black);
carrotButton.setFocusPainted(false);
carrotButton.setBorder(null);
carrotButton.setIcon(carrot);
carrotPanel.add(carrotButton);
JPanel counterPanel = new JPanel();
counterPanel.setBounds(100, 100, 200, 100);
counterPanel.setBackground(Color.black);
counterPanel.setLayout(new GridLayout(2, 1));
window.add(counterPanel);
counterLabel = new JLabel(carrotCounter + " carrots");
counterLabel.setForeground(Color.white);
counterLabel.setFont(font1);
counterPanel.add(counterLabel);
perSecLabel = new JLabel();
perSecLabel.setBackground(Color.white);
perSecLabel.setFont(font2);
counterPanel.add(perSecLabel);
window.setVisible(true);
}
}
What issue are you facing?
let me show you what it says
Error: Unable to load CarrotClicker.CarrotMain main class in CarrotClicker module
java.lang.ClassFormatError: Missing BootstrapMethods attribute in class file CarrotClicker/CarrotMain
it says that
when i run
can you help with it?
How are you compiling and running it?