1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TextViewer {
public static void main(String[] args) {
String text = "HELLO !";
int x = 0;
int y = 20;
JFrame frame = new JFrame();
/*
* drawString dans la frame, ca fonctionne
frame.add(new DrawText(text, x, y));
*/
/*
* drawString dans le panel, puis ajout du pannel dans la frame, ca fonctionne pas...
JPanel textPanel = new JPanel();
textPanel.add(new DrawText(text, x, y));
frame.add(textPanel, BorderLayout.NORTH);
*/
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,400);
frame.setVisible(true);
}
} |
Partager