How to create a JFrame , which contains a JLabel with text, and can be positioned anywhere in the frame.
I need this label to stay anywhere in the frame area.
How to create a JFrame , which contains a JLabel with text, and can be positioned anywhere in the frame.
I need this label to stay anywhere in the frame area.
package teste02;
import javax.swing.JFrame;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class TelaSistema extends JFrame
{
public TelaSistema()
{
setSize(600, 400);
setTitle("Sistema ");
JPanel painel = new JPanel();
painel.setLayout(null);
JLabel label = new JLabel();
label = new JLabel("Olá mundo !");
painel.add(label);
label.setBounds(250, 150, 300, 50);
add(painel);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setVisible(true);
}
public static void main(String[] args) {
TelaSistema teste = new TelaSistema();
}
}