Those years, learn together Java 9-1

Source: Internet
Author: User

1.import java.awt.flowlayout;import java.awt.gridlayout;import java.awt.menu;import  java.awt.menubar;import java.awt.menuitem;import java.awt.event.actionevent;import  java.awt.event.actionlistener;import java.awt.event.windowadapter;import java.awt.event.windowevent; import javax.swing.jbutton;import javax.swing.jframe;import javax.swing.jlabel;import  Javax.swing.jpanel;import javax.swing.jtextfield;public class test {public static  void main  (String[] args) {final jframe test= new jframe ();// Test.setsize (300,100); Test.setlayout (New flowlayout (flowlayout.left)); Jpanel pan1 = new jpanel (New gridlayout (5,1)); Jlabel lab1 = new jlabel ("decimal");final jtextfield text1 = new  JTextField ("-1", 32); Jlabel lab2 = new jlabel ("binary"); FINAL JTEXTFIELD TEXT2 = NEW&NBSp JTextField ("11111111111111111111111111111111", 32); Jlabel lab3 = new jlabel ("octal");final jtextfield text3 = new  JTextField ("37777777777", 32); Jlabel lab4 = new jlabel ("hex");final jtextfield text4 = new  JTextField ("ffffffff"), Final jbutton but1 = new jbutton ("conversion"); But1.addactionlistener (New actionlistener ()  {@Overridepublic  void actionperformed ( Actionevent e)  {// TODO Auto-generated method stubif  (E.getsource ()  ==  BUT1) {Int n = integer.parseint (Text1.gettext ()); Text2.settext (Integer.toBinaryString (n));          text3.settext (integer.tooctalstring (n));         text4.settext (integer.tohexstring (n));}}); Pan1.add (LAB1);p an1.add (Text1);p an1.add (LAB2);p an1.add (text2);p an1.add (LAB3);p an1.add (TEXT3);p an1.add (LAB4);Pan1.add (TEXT4); Test.add (pan1); Test.add (BUT1); test.setvisible (true); Test.pack ();}} 


This article is from the "hacker" blog, make sure to keep this source http://anglecode.blog.51cto.com/5628271/1619875

Those years, learn together Java 9-1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.