1
我做在Java程序,我使用JPanel
为the
接口,但我有一个问题始终在最前面,我不想这样。我希望当我恢复另一个窗口时,这将位于顶部。的JFrame始终在最前面
我试着用:
this.setAlwaysOnTop(false);
但它无法正常工作,框架总是不断在上面。
下面是一个简单的程序,与我的问题:
import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.ImageIcon;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class BorrarRegistro extends JPanel
{
public BorrarRegistro() {
super(new BorderLayout());
JLabel insertar= new JLabel("Registro");
JTextField borrar= new JTextField();
JButton borrar1= new JButton("Borrar Registro");
JPanel borrarRegistro= new JPanel(new GridLayout(4,1));
borrarRegistro.add(insertar);
borrarRegistro.add(borrar);
borrarRegistro.add(borrar1);
JPanel images= new JPanel(new GridLayout(1,3));
add(images,BorderLayout.NORTH);
add(borrarRegistro, BorderLayout.SOUTH);
}
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("ClaseBase ");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create and set up the content pane.
BorrarRegistro newContentPane = new BorrarRegistro();
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
// Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
// creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(
new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
我怎样才能解决这个问题呢?
这可能是操作系统问题。 – MadProgrammer
使用合乎逻辑的一致形式缩进代码行和块。缩进旨在使代码的流程更易于遵循! –