在面板中添加复杂图像,在一个自定义用户界面中使用按钮我怎样才能将这样的图像放到slavePanelJPanel的顶部和顶部,调整JButtons看起来像图像但是按钮正确缠绕?(现在它们形成一排,四列)在此输入图像描述 // // Shot Gun mover up/down/left/right, middle on is for zoom // public void GunMover(JPanel configPanel) throws IOException { // Master Panel - holds everything JPanel masterPanel = new Panel(); masterPanel.setLayout(new SpringLayout()); // Slave Panel - with image background JPanel slavePanel = new Panel(); slavePanel.setLayout(new SpringLayout()); // Row 1 final JButton ptzLeft = new JButton("<"); masterPanel.add(ptzLeft, BorderLayout.WEST); // Row 2 final JButton ptzRight = new JButton(">"); masterPanel.add(ptzRight, BorderLayout.CENTER); // Row 3 final JButton ptzUp = new JButton("^"); masterPanel.add(ptzUp, BorderLayout.WEST); // Row 4 final JButton ptzDown = new JButton("down"); masterPanel.add(ptzDown, BorderLayout.CENTER); // How do i add slavePanel this background and add all the JButtons // According to that image shape? // Layout the panel. SpringUtilities.makeCompactGrid(masterPanel, 1, 4, //rows, cols 6, 6, //initX, initY 6, 6); configPanel.setLayout(new GridLayout(0,1)); configPanel.add(masterPanel); }跟进:优秀的一个来自Andrew Thompson +至少我的破碎方法在此输入图像描述package test;import java.awt.*;import java.awt.font.FontRenderContext;import java.awt.font.TextLayout;import javax.swing.*;public class New extends JFrame { private static final long serialVersionUID = 1L; private ImageIcon errorIcon = (ImageIcon) UIManager.getIcon("OptionPane.errorIcon"); private Icon infoIcon = UIManager.getIcon("OptionPane.informationIcon"); private Icon warnIcon = UIManager.getIcon("OptionPane.warningIcon");
添加回答
举报
0/150
提交
取消