From 066827381eb068bbe344194301832029fdc04e95 Mon Sep 17 00:00:00 2001 From: xuenhua Date: Tue, 17 Dec 2024 22:43:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=86=E9=9A=94=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../google/zxing/client/j2se/GUIRunner.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/com/google/zxing/client/j2se/GUIRunner.java b/src/com/google/zxing/client/j2se/GUIRunner.java index 2c1ad99..f147ba4 100644 --- a/src/com/google/zxing/client/j2se/GUIRunner.java +++ b/src/com/google/zxing/client/j2se/GUIRunner.java @@ -58,8 +58,8 @@ import javax.swing.JPanel; * * @author Sean Owen */ -//设置编码格式 Encoder.java static final String DEFAULT_BYTE_MODE_ENCODING ="UTF-8" -//设置图片大小本文件中 +//璁剧疆缂栫爜鏍煎紡 Encoder.java static final String DEFAULT_BYTE_MODE_ENCODING ="UTF-8" +//璁剧疆鍥剧墖澶у皬鏈枃浠朵腑 public final class GUIRunner extends JFrame implements ActionListener { private final JLabel imageLabel; @@ -75,17 +75,17 @@ public final class GUIRunner extends JFrame implements ActionListener { textArea.setEditable(false); // textArea.setLineWrap(true); // textArea.setMaximumSize(new Dimension(400, 200)); - label2=new JLabel("请输入要编码信息:"); + label2=new JLabel("璇疯緭鍏ヨ缂栫爜淇℃伅锛"); textArea2 =new TextArea(); // Button - sel_button = new JButton("选择图片"); + sel_button = new JButton("閫夋嫨鍥剧墖"); sel_button.addActionListener(this); - generate_button=new JButton("生成二维码"); + generate_button=new JButton("鐢熸垚浜岀淮鐮"); generate_button.addActionListener(this); Container panel = new JPanel(new GridLayout(2,1)); //panel.setLayout(new FlowLayout());//new GridLayout(2,1) - panel.add(imageLabel);//一行一列 - JPanel panel2=new JPanel(new GridLayout(4,1));//2行一列 + panel.add(imageLabel);//涓琛屼竴鍒 + JPanel panel2=new JPanel(new GridLayout(4,1));//2琛屼竴鍒 panel2.add(textArea); panel2.add(label2); panel2.add(textArea2); @@ -94,7 +94,7 @@ public final class GUIRunner extends JFrame implements ActionListener { panel3.add(generate_button); panel2.add(panel3); panel.add(panel2); - setTitle("二维码编码解码程序_Powered by Zxing (C)xuenhua"); + setTitle("浜岀淮鐮佺紪鐮佽В鐮佺▼搴廮Powered by Zxing (C)xuenhua"); setSize(420, 420); setDefaultCloseOperation(EXIT_ON_CLOSE); setContentPane(panel); @@ -112,7 +112,7 @@ public final class GUIRunner extends JFrame implements ActionListener { fileChooser.showOpenDialog(this); File file = fileChooser.getSelectedFile(); Icon imageIcon = new ImageIcon(file.toURI().toURL()); - if(imageIcon.getIconWidth()>200){//转换尺寸 + if(imageIcon.getIconWidth()>200){//杞崲灏哄 Image image=null; try { image = ImageIO.read(file); @@ -155,10 +155,10 @@ public final class GUIRunner extends JFrame implements ActionListener { @Override public void actionPerformed(ActionEvent e) { try { - if(e.getActionCommand()=="选择图片"){ + if(e.getActionCommand()=="閫夋嫨鍥剧墖"){ chooseImage(); } - if(e.getActionCommand()=="生成二维码"){ + if(e.getActionCommand()=="鐢熸垚浜岀淮鐮"){ BitMatrix bitMatrix; String str=textArea2.getText(); String user_dir=System.getProperty("user.dir"); @@ -167,16 +167,16 @@ public final class GUIRunner extends JFrame implements ActionListener { String timestamp=sfd.format(new Date()); - String path=user_dir+"\\qr-"+timestamp+ ".png"; + String path=user_dir+File.separator+"qr-"+timestamp+ ".png"; try { bitMatrix = new MultiFormatWriter().encode - (str, BarcodeFormat.QR_CODE, 200, 200);//图片大小 + (str, BarcodeFormat.QR_CODE, 200, 200);//鍥剧墖澶у皬 File file = new File(path); if(!file.exists()) { file.createNewFile(); } MatrixToImageWriter.writeToFile(bitMatrix, "png", file); - textArea.setText("二维码生成成功\n"+path); + textArea.setText("浜岀淮鐮佺敓鎴愭垚鍔焅n"+path); } catch (IOException eIO) { eIO.printStackTrace(); } catch (WriterException e1) {