1

ログインとパスワードを入力してからログインを取得し、textFields から渡すことができるフルスクリーン ウィンドウが必要です。このコードを Eclipse で実行すると、ログイン テキスト フィールドとパス テキスト フィールドに入力できません。これがコードです。

import java.awt.*; 
import java.awt.event.*;
import javax.swing.*; 
import javax.swing.event.*; 

public class MostrarBloqueio extends JFrame implements ActionListener
{ 
    private static GraphicsDevice graphicsDevice1;
    private DisplayMode minDisplayMode; 
    private JButton loginButton = new JButton( "login"); 
    private JTextField txtLogin;
    private JPasswordField passwordField;

    public static void main(String[] args)
    { //Get and display a list of graphics devices solely for // information purposes. 
        GraphicsEnvironment graphicsEnvironment =  GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices(); 
        for(int cnt = 0;cnt < 1;cnt++)
        {
            System.out.println(devices[cnt]); 

        }//end for loop
    //Construct a full-screen object //
        new MostrarBloqueio(devices[0]);
    }//end main



//Constructor 
    public MostrarBloqueio(GraphicsDevice graphicsDevice)
    { 
        //Save a reference to the graphics device as an // instance variable so that it can be used later to // exit the full-screen mode.  

        this.graphicsDevice1 = graphicsDevice; 
        setTitle("This title will be hidden (undecorated)"); //Get and save a reference to the original display // mode as an instance variable so that it can be // restored later.  
        minDisplayMode = graphicsDevice.getDisplayMode(); 
        loginButton.setBounds(633, 518, 103, 23);

            //Register an action listener on the loginButton.  
        loginButton.addActionListener(this);  
        getContentPane().setLayout(null);

        passwordField = new JPasswordField();
        passwordField.setBounds(633, 475, 142, 20);
        getContentPane().add(passwordField);
        passwordField.setColumns(10);

            //Place the loginButton in the JFrame
        getContentPane().add(loginButton);
        getContentPane().setBackground(getBackground());

        JLabel lblNewLabel = new JLabel("senha:");
        lblNewLabel.setBounds(578, 478, 45, 14);
        getContentPane().add(lblNewLabel);

        JLabel lblLogin = new JLabel("Login:");
        lblLogin.setBounds(578, 456, 45, 14);
        getContentPane().add(lblLogin);

        txtLogin = new JTextField();
        txtLogin.setBounds(633, 453, 142, 20);
        getContentPane().add(txtLogin);
        txtLogin.setColumns(10);        

        if (graphicsDevice.isFullScreenSupported())
        { 
            // Enter full-screen mode witn an undecorated, // non-resizable JFrame object.  
            setUndecorated(true); 
            setResizable(false);  
            setAlwaysOnTop(true);
            setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
            graphicsDevice.setFullScreenWindow(this);
            AltTabStopper at = new AltTabStopper(this);
            at.create(this);
            validate();

        }
        else
        { 
            System.out.println("Full-screen mode not supported");
        }//end else 
    }//end constructor 

    //The following method is invoked when the used clicks // the loginButton 
    public void actionPerformed(ActionEvent evt)
    {
        //Restore the original display mode 
        String login = txtLogin.getText();
        System.out.println("1"+login);
        graphicsDevice1.setDisplayMode(minDisplayMode); 
        //Terminate the program 
        System.exit(0);
    }
}//end class
4

1 に答える 1

0

call txtLogin.setEditable(true) and passwordField.setEditable(true)

于 2013-09-04T19:40:30.980 に答える