怎样使jpanel标签页面中的按钮加入保存功能
怎样使jpanel标签页面中的按钮加入保存功能
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;
class MyFrame extends JFrame
{
MyFrame()
{
super("二维码生成和解码器");
setSize(500,340);
setVisible(true);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP
,JTabbedPane.SCROLL_TAB_LAYOUT);
//ImageIcon icon1=new ImageIcon("11.jpg");
//ImageIcon icon2=new ImageIcon("12.jpg");
String tip1 = "点击这里进入可以生成原始信息的加密或者不加密的二维码";
String tip2 = "点击这里可以对选择的二维码图片进行解密和解码";
tabbedPane.addTab("加密及二维码编码",null,new CodePanel(),tip1);
tabbedPane.addTab("解密及二维码解码",null,new UncodePanel(),tip2);
getContentPane().add(tabbedPane);
validate();
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
class CodePanel extends JPanel
{
CodePanel()
{
setLayout(new BorderLayout());
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
panel1.setBorder(new TitledBorder("输入原始信息"));
panel2.setBorder(new TitledBorder("加密和编码"));
panel2.setLayout(new GridLayout(5,1));
add("Center",panel1);
add("East",panel2);
TextArea ta = new TextArea("请在这里输入你的原始信息",10,20);
panel1.add(ta);
JRadioButton jrb1 = new JRadioButton("加密",true);
JRadioButton jrb2 = new JRadioButton("不加密",false);
//定义一个ButtonGroup将上面两个JRadioButton组合在一起
ButtonGroup bg = new ButtonGroup();
bg.add(jrb1);
bg.add(jrb2);
JLabel jl = new JLabel("password:");
TextField tf = new TextField("输入密码",20);
Button b1 = new Button("生成二维码");
panel2.add(jrb1);
panel2.add(jl);
panel2.add(tf);
panel2.add(jrb2);
panel2.add(b1);
}
}
class UncodePanel extends JPanel
{
UncodePanel()
{
setLayout(new BorderLayout());
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
add("North",panel1);
add("Center",panel2);
add("South",panel3);
JTextField jtf = new JTextField("请点击右键上传需要解码的二维码",20);
JButton jb = new JButton("上传图片");
panel1.add(jtf);
panel1.add(jb);
validate();
JComboBox jcfont = new JComboBox();