I am trying to achieve a simple “console” with a swing layout that i will just be able to add simple messages to each one in a different line and different color.
i have been able to do something but i still have problems with it.
i have made 2 attempts at this.
1: with grid layout:
summeryGrid = new JPanel(new GridLayout(0, 1)); summeryGrid.setBounds(10, 140, 600, 300); summeryGrid.add(createErrorMessage("some error message")); summeryGrid.add(createErrorMessage("some error message1")); summeryGrid.add(createErrorMessage("some error message2"));
This actualy works fine. but the problem that i am having is that if i don’t have enough messages there is a huge gap between them. i did try to set the hgap and vgap but they had not affect in this matter.
2: attempt is with flow layout. but that damn awful layout seems to work only vertically and not horizontally for some reason. so that’s no good unless i can turn its layout
You can use a single JEditorPane to display the whole thing.
Here is a very simple example: