Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.vladislav;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- // Главный класс, в котором расположен запускаемый метод
- public class Main {
- // Главный вызываемый метод
- public static void main(String[] args) {
- // Создание окна
- Window window = new Window();
- }
- }
- class Window extends JFrame {
- private JTextArea text;
- private void setWindow() {
- Toolkit toolkit = Toolkit.getDefaultToolkit();
- Dimension dimension = toolkit.getScreenSize();
- setBounds(0, 0, dimension.width, dimension.height);
- setMinimumSize(dimension);
- setMaximumSize(dimension);
- setUndecorated(true);
- requestFocus();
- setFocusable(true);
- toFront();
- setTitle("Blocker");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setVisible(true);
- }
- private void setContent() {
- Container container = getContentPane();
- JPanel panel = new JPanel();
- panel.setLayout(null);
- Font first = new Font("serif", 0, 40),
- second = new Font("serif", 0, 25);
- JLabel label = new JLabel("Компьютер заражён!!!");
- label.setForeground(Color.BLUE);
- label.setFont(first);
- label.setBounds(50, 0, 800, 100);
- panel.add(label);
- // Other text...
- JLabel name = new JLabel("Введите своё имя для снятия блокировки: ");
- name.setForeground(Color.BLUE);
- name.setFont(second);
- name.setBounds(50, 150, 800, 100);
- panel.add(name);
- text = new JTextArea();
- text.setFont(second);
- text.setBounds(50, 250, 300, 35);
- text.setForeground(new Color(0, 0, 128));
- text.setBackground(Color.WHITE);
- panel.add(text);
- JButton button = new JButton("Enter");
- button.setSize(150, 35);
- button.setFont(second);
- button.setLocation(50, 300);
- button.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- String string = text.getText().toLowerCase().trim(),
- result = "far__light";
- if (string.equals(result)) {
- JOptionPane.showMessageDialog(null, "Unlocked!");
- System.exit(0);
- } else {
- text.setText("Try again!");
- }
- }
- }
- );
- panel.add(button);
- container.add(panel);
- }
- Window() {
- setContent();
- setWindow();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement