Hallo erstmal,
also mein Problem siehe Bild, ist dass sich mein JLabel in dem der Chat angezeigt wird komischer Weise nach rechts verschoben wird.
Danke schon mal für konstruktive Beiträgt
Gruß Templar
also mein Problem siehe Bild, ist dass sich mein JLabel in dem der Chat angezeigt wird komischer Weise nach rechts verschoben wird.
Java:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.security.*;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Player extends JFrame{
private JTabbedPane tab;
private String name;
private String pw;
private JPanel login;
private JPanel overview;
private JLabel chatLog;
private JPanel chatPanel;
private JTextField chat;
private JPasswordField loginPw;;
private JTextField loginName;
private JButton loginButton;
private JButton chatButton;
private mysql mysql;
Player() {
mysql = new mysql();
login = new JPanel();
overview = new JPanel();
login.setLayout(new BoxLayout(login, BoxLayout.Y_AXIS));
this.add( login);
login.add(new JLabel("Playername: "));
login.add(loginName = new JTextField(20));
loginName.setMaximumSize(new Dimension(500, 20));
login.add(Box.createRigidArea(new Dimension(5,10)));
login.add(new JLabel("Password: "));
login.add(loginPw = new JPasswordField());
loginPw.setMaximumSize(new Dimension(500,20));
login.add(loginButton = new JButton("login"));
loginButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
name = loginName.getText();
pw = String.valueOf(loginPw.getPassword());
System.out.println(name+"|"+pw);
if(mysql.password(name, pw))
createPlayerWindow();
}
});
this.setTitle("Login");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(800, 600);
this.pack();
}
public static void main(String [] args) {
new Player().setVisible(true);
}
public void createPlayerWindow() {
this.remove(login);
this.setTitle(name);
this.setSize(600,400);
this.add(overview);
overview.setLayout(new BoxLayout(overview,BoxLayout.Y_AXIS));
tab = new JTabbedPane();
tab.setBorder(BorderFactory.createLineBorder(Color.black));
overview.add(tab);
tab.setMaximumSize(new Dimension(this.getWidth(), 400));
tab.addTab("Player Stats", new JLabel("Player Stats"));
tab.addTab("Game Stats", new JLabel("Game Stats"));
tab.addTab("Achievements", new JLabel("achievement"));
JLabel chatdunno = new JLabel(mysql.getChat());
//chatLog = new JLabel(mysql.getChat());
//chatLog.setMaximumSize(new Dimension(800, 250));
overview.add(chatdunno);
chatdunno.setBorder(BorderFactory.createLineBorder(Color.black));
chatPanel = new JPanel();
overview.add(chatPanel);
chatPanel.setLayout(new FlowLayout());
chatPanel.setMaximumSize(new Dimension(this.getWidth(), 30));
System.out.println(this.getWidth());
chat = new JTextField(this.getWidth()/13);
chatPanel.add(chat);
chatButton = new JButton("send");
chatButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mysql.sendChat(chat.getText(),name);
chat.setText("");
chatLog.setText(mysql.getChat());
}
});
chatPanel.add(chatButton);
}
}
Danke schon mal für konstruktive Beiträgt
Gruß Templar