I am fairly new to coding in general; however, am very adaptive. Here is the code. The background graphics and sound loads fine, but the JButton has a short delay before loading. Any help is appreciated!
public Window() {
startButton = new JButton();
initialPanel = new JPanel();
startButtonLabel = new JLabel("Start");
add(initialPanel, BorderLayout.SOUTH);
initialPanel.add(startButton);
startButton.add(startButtonLabel);
setSize(800, 600);
setLocationRelativeTo(null);
setUndecorated(true);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void paint (Graphics g) {
ImageIcon panel = new ImageIcon ("NOWNEW2.png");
g.drawImage(panel.getImage(), 0, 0, null);
try {
File sound = new File("bensound-newdawn.wav");
AudioInputStream ais = AudioSystem.getAudioInputStream(sound);
Clip clip = AudioSystem.getClip();
clip.open(ais);
clip.start();
}
catch (Exception e) {
System.out.println(e);
}
}
public static void main (String [] args) {
new Window();
}
}