怎样将一个label设置在frame的右下角 把frame的风格改一下,改成xy的那种,label想放哪就放哪 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 别用xylayout,因为你要带jbcl,layout设为null替代xylayout.你的问题还可以一种方法。整个panel设为borderlabyout.再其中加一个JPanel到borderlayout的south,再设此JPanel的layout为borderlayout,加你的label到其中的east一块。 import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Frame1 extends JFrame { private JPanel contentPane; private BorderLayout borderLayout1 = new BorderLayout(); private JPanel jPanel1 = new JPanel(); private BorderLayout borderLayout2 = new BorderLayout(); private JLabel jLabel1 = new JLabel(); //Construct the frame public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(borderLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("Frame Title"); jPanel1.setLayout(borderLayout2); jLabel1.setText("MyLabel"); contentPane.add(jPanel1, BorderLayout.SOUTH); jPanel1.add(jLabel1, BorderLayout.EAST); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } public static void main(String[] args) { Frame1 frame = new Frame1(); frame.validate(); frame.setVisible(true); }} 如何用JAVA调用系统的notepad,并写入一行文字? 关于.bat调用.jar文件的问题(怪)? 倾家荡产,请大家帮我写个java 代码 java容器到底存放的是什么,不是引用吗??? #####关于Jar打包的问题!熟悉的人进来!##### 退出的问题? 请问使用socket编码中读数据时采用InputStream和BufferedReader有什么区别? 请各位帮忙 byte() 方法如何使用? 求帮助一个双重for循环的算法,是在不知道怎么做 真的没人知道怎么做吗?再发一个贴子 关于jbuilder的简单问题
你的问题还可以一种方法。
整个panel设为borderlabyout.再其中加一个JPanel到borderlayout的south,再设此JPanel的layout为borderlayout,加你的label到其中的east一块。
import java.awt.event.*;
import javax.swing.*;public class Frame1 extends JFrame {
private JPanel contentPane;
private BorderLayout borderLayout1 = new BorderLayout();
private JPanel jPanel1 = new JPanel();
private BorderLayout borderLayout2 = new BorderLayout();
private JLabel jLabel1 = new JLabel(); //Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
jPanel1.setLayout(borderLayout2);
jLabel1.setText("MyLabel");
contentPane.add(jPanel1, BorderLayout.SOUTH);
jPanel1.add(jLabel1, BorderLayout.EAST);
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
} public static void main(String[] args) {
Frame1 frame = new Frame1();
frame.validate();
frame.setVisible(true);
}
}