【发布时间】:2014-05-06 20:47:35
【问题描述】:
我在网上搜索过,发现the answer on the this link。我跟着它,但它仍然无法工作。有人会告诉我我错过了什么。我的按钮仍然在面板的中心。
这是我的代码。
public class PDFJPanel extends JPanel {
private JPanel jpAnnotation=null;
private JScrollPane scrollPane = new JScrollPane();
private File thisFile=null;
private PDFNotesBean bean=null;
private CommentPanel commentPane=null;
public PDFJPanel (File file)
{
thisFile=file;
getJPanel();
}
public void getJPanel( )
{
this.setLayout(new BorderLayout());
this.add(getPDFNotesBean(), BorderLayout.CENTER);
commentPane= bean.getCommentPanel();
//Right size of the Panel
JPanel rightPanel=new JPanel();
rightPanel.setLayout(new BorderLayout());
rightPanel.setBackground(Color.GREEN);
jpAnnotation=new JPanel();
JButton btnUnderline =new JButton(new ImageIcon ("../UnderlineIcon.gif"));
btnUnderline.setSize(50, 260);
btnUnderline.setAlignmentX(JButton.LEFT_ALIGNMENT);
btnUnderline.setHorizontalAlignment(JButton.LEFT);
jpAnnotation.add(btnUnderline);
rightPanel.add(jpAnnotation, BorderLayout.NORTH );
rightPanel.add((Component) commentPane, BorderLayout.CENTER );
this.add(rightPanel, BorderLayout.EAST );
}
【问题讨论】:
标签: java swing alignment jpanel