我正在尝试将数据插入到我的MYSQL数据库中.我想在数据库中插入一个我没有问题的int.但是,我想INSERT INTO(VALUES)WHERE.我尝试这个时遇到MYSQL语法错误.
只要它们在两个单独的语句中,我就可以INSERT和SELECT WHERE.这是我的代码:
String query = ("INSERT INTO `accounts` (inventory) " + "VALUES ('"
+ Inventory.inventory + "') WHERE username='" + Frame.username
+ "' and password = '" + Frame.password + "'");
Run Code Online (Sandbox Code Playgroud) 我试图让一个JPanel出现在另一个JPanel中。当前,JPanel位于外部JFrame中,并与我的其他JFrame一起加载。我希望JPanel位于另一个JPanel中,以便该程序不会打开两个不同的窗口。
这是一张图片:

我想要在主游戏框架内放置文本日志的小型JPanel。我尝试将面板添加到面板中panel.add(othePanel)。我尝试将其添加到JFrame中frame.add(otherPanel)。它只会覆盖其他所有内容,并为其提供黑色背景。
如何添加面板,调整大小和移动面板?
编辑:
那就是我想要的聊天框。

班级代码:
不在课堂上。
public static JPanel panel;
public static JTextArea textArea = new JTextArea(5, 30);
public static JTextField userInputField = new JTextField(30);
public static void write(String message) {
Chatbox.textArea.append("[Game]: " + message + "\n");
Chatbox.textArea.setCaretPosition(Chatbox.textArea.getDocument()
.getLength());
Chatbox.userInputField.setText("");
}
public Chatbox() {
panel = new JPanel();
panel.setPreferredSize(new Dimension(220, 40));
panel.setBackground(Color.BLACK);
JScrollPane scrollPane = new JScrollPane(textArea);
scrollPane.setPreferredSize(new Dimension(380, 100));
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setEditable(false);
scrollPane
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
userInputField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
String …Run Code Online (Sandbox Code Playgroud)