再往小里错就更难看了,请问有办法解决么
12 个解决方案
#1
contentPane.setLayout(null);
// or
import com.borland.jbcl.layout.*;
contentPane.setLayout( new XYLayout() );
// or
import com.borland.jbcl.layout.*;
contentPane.setLayout( new XYLayout() );
#2
import javax.swing.*;
public class myFrame extends JFrame {
JPanel contentPanel=(JPanel)this.getContentPane();
JPanel jp=new JPanel();
JButton jb=new JButton("1");
JButton jb1=new JButton("2");
public myFrame() {
super("myFrame");
this.setSize(800,600);
this.setResizable(true);
this.setLocation(this.getToolkit().getScreenSize().width/2-400,this.getToolkit().getScreenSize().height/2-300);
contentPanel.setLayout(new BorderLayout());
contentPanel.add("Center",jp);
jp.setLayout(null);
jp.add(jb);
jb.setBounds(100,100,100,100);
jp.add(jb1);
jb1.setBounds(2100,210,50,50);
this.setVisible(true);
}
public static void main(String args[]) {
new myFrame();
}
}
public class myFrame extends JFrame {
JPanel contentPanel=(JPanel)this.getContentPane();
JPanel jp=new JPanel();
JButton jb=new JButton("1");
JButton jb1=new JButton("2");
public myFrame() {
super("myFrame");
this.setSize(800,600);
this.setResizable(true);
this.setLocation(this.getToolkit().getScreenSize().width/2-400,this.getToolkit().getScreenSize().height/2-300);
contentPanel.setLayout(new BorderLayout());
contentPanel.add("Center",jp);
jp.setLayout(null);
jp.add(jb);
jb.setBounds(100,100,100,100);
jp.add(jb1);
jb1.setBounds(2100,210,50,50);
this.setVisible(true);
}
public static void main(String args[]) {
new myFrame();
}
}
#3
or
import javax.swing.*;
public class myFrame extends JFrame {
JPanel contentPanel=(JPanel)this.getContentPane();
JPanel jp=new JPanel();
JButton jb=new JButton("1");
JButton jb1=new JButton("2");
public myFrame() {
super("myFrame");
this.setSize(800,600);
this.setResizable(true);
this.setLocation(this.getToolkit().getScreenSize().width/2-400,this.getToolkit().getScreenSize().height/2-300);
contentPanel.setLayout(new BorderLayout());
contentPanel.add("Center",jp);
jp.setLayout(new FlowLayout());
jp.add(jb);
jp.add(jb1);
this.setVisible(true);
}
public static void main(String args[]) {
new myFrame();
}
}
import javax.swing.*;
public class myFrame extends JFrame {
JPanel contentPanel=(JPanel)this.getContentPane();
JPanel jp=new JPanel();
JButton jb=new JButton("1");
JButton jb1=new JButton("2");
public myFrame() {
super("myFrame");
this.setSize(800,600);
this.setResizable(true);
this.setLocation(this.getToolkit().getScreenSize().width/2-400,this.getToolkit().getScreenSize().height/2-300);
contentPanel.setLayout(new BorderLayout());
contentPanel.add("Center",jp);
jp.setLayout(new FlowLayout());
jp.add(jb);
jp.add(jb1);
this.setVisible(true);
}
public static void main(String args[]) {
new myFrame();
}
}
#4
不要使用xylayout!
#5
提供点参考:
1。捕捉修改大小的事件,自己按照比例重画。
2。禁止修改大小。
1。捕捉修改大小的事件,自己按照比例重画。
2。禁止修改大小。
#6
getToolkit().getScreenSize()用这个可以取得屏幕尺寸,剩下的自己想把
#7
定义组键的尺寸,可以用GridBagConstraints里的,ipadx和ipday确定,
也可以用setPreferredSize(new Dimension(int x,int y))来设置大小!
也可以用setPreferredSize(new Dimension(int x,int y))来设置大小!
#8
很简单,用layout嘛
#9
只要布局用borderlayout就可以实现。
#10
可以尝试:
setLayout(null);
再用
setBounds(x,y,width,height);
定位.
应该可以,虽然很多书上不推荐用setLayout(null)
setLayout(null);
再用
setBounds(x,y,width,height);
定位.
应该可以,虽然很多书上不推荐用setLayout(null)
#11
这个问题不太好解决,比方说还有字体大小的问题,要控件大小和字体大小都随窗体的改变而改变可得费点工夫
#12
maybe you need to use multi-layouts to solve that problem. I am not sure of what results you want ultimately.
#1
contentPane.setLayout(null);
// or
import com.borland.jbcl.layout.*;
contentPane.setLayout( new XYLayout() );
// or
import com.borland.jbcl.layout.*;
contentPane.setLayout( new XYLayout() );
#2
import javax.swing.*;
public class myFrame extends JFrame {
JPanel contentPanel=(JPanel)this.getContentPane();
JPanel jp=new JPanel();
JButton jb=new JButton("1");
JButton jb1=new JButton("2");
public myFrame() {
super("myFrame");
this.setSize(800,600);
this.setResizable(true);
this.setLocation(this.getToolkit().getScreenSize().width/2-400,this.getToolkit().getScreenSize().height/2-300);
contentPanel.setLayout(new BorderLayout());
contentPanel.add("Center",jp);
jp.setLayout(null);
jp.add(jb);
jb.setBounds(100,100,100,100);
jp.add(jb1);
jb1.setBounds(2100,210,50,50);
this.setVisible(true);
}
public static void main(String args[]) {
new myFrame();
}
}
public class myFrame extends JFrame {
JPanel contentPanel=(JPanel)this.getContentPane();
JPanel jp=new JPanel();
JButton jb=new JButton("1");
JButton jb1=new JButton("2");
public myFrame() {
super("myFrame");
this.setSize(800,600);
this.setResizable(true);
this.setLocation(this.getToolkit().getScreenSize().width/2-400,this.getToolkit().getScreenSize().height/2-300);
contentPanel.setLayout(new BorderLayout());
contentPanel.add("Center",jp);
jp.setLayout(null);
jp.add(jb);
jb.setBounds(100,100,100,100);
jp.add(jb1);
jb1.setBounds(2100,210,50,50);
this.setVisible(true);
}
public static void main(String args[]) {
new myFrame();
}
}
#3
or
import javax.swing.*;
public class myFrame extends JFrame {
JPanel contentPanel=(JPanel)this.getContentPane();
JPanel jp=new JPanel();
JButton jb=new JButton("1");
JButton jb1=new JButton("2");
public myFrame() {
super("myFrame");
this.setSize(800,600);
this.setResizable(true);
this.setLocation(this.getToolkit().getScreenSize().width/2-400,this.getToolkit().getScreenSize().height/2-300);
contentPanel.setLayout(new BorderLayout());
contentPanel.add("Center",jp);
jp.setLayout(new FlowLayout());
jp.add(jb);
jp.add(jb1);
this.setVisible(true);
}
public static void main(String args[]) {
new myFrame();
}
}
import javax.swing.*;
public class myFrame extends JFrame {
JPanel contentPanel=(JPanel)this.getContentPane();
JPanel jp=new JPanel();
JButton jb=new JButton("1");
JButton jb1=new JButton("2");
public myFrame() {
super("myFrame");
this.setSize(800,600);
this.setResizable(true);
this.setLocation(this.getToolkit().getScreenSize().width/2-400,this.getToolkit().getScreenSize().height/2-300);
contentPanel.setLayout(new BorderLayout());
contentPanel.add("Center",jp);
jp.setLayout(new FlowLayout());
jp.add(jb);
jp.add(jb1);
this.setVisible(true);
}
public static void main(String args[]) {
new myFrame();
}
}
#4
不要使用xylayout!
#5
提供点参考:
1。捕捉修改大小的事件,自己按照比例重画。
2。禁止修改大小。
1。捕捉修改大小的事件,自己按照比例重画。
2。禁止修改大小。
#6
getToolkit().getScreenSize()用这个可以取得屏幕尺寸,剩下的自己想把
#7
定义组键的尺寸,可以用GridBagConstraints里的,ipadx和ipday确定,
也可以用setPreferredSize(new Dimension(int x,int y))来设置大小!
也可以用setPreferredSize(new Dimension(int x,int y))来设置大小!
#8
很简单,用layout嘛
#9
只要布局用borderlayout就可以实现。
#10
可以尝试:
setLayout(null);
再用
setBounds(x,y,width,height);
定位.
应该可以,虽然很多书上不推荐用setLayout(null)
setLayout(null);
再用
setBounds(x,y,width,height);
定位.
应该可以,虽然很多书上不推荐用setLayout(null)
#11
这个问题不太好解决,比方说还有字体大小的问题,要控件大小和字体大小都随窗体的改变而改变可得费点工夫
#12
maybe you need to use multi-layouts to solve that problem. I am not sure of what results you want ultimately.