import java.awt.*;
import java.awt.geom.Line2D;
import javax.swing.*;
public class Options {
public static void main(String[] args) {
JFrame frame = new JFrame("謝孜妤Java繪製選擇權到期日損益");
Container cp = frame.getContentPane();
cp.add(new JComponent() {
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setStroke(new BasicStroke(2));//stroke中風,筆觸
g2.setFont(new Font("monospaced", Font.BOLD|Font.ITALIC , 30));
g2.setColor(Color.black);
g2.drawString("買入賣權到期日損益",0,120);
g2.draw(new Line2D.Float(0, 0, 100, 100));
g2.draw(new Line2D.Float(100, 100, 200, 100));
g2.drawString("買入買權到期日損益",300,120);
g2.draw(new Line2D.Float(300, 100, 400, 100));
g2.draw(new Line2D.Float(400, 100, 500, 0));
g2.drawString("賣出賣權到期日損益",0,180);
g2.draw(new Line2D.Float(0, 300, 100, 200));
g2.draw(new Line2D.Float(100, 200, 200, 200));
g2.drawString("賣出買權到期日損益",300,180);
g2.draw(new Line2D.Float(300, 200, 400, 200));
g2.draw(new Line2D.Float(400, 200, 500, 300));
g2.drawString("謝孜妤",200,300);
g2.setColor(Color.blue);
}
});
frame.setSize(550, 350);
frame.setVisible(true);
}
}
截圖太多空白,浪費資源。https://kitty030994.blogspot.com/2024/01/java.html
回覆刪除