0

Design

| Design your own label that is able to have a vertical text with shadow, and two thick lines at the bottom and top of the label. Your label should look like the labels in the following shape

12th May 2020, 5:40 PM
jehan najjar
1 ответ
0
This is my attempt import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.font.TextLayout; import java.io.IOException; import java.awt.geom.AffineTransform; import javax.swing.JFrame; import javax.swing.JLabel; public class Main extends JLabel { public Main() { } public void paint(Graphics g) { String text = "Bay Bay World"; int x = 100; int y = 100; Font font = new Font("Georgia", Font.ITALIC, 45); Graphics2D g1 = (Graphics2D) g; TextLayout textLayout = new TextLayout(text, font, g1.getFontRenderContext()); g1.setPaint(new Color(150, 150, 150)); textLayout.draw(g1, x + 5, y + 3); g1.setPaint(Color.BLACK); textLayout.draw(g1, x, y); } public static void main(String[] args) throws IOException { JFrame f = new JFrame(); f.add(new Main()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(550, 450); f.setVisible(true); } }
12th May 2020, 5:44 PM
jehan najjar