Ragazzi, mi stavo chiedendo: come applico un sfondo in un JPanel?
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JPanel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.LayoutStyle.ComponentPlacement;
public class Finestra {
private JFrame frmMlgSoundboard;
private JPanel panel;
private JButton btnNewButton;
private JTextField textField;
private JLabel lblNome;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Finestra window = new Finestra();
window.frmMlgSoundboard.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Finestra() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmMlgSoundboard = new JFrame();
frmMlgSoundboard.setResizable(false);
frmMlgSoundboard.setTitle("MLG SOUNDBOARD");
frmMlgSoundboard.setBounds(100, 100, 450, 300);
frmMlgSoundboard.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel = new JPanel();
GroupLayout groupLayout = new GroupLayout(frmMlgSoundboard.getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.TRAILING)
.addComponent(panel, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE)
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.TRAILING)
.addGroup(Alignment.LEADING, groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(panel, GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE))
);
btnNewButton = new JButton("Accedi");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});
import javax.swing.JFrame;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JPanel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.LayoutStyle.ComponentPlacement;
public class Finestra {
private JFrame frmMlgSoundboard;
private JPanel panel;
private JButton btnNewButton;
private JTextField textField;
private JLabel lblNome;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Finestra window = new Finestra();
window.frmMlgSoundboard.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Finestra() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmMlgSoundboard = new JFrame();
frmMlgSoundboard.setResizable(false);
frmMlgSoundboard.setTitle("MLG SOUNDBOARD");
frmMlgSoundboard.setBounds(100, 100, 450, 300);
frmMlgSoundboard.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel = new JPanel();
GroupLayout groupLayout = new GroupLayout(frmMlgSoundboard.getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.TRAILING)
.addComponent(panel, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE)
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.TRAILING)
.addGroup(Alignment.LEADING, groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(panel, GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE))
);
btnNewButton = new JButton("Accedi");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});