I´m new at java, and world like to place a label on a panels upper left corner.
Should i use a different LayoutManager?
Hers a simple examle i can't get to work.
Probably a simple fix, but i´m bad at this
Thanks for your time !
Best Regards
Oskar
import javax.swing.*; import java.awt.*; public class test { public static void main(String[] args) { JFrame frame = new JFrame("TrippTrapp"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setPreferredSize(new Dimension(300, 300)); panel.setBackground(Color.red); JLabel label = new JLabel("hej"); label.setHorizontalAlignment(SwingConstants.LEFT); panel.add(label); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); } }