Esempio n. 1
0
 public void mouseDragged(MouseEvent e) {
   // System.out.println("Dragged");
   double beatWidth = sp.beatWidth;
   beatWidth += (double) ((double) e.getX() - (double) startX) / 5.0;
   if (beatWidth < 1.0) beatWidth = 1.0;
   if (beatWidth > 256.0) beatWidth = 256.0;
   // System.out.println("beatWidth = "+beatWidth);
   sp.beatWidth = beatWidth;
   startX = e.getX();
   // sp.update();
   this.repaint();
 }
  public HideInfoPanel() {
    // 初始化
    this.isHideMode = true; // 默认隐藏模式
    this.setLayout(null); // 使用坐标方式指定各个按钮的位置
    this.mt = new MediaTracker(this);
    jfc = new JFileChooser(); // 文件选择器
    this.im = Toolkit.getDefaultToolkit().getImage("resource/background.jpg"); // 载入背景
    mt.addImage(this.im, 1); // 把Image类的对象image添加到当前媒体跟踪器要追踪的图像列表中,整型对象id表示该image的标识
    try {
      mt.waitForID(1); // 跟踪多媒体文件
    } catch (InterruptedException e) {
    }
    this.setVisible(true);

    this.bFile1 = new JButton("选择原图像"); // 显示的字样 (按钮)
    this.bFile1.setBounds(70, 75, 120, 35); // 位置和大小
    this.bFile1.setFont(new Font("宋体", Font.BOLD, 12)); // 字体
    this.bFile1.setOpaque(true); // 透明
    this.bFile1.setForeground(Color.black); // 字体颜色
    this.bFile1.setBackground(new Color(240, 255, 240)); // 按钮背景色
    this.bFile1.addActionListener(this); // 如果这个按钮被按动,事件将被发送到本类下面的处理函数中
    this.add(bFile1);

    this.bFile2 = new JButton("选择隐藏信息");
    this.bFile2.setBounds(70, 120, 120, 35);
    this.bFile2.setFont(new Font("宋体", Font.BOLD, 12));
    this.bFile2.setOpaque(true);
    this.bFile2.setForeground(Color.black);
    this.bFile2.setBackground(new Color(240, 255, 240));
    this.bFile2.addActionListener(this);
    this.add(bFile2);

    this.bFile3 = new JButton("选择目标图像");
    this.bFile3.setBounds(70, 165, 120, 35);
    this.bFile3.setFont(new Font("宋体", Font.BOLD, 12));
    this.bFile3.setOpaque(true);
    this.bFile3.setForeground(Color.black);
    this.bFile3.setBackground(new Color(240, 255, 240));
    this.bFile3.addActionListener(this);
    this.add(bFile3);

    this.bOp = new JButton("开始隐藏");
    this.bOp.setBounds(70, 220, 120, 100);
    this.bOp.setFont(new Font("宋体", Font.BOLD, 12));
    this.bOp.setOpaque(true);
    this.bOp.setForeground(Color.black);
    this.bOp.setBackground(new Color(240, 255, 240));
    this.bOp.addActionListener(this);
    this.add(bOp);

    this.bMode = new JButton("切换模式");
    this.bMode.setBounds(70, 340, 120, 80);
    this.bMode.setFont(new Font("宋体", Font.BOLD, 12));
    this.bMode.setOpaque(true);
    this.bMode.setForeground(Color.black);
    this.bMode.setBackground(new Color(240, 255, 240));
    this.bMode.addActionListener(this);
    this.add(bMode);

    this.tag1 = new JLabel("路径:");
    this.tag1.setBounds(250, 75, 40, 35);
    this.tag1.setFont(new Font("宋体", Font.PLAIN, 14));
    this.tag1.setForeground(Color.black);
    this.add(this.tag1);

    this.tag2 = new JLabel("路径:");
    this.tag2.setBounds(250, 120, 40, 35);
    this.tag2.setFont(new Font("宋体", Font.PLAIN, 14));
    this.tag2.setForeground(Color.black);
    this.add(this.tag2);

    this.tag3 = new JLabel("路径:");
    this.tag3.setBounds(250, 165, 40, 35);
    this.tag3.setFont(new Font("宋体", Font.PLAIN, 14));
    this.tag3.setForeground(Color.black);
    this.add(this.tag3);

    this.status = new JLabel("当前模式:信息隐藏模式");
    this.status.setBounds(490, 450, 680, 30);
    this.status.setHorizontalAlignment(SwingConstants.LEFT); // 左对齐
    this.status.setFont(new Font("宋体", Font.ITALIC, 16));
    this.status.setForeground(Color.black);
    this.status.setOpaque(false);
    this.add(this.status);

    this.pathFile1 = new JTextField(100);
    this.pathFile1.setBounds(300, 75, 490, 35);
    this.pathFile1.setFont(new Font("宋体", Font.PLAIN, 12));
    this.pathFile1.setEditable(false); // 不可编辑
    this.pathFile1.setOpaque(false); // 透明
    this.pathFile1.setBorder(null); // 无边框
    this.add(this.pathFile1);

    this.pathFile2 = new JTextField(100);
    this.pathFile2.setBounds(300, 120, 490, 35);
    this.pathFile2.setFont(new Font("宋体", Font.PLAIN, 12));
    this.pathFile2.setEditable(false);
    this.pathFile2.setOpaque(false);
    this.pathFile2.setBorder(null);
    this.add(this.pathFile2);

    this.pathFile3 = new JTextField(100);
    this.pathFile3.setBounds(300, 165, 490, 35);
    this.pathFile3.setFont(new Font("宋体", Font.PLAIN, 12));
    this.pathFile3.setEditable(false);
    this.pathFile3.setOpaque(false);
    this.pathFile3.setBorder(null);
    this.add(this.pathFile3);

    this.show1 = new ShowPanel();
    this.show1.setBorder(
        new TitledBorder(
            new LineBorder(new Color(69, 167, 116)),
            "隐藏前的图像",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_POSITION,
            new Font("宋体", Font.PLAIN, 12),
            Color.black));
    this.show1.setBounds(250, 200, 320, 230);
    this.show1.setBackground(Color.WHITE);
    this.show1.setOpaque(true);
    this.add(this.show1);
    show1.repaint();

    this.show2 = new ShowPanel();
    this.show2.setBorder(
        new TitledBorder(
            new LineBorder(new Color(69, 167, 116)),
            "隐藏后的图像",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_POSITION,
            new Font("宋体", Font.PLAIN, 12),
            Color.black)); // 带有标题的边框
    this.show2.setBounds(600, 200, 320, 230);
    this.show2.setBackground(Color.WHITE);
    this.show2.setOpaque(true);
    this.add(this.show2);
    show2.repaint();

    this.repaint();
  }
Esempio n. 3
0
 public void mouseReleased(MouseEvent e) {
   this.setCursor(new Cursor(13));
   sp.update();
 }