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
使用合乎邏輯的一致形式縮進代碼行和塊。縮進旨在使代碼的流程更易於遵循! –