可以用EXP或X^Y,或者如下方法:
import javax.swing.*;
import java.awt.*;
class UP extends JFrame {
private static final Dimension minSize = new Dimension(300, 200);
private static final Dimension maxSize = new Dimension(1024, 768);
private static final Dimension preferredSize = new Dimension(600, 400);
public Dimension getMaximumSize() {return maxSize;}
public Dimension getMinimumSize() {return minSize;}
public Dimension getPreferredSize() {return preferredSize;}
public String getTitle() {return "Frame Title";}
UP() throws HeadlessException {
doLay();
attachListeners();
}
private void doLay() {
Container container = getContentPane();
//重点是这一句
container.add(new JButton("XY"),BorderLayout.NORTH);
pack();
}
private void attachListeners() {setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}
public static void main(String[] args) {new UP().setVisible(true);}
}
换想法
写成
x^y
或者用xy
通过value,text或者innerHTML试试。