Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Zadachi;
- import java.awt.EventQueue;
- import javax.swing.*;
- import java.awt.*;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import javax.swing.JTextField;
- import javax.swing.JButton;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import javax.swing.JLabel;
- import javax.swing.JTextArea;
- public class StepeniNa2 {
- private JFrame frame;
- private JTextField textField1;
- private JTextField textField2;
- private JLabel lblNewLabel;
- private JLabel lblNewLabel_1;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- StepeniNa2 window = new StepeniNa2();
- window.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- */
- public StepeniNa2() {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- private void initialize() {
- frame =new JFrame();
- frame.setTitle("\u0421\u0442\u0435\u043F\u0435\u043D\u0438 \u043D\u0430 \u0447\u0438\u0441\u043B\u043E\u0442\u043E 2");
- frame.setBounds(100, 100, 450, 190);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().setLayout(null);
- textField1 = new JTextField();
- textField1.setBounds(10, 49, 103, 20);
- frame.getContentPane().add(textField1);
- textField1.setColumns(10);
- textField2 = new JTextField();
- textField2.setText("");
- textField2.setBounds(154, 49, 103, 20);
- frame.getContentPane().add(textField2);
- textField2.setColumns(10);
- JTextArea textArea = new JTextArea();
- textArea.setBounds(27, 104, 380, 28);
- frame.getContentPane().add(textArea);
- JButton btnNewButton = new JButton("\u041F\u0440\u0435\u0441\u043C\u0435\u0442\u043D\u0438");
- btnNewButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- int a=Integer.parseInt(textField1.getText());
- int b=Integer.parseInt(textField2.getText());
- for (int i=a; i <b+1; i ++) {
- if (i>0&&i==Math.pow(2,Math.round(Math.log(i)/Math.log(2)))) {
- textArea.setText(textArea.getText()+" "+Integer.toString(i));
- }
- }
- }
- });
- btnNewButton.setBounds(318, 48, 89, 23);
- frame.getContentPane().add(btnNewButton);
- lblNewLabel = new JLabel("\u041D\u0430\u0447\u0430\u043B\u043E \u043D\u0430 \u0438\u043D\u0442\u0435\u0440\u0432\u0430\u043B\u0430");
- lblNewLabel.setBounds(10, 18, 123, 20);
- frame.getContentPane().add(lblNewLabel);
- lblNewLabel_1 = new JLabel("\u041A\u0440\u0430\u0439 \u043D\u0430 \u0438\u043D\u0442\u0435\u0440\u0432\u0430\u043B\u0430");
- lblNewLabel_1.setBounds(154, 21, 134, 14);
- frame.getContentPane().add(lblNewLabel_1);
- }
- }
Add Comment
Please, Sign In to add comment