【发布时间】:2022-01-09 13:25:30
【问题描述】:
我有一个面板,我想有一个背景图像和两组文本,一个“标题”和文本区域,以便稍后添加文本 如何让文本区域位于图像(标签)之上,或者是否有更好的方法来实现这一点?
` //对于文本(右)
JPanel textPanel = new JPanel();
//textPanel.setLayout(); //I don't understand layouts I tried some non really got what I needed
textPanel.setBorder(border);
textPanel.setBounds(190, 0, 1300, 886);
textPanel.setBackground(Color.BLACK);
//Imports For inventory Label
JLabel textLabel = new JLabel(); //Title label
arrayTXTA = new JTextArea(0,1);//The text I will add later label
JLabel textLabelbg = new JLabel(); //Background image label
ImageIcon Teximage =new ImageIcon("src\\emporium\\pkg\\background.jpg");//sets up image for background
//Code for background image
textLabelbg.setIcon(Teximage);//adds an image
textLabelbg.setBounds(70, 5, 1200, 886);
//TEXT AT 253
//Code for title
textLabel.setHorizontalTextPosition(JLabel.CENTER); icon
textLabel.setVerticalTextPosition(JLabel.TOP);
textLabel.setForeground(new Color(0,255,0));
textLabel.setFont(new Font("Blackadder ITC",Font.BOLD,30));
//textLabel.setBounds(300, 0, 100, 36);
//Code for Text I will add later
arrayTXTA.setVisible(true);
arrayTXTA.append("Words");
arrayTXTA.append("Words");
arrayTXTA.append("Words");
arrayTXTA.setForeground(new Color(255,0,0));
arrayTXTA.setFont(new Font("Blackadder ITC",Font.BOLD,30));
arrayTXTA.setBackground(new Color(0, 0, 0, 0));
arrayTXTA.setBounds(25, 0, 0, 0);
`
Here is a picture of what I am trying to achieve
提前谢谢你
【问题讨论】:
标签: java swing user-interface