{"id":4186,"date":"2021-08-02T08:18:27","date_gmt":"2021-08-02T08:18:27","guid":{"rendered":"https:\/\/www.bearloga.space\/?page_id=4186"},"modified":"2021-08-02T08:18:28","modified_gmt":"2021-08-02T08:18:28","slug":"jython-obrabotka-sobytij","status":"publish","type":"page","link":"https:\/\/www.bearloga.space\/uk\/jython-obrabotka-sobytij\/","title":{"rendered":"Jython \u2014 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 Java swing \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, JButton, JList \u0438 \u0442. \u0414.) \u0411\u044b\u043b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439.&nbsp;\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u043b\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 Adapter \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d \u0441 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439.&nbsp;\u0412 Jython \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430.&nbsp;\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u0430\u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0435 click \u0432 Java.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c&nbsp;<strong>\u043f\u0430\u043a\u0435\u0442 java.awt.event<\/strong>&nbsp;.&nbsp;\u0417\u0430\u0442\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 JFrame \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ActionListener.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public class btnclick extends JFrame implements ActionListener<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 JButton, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 ContentPane \u0444\u0440\u0435\u0439\u043c\u0430 \u0438 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 ActionListener \u043c\u0435\u0442\u043e\u0434\u043e\u043c addActionListener ().<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">JButton b1 = new JButton(\"Click here\");\n   getContentPane().add(b1);\n   b1.addActionListener(this);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u0435\u0442\u043e\u0434 actionPerformed () \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 ActionListener \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 ActionEvent.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0435\u0441\u044c \u043a\u043e\u0434 Java \u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import java.awt.event.*;\nimport javax.swing.*;\npublic class btnclick extends JFrame implements ActionListener {\n   btnclick() {\n      JButton b1 = new JButton(\"Click here\");\n      getContentPane().add(b1);\n      b1.addActionListener(this);\n   }\n   \n   public void actionPerformed(ActionEvent e) {\n      System.out.println(\"Clicked\");\n   }\n   \n   public static void main(String args[]) {\n      btnclick b = new btnclick();\n      b.setSize(300,200);\n      b.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n      b.setVisible(true);\n   }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 Jython, \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0439 \u0442\u043e\u043c\u0443 \u0436\u0435 \u043a\u043e\u0434\u0443.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c ActionEvent \u0438\u043b\u0438 ActionListener, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f Jython \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043d\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u044d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u0434\u0435.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441 ActionListener.&nbsp;\u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043b\u044e\u0431\u0430\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0443 JButton \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f&nbsp;<strong>\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/strong>&nbsp;bean-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430&nbsp;<strong>actionPerformed<\/strong>&nbsp;.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">button = JButton('Click here!', actionPerformed = clickhere)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f&nbsp;<strong>clickhere ()<\/strong>&nbsp;\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f Jython, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def change_text(event):\nprint clicked!'<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412\u043e\u0442 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0439 \u043a\u043e\u0434 Jython.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from javax.swing import JFrame, JButton\n\nframe = JFrame(\"Hello\")\nframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)\nframe.setLocation(100,100)\nframe.setSize(300,200)\n\ndef clickhere(event):\n   print \"clicked\"\n\nbtn = JButton(\"Add\", actionPerformed = clickhere)\nframe.add(btn)\n\nframe.setVisible(True)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412\u044b\u0432\u043e\u0434 \u043a\u043e\u0434\u0430 Java \u0438 Jython \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u0435\u043d.&nbsp;\u041a\u043e\u0433\u0434\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \u043d\u0430\u0436\u0430\u0442\u0430, \u043e\u043d\u0430 \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u00ab\u043d\u0430\u0436\u0430\u043b\u00bb \u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u0438.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/coderlessons.com\/wp-content\/uploads\/2019\/07\/java_and_jython.png\" alt=\"Java \u0438 Jython\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043a\u043e\u0434\u0435 Jython \u0432 \u043e\u043a\u043d\u0435 JFrame \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 JTextField \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u043c\u0435\u0442\u043e\u043a \u0432 \u00abphy\u00bb \u0438 \u00abmaths\u00bb.&nbsp;\u041e\u0431\u044a\u0435\u043a\u0442 JButton \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e add () \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">btn = JButton(\"Add\", actionPerformed = add)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f add () \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0434\u0432\u0443\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u043c getText () \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u0432 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435.&nbsp;\u0417\u0430\u0442\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0440\u0435\u0442\u044c\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c setText ().<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def add(event):\n   print \"add\"\n   ttl = int(txt1.getText())+int(txt2.getText())\n   txt3.setText(str(ttl))<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043d\u0438\u0436\u0435 \u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from javax.swing import JFrame, JLabel, JButton, JTextField\nfrom java.awt import Dimension\n\nframe = JFrame(\"Hello\")\nframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)\nframe.setLocation(100,100)\nframe.setSize(300,200)\nframe.setLayout(None)\n\ndef add(event):\n   print \"add\"\n   ttl = int(txt1.getText())+int(txt2.getText())\n   txt3.setText(str(ttl))\n\nlbl1 = JLabel(\"Phy\")\nlbl1.setBounds(60,20,40,20)\ntxt1 = JTextField(10)\ntxt1.setBounds(120,20,60,20)\nlbl2 = JLabel(\"Maths\")\nlbl2.setBounds(60,50,40,20)\ntxt2 = JTextField(10)\ntxt2.setBounds(120, 50, 60,20)\nbtn = JButton(\"Add\", actionPerformed = add)\nbtn.setBounds(60,80,60,20)\nlbl3 = JLabel(\"Total\")\nlbl3.setBounds(60,110,40,20)\ntxt3 = JTextField(10)\ntxt3.setBounds(120, 110, 60,20)\n\nframe.add(lbl1)\nframe.add(txt1)\nframe.add(lbl2)\nframe.add(txt2)\nframe.add(btn)\nframe.add(lbl3)\nframe.add(txt3)\nframe.setVisible(True)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043e\u043a\u043d\u043e.\u00a0\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043e\u0446\u0435\u043d\u043a\u0438 \u0434\u043b\u044f \u00abPhy\u00bb, \u00ab\u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430\u00bb \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043a\u043d\u043e\u043f\u043a\u0443 \u00ab\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c\u00bb.\u00a0\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/coderlessons.com\/wp-content\/uploads\/2019\/07\/phy_maths.png\" alt=\"Phy Maths\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Jython JRadioButton Event<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043b\u0430\u0441\u0441 JRadioButton \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432&nbsp;<strong>\u043f\u0430\u043a\u0435\u0442\u0435 javax.swing<\/strong>&nbsp;.&nbsp;\u041e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c \u0438\u043b\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438.&nbsp;\u0415\u0441\u043b\u0438 \u0432 ButtonGroup \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u0435\u0439, \u0438\u0445 \u0432\u044b\u0431\u043e\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u043c.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 JRadioButton \u0438 \u0434\u0432\u0430 JLabels \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 Jpanel \u0432 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u043c BoxLayout.&nbsp;\u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432&nbsp;<strong>JRadioButton<\/strong>&nbsp;\u0444\u0443\u043d\u043a\u0446\u0438\u044f&nbsp;<strong>OnCheck ()<\/strong>&nbsp;\u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 actionPerformed.&nbsp;\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044f, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rb1 = JRadioButton(\"Male\", True,actionPerformed = OnCheck)\nrb2 = JRadioButton(\"Female\", actionPerformed = OnCheck)\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043b\u044f Radio Button \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 false (\u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043e).&nbsp;\u041a\u043d\u043e\u043f\u043a\u0430 rb1 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441 \u0435\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u043a\u0430\u043a True (\u0432\u044b\u0431\u0440\u0430\u043d\u043e).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0414\u0432\u0435 \u0440\u0430\u0434\u0438\u043e\u043a\u043d\u043e\u043f\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0440\u0430\u0434\u0438\u043e\u043a\u043d\u043e\u043f\u043a\u0443 ButtonGroup, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0445 \u0432\u0437\u0430\u0438\u043c\u043e\u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u043c\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0438\u0445 \u0432\u044b\u0431\u0440\u0430\u043d\u0430, \u0434\u0440\u0443\u0433\u0430\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">grp = ButtonGroup()\ngrp.add(rb1)\ngrp.add(rb2)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0438 \u0434\u0432\u0435 \u0440\u0430\u0434\u0438\u043e\u043a\u043d\u043e\u043f\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0434\u0432\u0443\u043c\u044f \u043c\u0435\u0442\u043a\u0430\u043c\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043f\u0430\u043d\u0435\u043b\u0438 \u0432 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0435 \u0441 \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f 25 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u043f\u043e \u0432\u044b\u0441\u043e\u0442\u0435 \u043c\u0435\u0436\u0434\u0443 rb2 \u0438 lbl2.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">panel = JPanel()\npanel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))\n\npanel.add(Box.createVerticalGlue())\npanel.add(lbl)\npanel.add(rb1)\npanel.add(rb2)\npanel.add(Box.createRigidArea(Dimension(0,25)))\npanel.add(lbl1)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430 \u043f\u0430\u043d\u0435\u043b\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 JFrame \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e visible \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 True.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">frame = JFrame(\"JRadioButton Example\")\nframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)\nframe.setLocation(100,100)\nframe.setSize(250,200)\nframe.setVisible(True)\nThe complete code of radio.py is given below:\nfrom javax.swing import JFrame, JPanel, JLabel, BoxLayout, Box\n\nfrom java.awt import Dimension\nfrom javax.swing import JRadioButton,ButtonGroup\nframe = JFrame(\"JRadioButton Example\")\nframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)\nframe.setLocation(100,100)\nframe.setSize(250,200)\npanel = JPanel()\npanel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))\nframe.add(panel)\n\ndef OnCheck(event):\n   lbl1.text = \"\"\n   if rb1.isSelected():\n      lbl1.text = lbl1.text+\"Gender selection : Male\"\n   else:\n      lbl1.text = lbl1.text+\"Gender selection : Female \"\n      lbl = JLabel(\"Select Gender\")\n\nrb1 = JRadioButton(\"Male\", True,actionPerformed = OnCheck)\nrb2 = JRadioButton(\"Female\", actionPerformed = OnCheck)\ngrp = ButtonGroup()\ngrp.add(rb1)\ngrp.add(rb2)\n\nlbl1 = JLabel(\"Gender Selection :\")\n\npanel.add(Box.createVerticalGlue())\npanel.add(lbl)\npanel.add(rb1)\npanel.add(rb2)\npanel.add(Box.createRigidArea(Dimension(0,25)))\npanel.add(lbl1)\n\nframe.setVisible(True)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 Jython \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0432\u044b\u0431\u043e\u0440 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u0435\u0439.&nbsp;\u0412\u044b\u0431\u043e\u0440 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043d\u0430 \u044f\u0440\u043b\u044b\u043a\u0435 \u0432\u043d\u0438\u0437\u0443.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/coderlessons.com\/wp-content\/uploads\/2019\/07\/jradiobutton.png\" alt=\"JRadioButton\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Jython JCheckBox Event<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u0430\u043a \u0438&nbsp;<strong>JRadioButton<\/strong>&nbsp;, \u043e\u0431\u044a\u0435\u043a\u0442 JCheckBox \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u0441 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u044b\u043c \u0444\u043b\u0430\u0436\u043a\u043e\u043c, \u043f\u043e\u043c\u0438\u043c\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430.&nbsp;\u042d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0432\u0430 \u0444\u043b\u0430\u0436\u043a\u0430 \u0438 \u043c\u0435\u0442\u043a\u0430 \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 \u0441\u0432\u0438\u043d\u0433\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 JPanel \u0432 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u043c BoxLayout.&nbsp;\u041c\u0435\u0442\u043a\u0430 \u0432\u043d\u0438\u0437\u0443 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u0434\u0432\u0443\u0445 \u0444\u043b\u0430\u0436\u043a\u043e\u0432.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041e\u0431\u0430 \u0444\u043b\u0430\u0436\u043a\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u0441 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c, \u0438\u043c\u0435\u044e\u0449\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e actionPerformed, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0432&nbsp;<strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044e OnCheck ()<\/strong>&nbsp;.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">box1 = JCheckBox(\"Check1\", actionPerformed = OnCheck)\nbox2 = JCheckBox(\"Check2\", actionPerformed = OnCheck)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f OnCheck () \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u043b\u0430\u0436\u043a\u0430 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u044f\u0440\u043b\u044b\u043a\u0435 \u0432\u043d\u0438\u0437\u0443.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def OnCheck(event):\n   lbl1.text = \"\"\n   if box1.isSelected():\n      lbl1.text = lbl1.text + \"box1 selected \"\n   else:\n      lbl1.text = lbl1.text + \"box1 not selected \"\n   if box2.isSelected():\n      lbl1.text = lbl1.text + \"box2 selected\"\n   else:\n      lbl1.text = lbl1.text + \"box2 not selected\"<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0438 \u043f\u043e\u043b\u044f \u0438 \u043e\u0431\u044a\u0435\u043a\u0442 JLabel \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 JPanel, \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u0435\u043b \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 50 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">panel = JPanel()\npanel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))\npanel.add(Box.createVerticalGlue())\npanel.add(box1)\npanel.add(box2)\npanel.add(Box.createRigidArea(Dimension(0,50)))\npanel.add(lbl1)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u0430\u043c\u0430 \u043f\u0430\u043d\u0435\u043b\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043e\u043a\u043d\u043e JFrame \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e visible \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 true.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">frame = JFrame(\"JCheckBox Example\")\nframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)\nframe.setLocation(100,100)\nframe.setSize(250,150)\nframe.add(panel)\n\nframe.setVisible(True)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u0434 \u0438 \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u0444\u043b\u0430\u0436\u043a\u043e\u0432.&nbsp;\u041c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0431\u043e\u0438\u0445 \u0444\u043b\u0430\u0436\u043a\u043e\u0432 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432\u043d\u0438\u0437\u0443.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/coderlessons.com\/wp-content\/uploads\/2019\/07\/check_box.png\" alt=\"\u0424\u043b\u0430\u0436\u043e\u043a\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Jython JList Event<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f JList \u0432 \u0441\u0432\u0438\u043d\u0433-\u043f\u0430\u043a\u0435\u0442\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438.&nbsp;JComboBox \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.&nbsp;\u0412 Java \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0442\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 valueChanged () \u0432 ListSelectionListener.&nbsp;\u0412 Jython \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 valueChanged \u043e\u0431\u044a\u0435\u043a\u0442\u0430 JList.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 JList \u0438 \u043c\u0435\u0442\u043a\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 JFrame \u0432 BorderLayout.&nbsp;JList \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0435\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u0435.&nbsp;\u0415\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e valueChanged \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e listSelect ().<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">lang = (\"C\", \"C++\", \"Java\", \"Python\", \"Perl\", \"C#\", \"VB\", \"PHP\", \"Javascript\", \"Ruby\")\nlst = JList(lang, valueChanged = listSelect)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 JList \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043c\u0435\u0442\u043a\u0435 \u0432\u043d\u0438\u0437\u0443.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def listSelect(event):\n   index = lst.selectedIndex\n   lbl1.text = \"Hello\" + lang[index]<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041e\u0431\u044a\u0435\u043a\u0442\u044b JList \u0438 JLabel \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 JFrame \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e BorderLayout.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043d\u0438\u0436\u0435 \u2014<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from javax.swing import JFrame, JPanel, JLabel, JList\nfrom java.awt import BorderLayout\n\nframe = JFrame(\"JList Example\")\nframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)\nframe.setLocation(100,100)\nframe.setSize(300,250)\n\nframe.setLayout(BorderLayout())\n\ndef listSelect(event):\n   index = lst.selectedIndex\n   lbl1.text = \"Hello\" + lang[index]\n\nlang = (\"C\", \"C++\", \"Java\", \"Python\", \"Perl\", \"C#\", \"VB\", \"PHP\", \"Javascript\", \"Ruby\")\nlst = JList(lang, valueChanged = listSelect)\nlbl1 = JLabel(\"box1 not selected box2 not selected\")\nframe.add(lst, BorderLayout.NORTH)\nframe.add(lbl1, BorderLayout.SOUTH)\n\nframe.setVisible(True)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 Java swing \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, JButton, JList \u0438 \u0442. \u0414.) \u0411\u044b\u043b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u043c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[129],"tags":[],"class_list":["post-4186","page","type-page","status-publish","hentry","category-jython"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/4186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/comments?post=4186"}],"version-history":[{"count":0,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/4186\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/media?parent=4186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/categories?post=4186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/tags?post=4186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}