用swing开发、怎样实现分隔线的功能? 什么分隔线啊?如果是菜单栏的分隔线就用楼上的如果是面板上的,可以用JSplitPane来解决。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是面板上的、不是分栏的。类似html里的<HR>那种的、有点凹的一条线。就相当于菜单上的那种。 import java.awt.*;import javax.swing.*;public class Test extends JApplet { public void init() { Container contentPane = getContentPane(); JSeparator s = new JSeparator(JSeparator.VERTICAL); Dimension ps = s.getPreferredSize(); contentPane.setLayout(new FlowLayout()); contentPane.add(new JButton("left")); contentPane.add(s); contentPane.add(new JButton("right")); s.setPreferredSize(new Dimension(ps.width, 50)); }} 用了JSeparator还是看不到分隔线啊。 可以自己画,上面是灰色的,下面是白色的两条线,也可以用带边框的PANEL,将其高度调低就可以了!! 修改JSeparator默认的大小后就能看见 private javax.swing.JSeparator s = null;...jContentPane.add(getJSeparator(), null);...private javax.swing.JSeparator getJSeparator() { if (s == null) { s = new JSeparator(); } return s;}我的文件里有了以上代码后为何看不到分隔线? 要设置面板的布局方式为BoxLayout,否则必须设置JSeperator的大小才能看见。 J2SE考试系统,JTree 关于JDBC! String=什么 然后就不用转义 求助高人!!!路径问题 如何使用jsr-80 JFrame执行问题 请问这句是什么作用:static Class class$org$jfree$data$time$Millisecond; 高分求此XML解析问题,快来拿分啊。。。。 class inclass=System.out.getclass()是什么意思?起什么作用? 快看阿! 请教一个滚动面板(JScrollPane)使用的问题(非常常见)! 如何判断一个其间包含了哪几个月?
import javax.swing.*;public class Test extends JApplet {
public void init() {
Container contentPane = getContentPane();
JSeparator s = new JSeparator(JSeparator.VERTICAL);
Dimension ps = s.getPreferredSize(); contentPane.setLayout(new FlowLayout()); contentPane.add(new JButton("left"));
contentPane.add(s);
contentPane.add(new JButton("right")); s.setPreferredSize(new Dimension(ps.width, 50));
}
}
...
jContentPane.add(getJSeparator(), null);
...
private javax.swing.JSeparator getJSeparator() {
if (s == null) {
s = new JSeparator();
}
return s;
}
我的文件里有了以上代码后为何看不到分隔线?