?? testframe.java
字號(hào):
/**
* Copyright 1999-2002 Matthew Robinson and Pavel Vorobiev.
* All Rights Reserved.
*
* ===================================================
* This program contains code from the book "Swing"
* 2nd Edition by Matthew Robinson and Pavel Vorobiev
* http://www.spindoczine.com/sbe
* ===================================================
*
* The above paragraph must be included in full, unmodified
* and completely intact in the beginning of any source code
* file that references, copies or uses (in any way, shape
* or form) code contained in this file.
*/
import java.awt.*;
import javax.swing.*;
class TestFrame extends JFrame
{
public TestFrame() {
super( "Lets get it straight!" );
getContentPane().add(new JCanvas());
}
public static void main( String args[] ) {
TestFrame mainFrame = new TestFrame();
mainFrame.pack();
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 1.3
mainFrame.setVisible( true );
}
}
class JCanvas extends JComponent
{
private static Font m_biFont = new Font("Monospaced", Font.BOLD, 36);
public void paintComponent(Graphics g) {
g.setColor(Color.black);
// Bold 36-point "Swing"
g.setFont(m_biFont);
FontMetrics fm = g.getFontMetrics();
int h = fm.getAscent();
g.drawString("Swing",50,50); // Try these as well:
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -