社区
Java SE
帖子详情
问一个关于jpanel的问题。。
lodestar51
2004-08-30 01:14:55
jpanel是一个容器吧?它为什么一定还要放到别的容器里呀??
给个例子吧??在说说为什么!!
jframe我明白,可是jpanel晕了。。。。
以前没有做过gui,向大家学习一下。。。
...全文
103
7
打赏
收藏
问一个关于jpanel的问题。。
jpanel是一个容器吧?它为什么一定还要放到别的容器里呀?? 给个例子吧??在说说为什么!! jframe我明白,可是jpanel晕了。。。。 以前没有做过gui,向大家学习一下。。。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
oioioi-090
2004-09-01
打赏
举报
回复
因为我用过delphi
我就把JPanel当成TPanel
把JFrame当成TForm
呵呵!不知对不!
oioioi-090
2004-09-01
打赏
举报
回复
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
* Created on 2004-8-28
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
/**
* @author zhu_hb
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class MySwing extends JFrame {
Panel p;
JRadioButton b1 = new JRadioButton("Metal"),
b2 = new JRadioButton("Motif"),
b3 = new JRadioButton("Windows");
public MySwing() {
super("Swing application");
Container contentPane = getContentPane();
p = new Panel();
contentPane.add(p, BorderLayout.CENTER);
}
public static void main(String[] args) {
final JFrame f = new MySwing();
f.setBounds(100, 100, 300, 200);
f.setVisible(true);
f.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
class Panel extends JPanel implements ActionListener {
public Panel() {
add(new JButton("JButton"));
add(new JTextField("JTextField"));
add(new JCheckBox("JCheckBox"));
add(new JRadioButton("JRadioButton"));
add(new JLabel("JLabel"));
add(
new JList(
new String[] {
"JList Item 1",
"JList Item 2",
"JList Item 3" }));
add(new JScrollBar(SwingConstants.HORIZONTAL));
ButtonGroup group = new ButtonGroup();
group.add(b1);
group.add(b2);
group.add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
add(b1);
add(b2);
add(b3);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawString("Hello from Eclipse!", 60, 100);
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
JRadioButton src = (JRadioButton) e.getSource();
try {
if ((JRadioButton) e.getSource() == b1)
UIManager.setLookAndFeel(
"javax.swing.plaf.metal.MetalLookAndFeel");
else if ((JRadioButton) e.getSource() == b2)
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.motif.MotifLookAndFeel");
else if ((JRadioButton) e.getSource() == b3)
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception ex) {
}
SwingUtilities.updateComponentTreeUI(getContentPane());
}
}
}
lodestar51
2004-09-01
打赏
举报
回复
UP.....一下。。。过两天结贴。。
有没有人给个JPanel的CODE呀?
谢谢了。。
sylmoon
2004-08-30
打赏
举报
回复
jframe是最低层的容器,相当于构建一个windows窗口
jpanel是窗口中的容器,用来容纳各种其他的组件
并可以使用很多工具来增强表现力
如:layout,doublebuffer等
flyingbug
2004-08-30
打赏
举报
回复
jframe是最低层的容器,相当于构建一个windows窗口
jpanel是窗口中的容器,用来容纳各种其他的组件
并可以使用很多工具来增强表现力
如:layout,doublebuffer等
constantine
2004-08-30
打赏
举报
回复
up
zerogotosum
2004-08-30
打赏
举报
回复
看书
Java布局管理器使用方法
首先,建
一个
frame文件(Application应用程序),在Design中将this中的layout设置为BorderLayout。 第二,在组件盘内点选Swing Container页签,选取
Jpanel
图标,在this中上方拖拽一块区域,布局器会自动
达内 coreJava 习题答案
6、输出所有的水仙花数,把谓水仙花数是指
一个
数3位数,其各各位数字立方和等于其本身, 例如: 153 = 1*1*1 + 3*3*3 + 5*5*5 class DafodilNumber{ public static void main(String[] args){ System.out....
java
jpanel
叠加_java
JPanel
重叠覆盖
问
题
。
importjava.awt.Graphics;importjavax.swing....importjavax.swing.
JPanel
;publicclasspaintextendsJFrame{
JPanel
jp1;
JPanel
jp2;publicpaint(){this.add(jp1=newpanel1());jp1.se...import java.awt.Graphics;im...
Java窗体在另
一个
类_java – 在JFrame中将
JPanel
从另
一个
类添加到
JPanel
我无法从主类中获取我的JFrame来显示另
一个
类的
JPanel
.一切都编译没有错误.JFrameTest.java:package jframetest;import java.awt.FlowLayout;import javax.swing.JButton;import javax.swing.JFrame;import javax....
java
jpanel
透明背景_JLayeredPanes中的透明
JPanel
我希望
JPanel
透明或完全不可见(不像panel.setVisible(false),但更像是opacity = 0.0f),然后将其放入JLayeredPane,以使底层...我接下来尝试的是首先实现
一个
透明的
JPanel
,通过这样做或多或少容易:public class...
Java SE
62,614
社区成员
307,327
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章