JPanel mEvidenceFilePanel = new JPanel();
mEvidenceFilePanel.setLayout(null);
mEtitleSnoLbl = new JLabel("", JLabel.LEFT);
mEtitleEtypesLbl = new JLabel("", JLabel.LEFT);
mEtitleSnoLbl.setBounds(10, 1, 50, 50);
mEtitleEtypesLbl.setBounds(50, 1, 100, 50);
mEvidenceFilePanel.add(mEtitleSnoLbl);
mEvidenceFilePanel.add(mEtitleEtypesLbl);
hv.mMainFrame.getContentPane().add(mEvidenceFilePanel);
我无法想象它在JPanel中添加滚动条,而不是Frame ...任何人都知道帮助我......如何在里面添加滚动条..谢谢......
答案 0 :(得分:1)
首先,将布局设为null是一个非常糟糕的主意。至于你的问题的答案,试试这个..
JPanel pn= new JPanel();
pn.setLayout(null); //Do not do this, I'm just using this as an example
JScrollPane scroll = new JScrollPane(panel);
JScrollPane s = new JScrollPane(pn, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);