Exemple #1
0
  public void createGUI() {
    setLayout(new BorderLayout());
    JPanel topPan = new JPanel(new BorderLayout());
    //        topPan.setBorder(BorderFactory.createRaisedSoftBevelBorder());
    JPanel topCentPan = new JPanel();
    JLabel titleLab = new JLabel();
    titleLab.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 15));
    topCentPan.add(titleLab);

    JPanel topRightPan = new JPanel();
    //        Cursor handCursor = new Cursor(Cursor.HAND_CURSOR);
    replyBut = new JButton(new ImageIcon("src\\images\\replyIcon.png"));
    replyBut.setBorder(BorderFactory.createEmptyBorder());
    replyBut.addActionListener(this);
    replyBut.setCursor(new Cursor(Cursor.HAND_CURSOR));
    replyBut.setToolTipText("Reply");
    replyBut.setContentAreaFilled(false);
    replyBut.setRolloverEnabled(true);
    forwardBut = new JButton(new ImageIcon("src\\images\\forwardIcon.png"));
    forwardBut.setBorder(BorderFactory.createEmptyBorder());
    forwardBut.addActionListener(this);
    forwardBut.setCursor(new Cursor(Cursor.HAND_CURSOR));
    forwardBut.setToolTipText("Forward");
    forwardBut.setContentAreaFilled(false);
    forwardBut.setRolloverEnabled(true);
    topRightPan.add(replyBut);
    topRightPan.add(forwardBut);
    topPan.add(topCentPan, "Center");
    topPan.add(topRightPan, "East");

    JPanel centPan = new JPanel(new BorderLayout());
    JPanel centTopPan = new JPanel(new BorderLayout());
    JPanel centTopLeftPan = new JPanel();
    JLabel fromLab = new JLabel();
    fromLab.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    JTextArea contentTA = new JTextArea();
    //            JEditorPane contentTA = new JEditorPane(JEditorPane.W3C_LENGTH_UNITS,"");
    contentTA.setLineWrap(true);
    contentTA.setEditable(false);
    centTopLeftPan.add(fromLab);
    JPanel centTopRightPan = new JPanel();
    JLabel dateLab = new JLabel();
    dateLab.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    centTopRightPan.add(dateLab);
    centTopPan.add(centTopLeftPan, "West");
    centTopPan.add(centTopRightPan, "East");
    centPan.add(centTopPan, "North");
    centPan.add(new JScrollPane(contentTA), "Center");

    add(topPan, "North");
    add(centPan, "Center");

    try {
      workingSet.absolute(pointer + 1);
      msgID = Home.bodyPan.msgID[pointer];
      titleLab.setText(workingSet.getString("subject"));
      fromLab.setText("From: " + workingSet.getString("mail_addresses"));
      dateLab.setText(workingSet.getString("sent_date"));
      contentTA.setText(workingSet.getString("content"));
    } catch (SQLException sqlExc) {
      JOptionPane.showMessageDialog(this, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE);
    }
    Home.bodyPan.remove(Home.bodyPan.contentPan);
    Home.bodyPan.contentPan = new JScrollPane(this);
    Home.bodyPan.add(Home.bodyPan.contentPan);
    Home.home.homeFrame.setVisible(true);
  }
  public LoginPanel(Image img, ActionListener listener) {
    super(null);
    this.listener = listener;
    if (img == null) {
      InputStream inData = getClass().getResourceAsStream("/resources/background.gif");
      BufferedImage back = null;
      if (inData != null)
        try {
          back = ImageIO.read(inData);
        } catch (IOException e) {
          loger.finest("LoginPanel class can't get the background image");
        }
      this.background = back;
    }

    setLayout(null);
    JPanel logingPanel = new JPanel();
    loginTitle = new JLabel("Autentificare");
    logingPanel.setSize(250, 150);
    logingPanel.setBorder(new javax.swing.border.LineBorder(Color.black, 2));
    logingPanel.setLayout(null);
    loginTitle.setBounds(3, 0, logingPanel.getWidth(), 20);
    logingPanel.add(loginTitle);
    JLabel loginUser = new JLabel("Utilizator");
    loginUser.setBounds(
        80 - loginUser.getPreferredSize().width,
        40,
        loginUser.getPreferredSize().width,
        loginUser.getPreferredSize().height);
    logingPanel.add(loginUser);
    user = new JTextField(10);
    user.setBounds(85, 40, user.getPreferredSize().width, user.getPreferredSize().height);
    // user.setText("test");
    // loginUser.setLabelFor(user);
    logingPanel.add(user);
    JLabel loginPass = new JLabel("Parola");
    loginPass.setBounds(
        80 - loginPass.getPreferredSize().width,
        80,
        loginPass.getPreferredSize().width,
        loginPass.getPreferredSize().height);
    logingPanel.add(loginPass);
    // JTextField pass = new JTextField(10);
    pass = new JPasswordField(10);
    pass.setBounds(85, 80, pass.getPreferredSize().width, pass.getPreferredSize().height);
    pass.addKeyListener(this);
    // pass.setText("test");
    // loginUser.setLabelFor(user);
    logingPanel.add(pass);
    JButton loginButton = new JButton("Start");
    loginButton.setActionCommand("LOGIN");
    loginButton.setBounds(
        60, 110, loginButton.getPreferredSize().width, loginButton.getPreferredSize().height);
    // loginButton.setOpaque(false);
    loginButton.setFocusPainted(false);
    // loginButton.setContentAreaFilled(false);
    // loginButton.setBorderPainted(false);
    loginButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    loginButton.addActionListener(listener);
    logingPanel.add(loginButton);

    add(logingPanel);
  }