首页 > 编程知识 正文

简单java留言板(JAVA留言板)

时间:2023-12-22 11:30:28 阅读:318969 作者:JKZW

本文目录一览:

急急急!java简单留言板

您好。我重新地帮你写了代码,完全地符合了你的图片中的界面要求、功能要求。代码如下:(解决了问题,记得给我分哦~^_^呵呵……)

import java.awt.BorderLayout;

import javax.swing.JPanel;

import javax.swing.JFrame;

import java.awt.Rectangle;

import javax.swing.JLabel;

import javax.swing.SwingConstants;

import java.awt.Font;

import javax.swing.JTextArea;

import javax.swing.JScrollBar;

import javax.swing.JScrollPane;

import javax.swing.JComboBox;

import javax.swing.JTextField;

import javax.swing.JButton;

public class Liuyb extends JFrame {

private static final long serialVersionUID = 1L;

private JPanel jContentPane = null;

private JLabel jLabel = null;

private JTextArea jTextArea = null;

private JScrollPane jScrollPane = null;

private JLabel jLabel1 = null;

private JComboBox jComboBox = null;

private JLabel jLabel2 = null;

private JTextField jTextField = null;

private JButton jButton = null;

private JButton jButton1 = null;

private JButton jButton2 = null;

private JButton jButton3 = null;

/**

* This is the default constructor

*/

public Liuyb() {

super();

initialize();

}

/**

* This method initializes this

*

* @return void

*/

private void initialize() {

this.setContentPane(getJContentPane());

this.setTitle("留言板程序");

this.setBounds(new Rectangle(0, 0, 640, 480));

this.setVisible(true);

}

/**

* This method initializes jContentPane

*

* @return javax.swing.JPanel

*/

private JPanel getJContentPane() {

if (jContentPane == null) {

jLabel2 = new JLabel();

jLabel2.setBounds(new Rectangle(214, 407, 45, 24));

jLabel2.setFont(new Font("Dialog", Font.BOLD, 14));

jLabel2.setText("地说:");

jLabel1 = new JLabel();

jLabel1.setBounds(new Rectangle(32, 407, 15, 24));

jLabel1.setFont(new Font("Dialog", Font.BOLD, 14));

jLabel1.setText("你");

jLabel = new JLabel();

jLabel.setBounds(new Rectangle(283, 15, 45, 20));

jLabel.setHorizontalAlignment(SwingConstants.CENTER);

jLabel.setFont(new Font("Dialog", Font.BOLD, 14));

jLabel.setText("留言板");

jContentPane = new JPanel();

jContentPane.setLayout(null);

jContentPane.add(jLabel, null);

jContentPane.add(getJScrollPane(), null);

jContentPane.add(jLabel1, null);

jContentPane.add(getJComboBox(), null);

jContentPane.add(jLabel2, null);

jContentPane.add(getJTextField(), null);

jContentPane.add(getJButton(), null);

jContentPane.add(getJButton1(), null);

jContentPane.add(getJButton2(), null);

jContentPane.add(getJButton3(), null);

}

return jContentPane;

}

/**

* This method initializes jTextArea

*

* @return javax.swing.JTextArea

*/

private JTextArea getJTextArea() {

if (jTextArea == null) {

jTextArea = new JTextArea();

jTextArea.setText("留言内容:");

jTextArea.setEditable(false);

}

return jTextArea;

}

/**

* This method initializes jScrollPane

*

* @return javax.swing.JScrollPane

*/

private JScrollPane getJScrollPane() {

if (jScrollPane == null) {

jScrollPane = new JScrollPane();

jScrollPane.setBounds(new Rectangle(22, 49, 534, 347));

jScrollPane.setViewportView(getJTextArea());

}

return jScrollPane;

}

/**

* This method initializes jComboBox

*

* @return javax.swing.JComboBox

*/

private JComboBox getJComboBox() {

if (jComboBox == null) {

jComboBox = new JComboBox();

jComboBox.setBounds(new Rectangle(54, 407, 149, 24));

String[] mycbox={"微笑","大笑","痛苦"};

jComboBox.addItem(mycbox[0]);

jComboBox.addItem(mycbox[1]);

jComboBox.addItem(mycbox[2]);

}

return jComboBox;

}

/**

* This method initializes jTextField

*

* @return javax.swing.JTextField

*/

private JTextField getJTextField() {

if (jTextField == null) {

jTextField = new JTextField();

jTextField.setBounds(new Rectangle(265, 407, 231, 24));

}

return jTextField;

}

/**

* This method initializes jButton

*

* @return javax.swing.JButton

*/

private JButton getJButton() {

if (jButton == null) {

jButton = new JButton();

jButton.setBounds(new Rectangle(505, 407, 70, 24));

jButton.setText("提交");

jButton.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent e) {

jTextArea.setText(jTextArea.getText()+"rn"+"你"+jComboBox.getSelectedItem().toString()+"地说:"+jTextField.getText());

}

});

}

