package com.main; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import com.util.ASCIIAndHEX; import javax.swing.JButton; import javax.swing.JLabel; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.ActionEvent; /** * ASCII与16进制互转 * @author cyw * @time 2018-08-14 * */ @SuppressWarnings("serial") public class ASCIIWithHEXJframe extends JFrame { private JPanel contentPane; private JTextArea Sixty,ASCII; private boolean flag = true;//判断是否第一次打开 /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { ASCIIWithHEXJframe frame = new ASCIIWithHEXJframe(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public ASCIIWithHEXJframe() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 380); setTitle("ASCII与16进制转换"); contentPane = new JPanel(); init(); this.setLocationRelativeTo(null);//居中显示 this.setResizable(false); } private void init() { // TODO Auto-generated method stub Sixty = new JTextArea("请输入需要转换的16进制字符串"); Sixty.setBounds(0, 0, 444, 150); Sixty.setLineWrap(true); //激活自动换行功能 Sixty.setWrapStyleWord(true); // 激活断行不断字功能 ASCII = new JTextArea("请输入需要转换的ASCII字符串"); ASCII.setBounds(0, 192, 444, 150); ASCII.setLineWrap(true); //激活自动换行功能 ASCII.setWrapStyleWord(true); // 激活断行不断字功能 ASCII.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub if(flag==true) { ASCII.setText(""); Sixty.setText(""); flag = false; } } }); Sixty.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub if(flag==true) { ASCII.setText(""); Sixty.setText(""); flag = false; } } }); JScrollPane p1 = new JScrollPane(Sixty); p1.setSize(445, 150); JScrollPane p2 = new JScrollPane(ASCII); p2.setSize(445, 150); p2.setLocation(0, 180); contentPane.setLayout(null); contentPane.add(p1); contentPane.add(p2); setContentPane(contentPane); JButton btnNewButton = new JButton("\u8F6CASCII"); btnNewButton.addActionListener(new ActionListener() { @SuppressWarnings("static-access") public void actionPerformed(ActionEvent e) { String s = Sixty.getText().trim(); ASCIIAndHEX ah = new ASCIIAndHEX(); if(s.length()>0) { ASCII.setText(ah.toASCII(s));//转ASCII } } }); btnNewButton.setBounds(90, 155, 93, 20); contentPane.add(btnNewButton); JLabel lblCopyright = new JLabel("Copyright\u00AEcyw 2018",JLabel.CENTER); lblCopyright.setBounds(0, 332, 445, 20); contentPane.add(lblCopyright); JButton button = new JButton("\u8F6C16\u8FDB\u5236"); button.addActionListener(new ActionListener() { @SuppressWarnings("static-access") @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub String asc = ASCII.getText().trim(); ASCIIAndHEX ah = new ASCIIAndHEX(); if(asc.length()>0) { Sixty.setText(ah.toHex(asc));//转16进制 } } }); button.setBounds(256, 155, 93, 20); contentPane.add(button); } }
最近下载更多
wadadd LV7
2022年9月5日
756398953 LV12
2020年10月13日
古月剑独孤镖 LV3
2019年5月24日
904311498 LV1
2019年5月5日
vegetablebirds LV1
2019年3月7日
xie5461246464 LV6
2018年12月17日
谭鬼鬼 LV48
2018年8月15日