高分求助!关于Swing方面的问题 这里有一个关于scoll的例子http://javaboutique.internet.com/Scrollup/ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Frame1 extends JFrame { private JPanel contentPane; private JLabel jLabel1 = new JLabel(); private JButton jb=new JButton("click"); private JPanel jp=new JPanel(new FlowLayout()); private JScrollPane jscr=new JScrollPane(); private JTextArea jta=new JTextArea(); public Frame1() { super("myFrame"); this.setSize(400,300); this.setResizable(false); this.setLocation(this.getToolkit().getScreenSize().width/2-this.getWidth()/2,this.getToolkit().getScreenSize().height/2-this.getHeight()/2); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add("South",jp); contentPane.add("Center",jscr); jscr.getViewport().add(jta); jta.setText("start\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nend"); jp.add(jb); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { click(e); } }); this.setSize(new Dimension(400, 300)); this.setTitle("Frame Title"); for(int i=1;i<=9;i++) { for(int j=1;j<=i;j++) { if(j!=1) System.out.print(","); System.out.print(j+"*"+i+"="+i*j); } System.out.println(""); } this.setVisible(true); } public void click(ActionEvent e) { this.jta.requestFocus(); this.jta.setSelectionStart(this.jta.getText().length()); this.jta.setSelectionEnd(this.jta.getText().length()); } public static void main(String args[]) { new Frame1(); }} to: beyond_xiruo(希偌) 太强了你怎么有这么多时间来写啊 简单日期格式问题?急。。。。。在线等! 迷惑的正则表达式 相对路径的问题(与web无关) snmp协议 如何获取局域网电脑Cpu负载和内存使用率 两个简单的问题!! java.awt类? 怎样提前结束方法? 求大神,java怎么运行一个外部的.class文件并获得输出呢? 神,如何在子窗口中调用父窗口的变量? 谁现在学thinkinjava了,留个qq,,,好多问题我自己弄不明白/// 请教:关于线程的问题。 串行化有什么作用?
import java.awt.event.*;
import javax.swing.*;public class Frame1 extends JFrame {
private JPanel contentPane;
private JLabel jLabel1 = new JLabel();
private JButton jb=new JButton("click");
private JPanel jp=new JPanel(new FlowLayout());
private JScrollPane jscr=new JScrollPane();
private JTextArea jta=new JTextArea();
public Frame1() {
super("myFrame");
this.setSize(400,300);
this.setResizable(false);
this.setLocation(this.getToolkit().getScreenSize().width/2-this.getWidth()/2,this.getToolkit().getScreenSize().height/2-this.getHeight()/2);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add("South",jp);
contentPane.add("Center",jscr);
jscr.getViewport().add(jta);
jta.setText("start\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nend");
jp.add(jb);
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
click(e);
}
});
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
for(int i=1;i<=9;i++) {
for(int j=1;j<=i;j++) {
if(j!=1)
System.out.print(",");
System.out.print(j+"*"+i+"="+i*j);
}
System.out.println("");
}
this.setVisible(true);
} public void click(ActionEvent e) {
this.jta.requestFocus();
this.jta.setSelectionStart(this.jta.getText().length());
this.jta.setSelectionEnd(this.jta.getText().length());
} public static void main(String args[]) {
new Frame1();
}
}
你怎么有这么多时间来写啊