3
When I concateno(+) strings adds one alone enter right after the concatenation.
private static Dimension TOOLKIT = Toolkit.getDefaultToolkit().getScreenSize();
private static GraphicsEnvironment GE = GraphicsEnvironment.getLocalGraphicsEnvironment();  
private static Rectangle SCREEN = GE.getMaximumWindowBounds(); 
private static Color BLACK = new Color(0, 0, 0);
private static Color CINZA = new Color(32, 32, 32);
private static Color GREEN = new Color(12, 202, 5);
static JTextArea showMens = new JTextArea();
static JTextArea writeMens = new JTextArea();
public static void main(String[] args) 
{
    createChatLayout();
}
public static void createChatLayout()
{
    JFrame frameChat = new JFrame();
    int WIDTH = SCREEN.width;
    int HEIGHT = SCREEN.height;
    int BORDA = 10;
    frameChat.setExtendedState(frameChat.MAXIMIZED_BOTH);
    frameChat.setDefaultCloseOperation(frameChat.EXIT_ON_CLOSE);
    frameChat.setLayout(null);
    frameChat.setVisible(true);
    Container c = frameChat.getContentPane();
    c.setBackground(BLACK);
    showMens.setBounds(BORDA, BORDA, WIDTH - BORDA * 2, HEIGHT - BORDA * 2 - HEIGHT / 4 - 2 * BORDA);
    writeMens.setBounds(BORDA, (HEIGHT - BORDA * 2 - HEIGHT / 4 - BORDA) + BORDA , WIDTH - BORDA * 2, HEIGHT / 4 - BORDA);
    showMens.setBackground(CINZA);
    writeMens.setBackground(CINZA);
    showMens.setForeground(GREEN);
    writeMens.setForeground(GREEN);
    showMens.setFont(createFont(16));   
    writeMens.setFont(createFont(16));
    showMens.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));  
    writeMens.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));  
    showMens.setLineWrap(true);
    writeMens.setLineWrap(true);
    showMens.setWrapStyleWord(true);
    writeMens.setWrapStyleWord(true);
    showMens.setEditable(false);
    c.add(showMens);
    c.add(writeMens);
    frameChat.repaint();
    eventos();
}
public static void eventos()
{
    writeMens.addKeyListener(new KeyListener()
    {
        public void keyTyped(KeyEvent e) {}
        public void keyReleased(KeyEvent e) {}
        public void keyPressed(KeyEvent e) 
        {
            if(e.getKeyCode() == e.VK_ENTER)
            {
                showMens.append("Lucas: " + writeMens.getText());
                showMens.append("\n");
                writeMens.setText("");
            }
        }
    });
}
public static Font createFont(int tamanho)
{
    Font font = null;
    try 
    {
        font = Font.createFont(Font.TRUETYPE_FONT, new File("ocraextended.ttf")).deriveFont(Font.PLAIN, tamanho);
    } 
    catch (FontFormatException e){} catch (IOException e){}
    return font;
}
						


The function that writes the line is which? Because in java we have Write and Writeln, the second adds a enter. Isn’t that something? If you can, post the functions used, such as showMens, for example.
– Celso Marigo Jr
But of course, it’s not alone. It adds enter to Panel for after/during firing the keyPressed event
– Dener
And what should I do to take that away ??
– Lucas Caresia