Using the GlassPane of the frame is an option (assuming you don't need the use of dropdowns). Some people may argue that it's an abuse of the pane system, but if the login screen is simple enough, I think it's legitimate.
The benefit is that it's already there for you to use (It doesn't require significant changes to your application), and that it eats any events (so they don't get passed to the actual application). It's also very easy to show/hide.
The downfall is a few swing components don't work on the glass pane (JComboBox is an example).
Here's an example of using the GlassPane:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class QuickTest {
public QuickTest(){
//Setup Frame
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setSize(400, 300);
frame.setLocationRelativeTo(null);
//Setup Main Content
JPanel main = new JPanel();
main.add(new JLabel("Here's the application!"));
frame.setContentPane(main);
//Setup login Screen
Box login = new Box(BoxLayout.Y_AXIS){
// Makes the main screen faded
public void paintComponent(Graphics g){
g.setColor(new Color(255,255,255,200));
g.fillRect(0,0, getWidth(), getHeight());
super.paintComponent(g);
}
};
login.add(new JLabel("Username here:"));
login.add(new JLabel("Password here:"));
JButton loginButton = new JButton("login");
loginButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
frame.getGlassPane().setVisible(false);
}
});
login.add(loginButton);
login.add(Box.createVerticalGlue());
frame.setGlassPane(login);
frame.getGlassPane().setVisible(true);
//Show Frame
frame.setVisible(true);
}
public static void main(String[] args){
new QuickTest();
}
}