请问这种布局如何在swing中实现 作业只学了简单的布局管理器,这种不知道如何实现,请教大家! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 晕错了 刚刚看了一眼 是网格布局 java.awt.GridLayout() 我..楼上楼主小号啊这么多要求啊 这就不是一个布局了是一个组合的啊整体上用box中间的用网格的 动态调整大小是什么意思啊 import java.awt.Color;import java.awt.Font;import java.awt.Rectangle;import java.awt.SystemColor;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.ButtonGroup;import javax.swing.JDialog;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JRadioButton;public class b extends JDialog implements ActionListener { private JPanel jContentPane = null; public JLabel jLabelDealingID = null; static JLabel jLabelSumShow = null; static JLabel jLabelMerberIDShow = null; static JLabel jLabelMerberNameShow = null; static JLabel jLabelMerberLevelShow = null; static JLabel jLabelMerberDiscountShow = null; static JLabel jLabelMerberPointsShow = null; static JRadioButton jRadioButtonCommon = null; static JRadioButton jRadioButtonMerBer = null; private ButtonGroup bg = new ButtonGroup(); private JLabel jLabelNum = null; static JLabel jLabelNumShow = null; public b() { initialize(); this.setVisible(true); } private void initialize() { this.setTitle("CashRegister"); this.setSize(500, 200); this.setModal(true); this.setLocationRelativeTo(this); this.setContentPane(getJContentPane()); } private JPanel getJContentPane() { if (jContentPane == null) { jLabelNumShow = new JLabel(); jLabelNumShow.setBounds(new Rectangle(40, 0, 53, 25)); jLabelNumShow.setForeground(Color.WHITE); jLabelNumShow.setText(""); jLabelNum = new JLabel(); jLabelNum.setBounds(new Rectangle(0, 0, 40, 25)); jLabelNum.setForeground(Color.WHITE); jLabelNum.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.BOLD, 12)); jLabelNum.setText("总计:"); jContentPane = new JPanel(); jContentPane.setLayout(null); jContentPane.add(getJRadioButtonMerBer(), null); jContentPane.add(jLabelNum, null); jContentPane.add(jLabelNumShow, null); jContentPane.setBackground(SystemColor.darkGray);//背景颜色 } return jContentPane; } private JRadioButton getJRadioButtonMerBer() { if (jRadioButtonMerBer == null) { jRadioButtonMerBer = new JRadioButton(); jRadioButtonMerBer.setBounds(new Rectangle(300, 0, 54, 21)); jRadioButtonMerBer.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.BOLD, 12)); jRadioButtonMerBer.setText("点我"); jRadioButtonMerBer.setSelected(false);// 交易后返回普通用户 bg.add(jRadioButtonMerBer); jRadioButtonMerBer.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent e) { } }); } return jRadioButtonMerBer; } public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub } public static void main(String args[]) { b test=new b(); test.setVisible(true); } } 方法很多,我给你介绍的是采用这种坐标实现 jRadioButtonMerBer.setBounds(new Rectangle(300, 0, 54, 21));(x轴,y轴,长,宽)希望对你有帮助 java 里面能把method name 作为另外一个method 的参数吗? 关于 JAVA 在线等!这段代码到底有什么问题?????????? 改CSDN的名字怎么改 如何用程序获得本机器中有几个分区,如何在找到的分区中搜索*.rar 文件。解决给200分??急!! 弱弱的问:为什么不能调用同一个包中的类?100 如何传递jsp中的参数呢?(来者有分) 总结:jTable与数据关联的方法,大家多总结一些这样的方法 怎麼用java實現文件的ftp上傳???? 一道大数据量算法的面试题,有兴趣的给点思路 java代码编译报错,请高手帮哈忙 swing里一个关于窗体旋转的问题的
整体上用box中间的用网格的 动态调整大小是什么意思啊
import java.awt.Color;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.ButtonGroup;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;public class b extends JDialog implements ActionListener {
private JPanel jContentPane = null;
public JLabel jLabelDealingID = null;
static JLabel jLabelSumShow = null;
static JLabel jLabelMerberIDShow = null;
static JLabel jLabelMerberNameShow = null;
static JLabel jLabelMerberLevelShow = null;
static JLabel jLabelMerberDiscountShow = null;
static JLabel jLabelMerberPointsShow = null;
static JRadioButton jRadioButtonCommon = null;
static JRadioButton jRadioButtonMerBer = null;
private ButtonGroup bg = new ButtonGroup();
private JLabel jLabelNum = null;
static JLabel jLabelNumShow = null;
public b() {
initialize();
this.setVisible(true);
}
private void initialize() {
this.setTitle("CashRegister");
this.setSize(500, 200);
this.setModal(true);
this.setLocationRelativeTo(this);
this.setContentPane(getJContentPane());
} private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelNumShow = new JLabel();
jLabelNumShow.setBounds(new Rectangle(40, 0, 53, 25));
jLabelNumShow.setForeground(Color.WHITE);
jLabelNumShow.setText("");
jLabelNum = new JLabel();
jLabelNum.setBounds(new Rectangle(0, 0, 40, 25));
jLabelNum.setForeground(Color.WHITE);
jLabelNum.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.BOLD, 12));
jLabelNum.setText("总计:");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJRadioButtonMerBer(), null);
jContentPane.add(jLabelNum, null);
jContentPane.add(jLabelNumShow, null);
jContentPane.setBackground(SystemColor.darkGray);//背景颜色
}
return jContentPane;
}
private JRadioButton getJRadioButtonMerBer() {
if (jRadioButtonMerBer == null) {
jRadioButtonMerBer = new JRadioButton();
jRadioButtonMerBer.setBounds(new Rectangle(300, 0, 54, 21));
jRadioButtonMerBer.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.BOLD, 12));
jRadioButtonMerBer.setText("点我");
jRadioButtonMerBer.setSelected(false);// 交易后返回普通用户
bg.add(jRadioButtonMerBer);
jRadioButtonMerBer.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
}
});
}
return jRadioButtonMerBer;
} public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
public static void main(String args[]) {
b test=new b();
test.setVisible(true);
}
} 方法很多,我给你介绍的是采用这种坐标实现
jRadioButtonMerBer.setBounds(new Rectangle(300, 0, 54, 21));
(x轴,y轴,长,宽)希望对你有帮助