I added two JMenu's on the frame :
JFrame frame = new JFrame();
//Menu :
menuBar = new JMenuBar();
menu = new JMenu("Fichier");
menu2 = new JMenu("Options");
JSeparator sep = new JSeparator(SwingConstants.VERTICAL);
JButton btn = new JButton();
btn.addActionListener(MyListener);
menuBar.add(menu);
menuBar.add(sep);
menuBar.add(menu2);
frame.setJMenuBar(menuBar);
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class Test {
public static void main(String[] args) {
new Test();
}
public Test() {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
JTextArea ta = new JTextArea(20, 40);
JFrame frame = new JFrame();
frame.setUndecorated(true);
frame.add(new JScrollPane(ta));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
}
}
Now, if you "need" some padding around the edges, either use a layout manager that allows you to specify padding or use a EmptyBorder
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;
public class Test {
public static void main(String[] args) {
new Test();
}
public Test() {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
JTextArea ta = new JTextArea(20, 40);
JFrame frame = new JFrame();
JPanel content = new JPanel(new BorderLayout());
content.setBorder(new EmptyBorder(16, 16, 16, 16));
frame.setContentPane(content);
frame.setUndecorated(true);
frame.add(new JScrollPane(ta));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
}
}
I think you will find:
- Creating a GUI With Swing
- How to Make Frames (Main Windows)
- Laying Out Components Within a Container
a better place to start.
Also, in future, ask 1 specific question, otherwise you risk having the question closed for "needing more focus"