return jButton;

}

/**

* This method initializes jButton1

*

* @return javax.swing.JButton

*/

private JButton getJButton1() {

if (jButton1 == null) {

jButton1 = new JButton();

jButton1.setBounds(new Rectangle(565, 51, 60, 32));

jButton1.setText("清屏");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent e) {

jTextArea.setText("留言内容:");

}

});

}

return jButton1;

}

/**

* This method initializes jButton2

*

* @return javax.swing.JButton

*/

private JButton getJButton2() {

if (jButton2 == null) {

jButton2 = new JButton();

jButton2.setBounds(new Rectangle(565, 112, 60, 32));

jButton2.setText("置顶");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent e) {

jTextArea.setCaretPosition(0);

}

});

}

return jButton2;

}

/**

* This method initializes jButton3

*

* @return javax.swing.JButton

*/

private JButton getJButton3() {

if (jButton3 == null) {

jButton3 = new JButton();

jButton3.setBounds(new Rectangle(565, 173, 60, 32));

jButton3.setText("至尾");

jButton3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent e) {

jTextArea.setCaretPosition((int)jTextArea.getText().length());

}

});

}

return jButton3;

}

public static void main(String args[]){

new Liuyb();

}

}

我正在做一个java留言版,设计

数据库是必不可少的,推荐MySQL,好用而且免费。

另外权限的话,你是个新手吧。可以设计的简单点能达到清爽就行了。

如果你会使用struts2框架的话就使用它的拦截器来实现请求的权限拦截判断。

如果不会的话就使用过滤器吧。当然其中的处理权限的逻辑都是一样的。

当然Spring Security也是一个选择。

关于权限的逻辑,你先要设计数据库表,你可以简单的分为用户表和权限表。

用户表就是:用户ID,用户名等简单字段

权限表就是:权限ID权限名称,权限对应URL(这个URL就对应了一个功能的servelet或者一个action)

你还需要一张中间表,实现上述2张表多对多的关系,字段:用户ID,权限ID

因为每个功能踩,顶,发言,删除等,都是一个http请求,每个请求都是一个URL,会去到一个servelet或action来处理的。那么你根据URL可以得到这个权限的ID,再去查找中间表是否存在当前用户ID所关联的记录,有就说明有这个权限,没,就说明没有这个权限。

JAVA的留言板是怎么实现新留言,和回复留言的。

首先要会数据库,做一张留言表,一张回复表,留言表和回复表呈现一对多关系,就是说在回复表里面加一列叫做‘留言编号’,每次添加回复数据的时候,把对应的的留言id写进表里,insert into

回复表 values(回复id,留言id,回复内容、、、)查的时候 select * from 回复表 where 留言id=想查回复的留言的id,希望理解我说的

怎么用java写留言板

主要还是用html或者jsp写,通过提交表单传参到java类中进行处理,直接也可以用servlet,不过写出的代码跟SH1T一样,根本没法看

用Java做一个类似于QQ空间留言板的功能。。。

不用数据库也能实现. 及时性的罢了;

要是数据库的话:方法一(用于有条件性的,比如只显示对方发的信息)

1 user表 id , use 两列

2 messages表 id , message , message_person , use_id (外键) 四列

方法二(双方都用select * form messages查询所有信息)

1 messages表 id , message 两列

谁能帮我编一个简单的JAVA留言板,要代码,我会修改

csdn上面有,绝对有,你下一个就可以,一般只要改下数据库用户和密码就可以链接了

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。