How can I align a JTextArea in a vertical manner?

55 Views Asked by At

Here is the code that I'm currently working on:

private static void createAndShowUI() {
    JFrame frame = new JFrame("Task 1");  
    frame.getContentPane().setLayout(new BorderLayout());
    
    JTextArea area=new JTextArea("BETCP");
    frame.add(area);
    //frame.setSize(300,300);
    area.setForeground(Color.CYAN);

    JTextArea area2 =new JTextArea("Names");
    frame.add(area2);
    //frame.setSize(300,300);
    area2.setForeground(Color.BLUE);
    
    JTextArea area3 =new JTextArea("Codes");
    frame.add(area3);
    //frame.setSize(300,300);
    area3.setForeground(Color.BLUE);
    
    final Blinklabel  bl = new Blinklabel ("This is the blinking text");
    frame.getContentPane().add(bl, BorderLayout.SOUTH);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

I'm not yet that familiar with Java. I hope that you can help me. I want to make the colored texts come first, then the blinking text is in the last part. The border layout is just limited to north, south, east, west etc.. so I can't really align it vertically because it will just overwrite the other text (if both texts are set at center, for example)

0

There are 0 best solutions below