0

Hello Guys JPasswordField (JPasswordFieldAnon) に書き込みたいパスワードが必要で、submit アクションを 2 つの JButton (AnonButton と AnonButton1) にアタッチします。

コードは次のとおりです。

package javafx;

import java.awt.*;

import javax.swing.*;

import java.awt.event.ActionEvent;

public class Anonymous {

private JFrame frame;

/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Anonymous window = new Anonymous();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the application.
 */
public Anonymous() {
    initialize();
}

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 450, 300);
    frame.setTitle("Anonymous Terminal. Enter Password");
    frame.setResizable(false);
    frame.setVisible(true);
    frame.setSize(952, 785);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);

    JLabel JLabelAnon = new JLabel("We are Anonymous. We are Legion. We do not forgive. We do not forget. Expect Us.");
    JLabelAnon.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    JLabelAnon.setBackground(Color.BLACK);
    JLabelAnon.setFont(new Font("hooge 05_53", Font.PLAIN, 13));
    JLabelAnon.setForeground(Color.GREEN);
    JLabelAnon.setBounds(116, 566, 695, 14);
    frame.getContentPane().add(JLabelAnon);

    JPasswordField JPasswordFieldAnon = new JPasswordField("Enter Password: ", 1);
    JPasswordFieldAnon.setBackground(new Color(0, 128, 0));
    JPasswordFieldAnon.setToolTipText("Enter Password\r\n");
    JPasswordFieldAnon.setText("");
    JPasswordFieldAnon.setName("Anonymous Password");
    JPasswordFieldAnon.setBounds(367, 535, 206, 22);
    frame.getContentPane().add(JPasswordFieldAnon);

    JButton AnonButton = new JButton("Expect Us!");
    AnonButton.setBackground(new Color(34, 139, 34));
    AnonButton.setName("Log In");
    AnonButton.setBounds(579, 535, 115, 22);
    frame.getContentPane().add(AnonButton);

    JButton AnonButton1 = new JButton("Expect Us!");
    AnonButton1.setName("Log In");
    AnonButton1.setBackground(new Color(34, 139, 34));
    AnonButton1.setBounds(246, 535, 115, 22);
    frame.getContentPane().add(AnonButton1);

    JTextPane textPane1 = new JTextPane();
    textPane1.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    textPane1.setEditable(false);
    textPane1.setBackground(Color.BLACK);
    textPane1.setBounds(108, 563, 703, 20);
    frame.getContentPane().add(textPane1);

    JLabel lblNewLabel = new JLabel("");
    lblNewLabel.setIcon(new ImageIcon("F:\\FBI-Terminal_1.png"));
    lblNewLabel.setBounds(0, 0, 948, 759);
    frame.getContentPane().add(lblNewLabel);

}


    public void actionPerformed(ActionEvent e) {
    }
}

私の問題は、多くの方法を試しただけで約5日間試したことです...

4

1 に答える 1