当前位置: 技术问答>java相关
寻人启示一个名叫 hhjgx(何躝) 的大侠请进来!
来源: 互联网 发布时间:2015-08-30
本文导语: 好感谢你上次回答我的问题,并写下以下程序, 但现在还有个小小的问题,就是怎么把button定位。 谢谢打扰了! import java.awt.*; import javax.swing.*; public class ShowButton extends JFrame { JPanel jPanel1 = new JPanel(); ...
好感谢你上次回答我的问题,并写下以下程序,
但现在还有个小小的问题,就是怎么把button定位。
谢谢打扰了!
import java.awt.*;
import javax.swing.*;
public class ShowButton extends JFrame {
JPanel jPanel1 = new JPanel();
JButton f1 = new JButton();
JButton f2 = new JButton();
JButton f3 = new JButton();
JButton f4 = new JButton();
JButton f5 = new JButton();
JButton f6 = new JButton();
JButton f7 = new JButton();
JButton f8 = new JButton();
JButton f9 = new JButton();
private JButton buttonArray[]={f1,f2,f3,f4,f5,f6,f7,f8,f9};
JScrollPane scrollPane = new JScrollPane();
public static void main(String args[]) {
new ShowButton();
}
public ShowButton() {
try{
jbInit();
} catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
scrollPane.setAutoscrolls(true);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.Y_AXIS) );
for(int i=0;i
但现在还有个小小的问题,就是怎么把button定位。
谢谢打扰了!
import java.awt.*;
import javax.swing.*;
public class ShowButton extends JFrame {
JPanel jPanel1 = new JPanel();
JButton f1 = new JButton();
JButton f2 = new JButton();
JButton f3 = new JButton();
JButton f4 = new JButton();
JButton f5 = new JButton();
JButton f6 = new JButton();
JButton f7 = new JButton();
JButton f8 = new JButton();
JButton f9 = new JButton();
private JButton buttonArray[]={f1,f2,f3,f4,f5,f6,f7,f8,f9};
JScrollPane scrollPane = new JScrollPane();
public static void main(String args[]) {
new ShowButton();
}
public ShowButton() {
try{
jbInit();
} catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
scrollPane.setAutoscrolls(true);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.Y_AXIS) );
for(int i=0;i