|
|
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
//使用AWT和SWING包内的东西
public class converter extends JFrame implements ActionListener
{
private static final double Aues = 0;
private JLabel prompt1 = new JLabel("加密密码");
private JLabel prompt2 = new JLabel("解密密码");
private JLabel prompt3 = new JLabel("加密文件");
private JLabel prompt4 = new JLabel("解密文件路径");
private JTextField input1= new JTextField(12);
private JTextField input2= new JTextField(12);
private JTextField input3= new JTextField(12);
private JTextField input4= new JTextField(12);
private JTextArea display = new JTextArea (10,20);
private JButton convert1 = new JButton("加密");
private JButton convert2 = new JButton("解密");
//声明
//实例化
public converter()
{
JPanel inputPanel1 = new JPanel();
inputPanel1.add(prompt1);
inputPanel1.add(prompt2);
inputPanel1.add(prompt3);
inputPanel1.add(prompt4);
JPanel inputPanel2 = new JPanel();
inputPanel2.add(input1);
inputPanel2.add(input2);
inputPanel2.add(input3);
inputPanel2.add(input4);
JPanel inputPanel0 = new JPanel();
inputPanel0.add(inputPanel1);
inputPanel0.add(inputPanel2);
inputPanel1.setLayout(new BoxLayout(inputPanel1,BoxLayout.Y_AXIS));
inputPanel2.setLayout(new BoxLayout(inputPanel2,BoxLayout.Y_AXIS));
inputPanel2.setLayout(new BoxLayout(inputPanel0,BoxLayout.X_AXIS));
getContentPane().setLayout(new FlowLayout());
getContentPane().add(prompt1);
getContentPane().add(prompt2);
getContentPane().add(prompt3);
getContentPane().add(prompt4);
getContentPane().add(input1);
getContentPane().add(input2);
getContentPane().add(input3);
getContentPane().add(input4);
getContentPane().add(convert1);
getContentPane().add(convert2);
getContentPane().add(display);
display.setLineWrap(true);
display.setEditable(false);
convert2.addActionListener(this);
convert1.addActionListener(this);
input1.addActionListener(this);
input2.addActionListener(this);
}//Converter()
小弟毕业设计是个系统。需要做个操作界面。但是我编译没问题。就是JPANEL不能起组合组件效果。
JPanel inputPanel1 = new JPanel();
inputPanel1.add(prompt1);
inputPanel1.add(prompt2);
inputPanel1.add(prompt3);
inputPanel1.add(prompt4);
JPanel inputPanel2 = new JPanel();
inputPanel2.add(input1);
inputPanel2.add(input2);
inputPanel2.add(input3);
inputPanel2.add(input4);
JPanel inputPanel0 = new JPanel();
inputPanel0.add(inputPanel1);
inputPanel0.add(inputPanel2);
inputPanel1.setLayout(new BoxLayout(inputPanel1,BoxLayout.Y_AXIS));
inputPanel2.setLayout(new BoxLayout(inputPanel2,BoxLayout.Y_AXIS));
inputPanel2.setLayout(new BoxLayout(inputPanel0,BoxLayout.X_AXIS));
这我想做4个组合按键,按键按Y轴排,LABEL也按Y轴排。最后这2个PANEL按X轴排。
我编译出来的效果却不是这样的。和没写这些代码的效果一样。
请大仙解决下
|
|