close
public class MessagePane extends JPanel { private static final long serialVersionUID = 1L; @Override protected void paintComponent(final Graphics g) { final Graphics2D graphics2D = (Graphics2D) g; RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); graphics2D.setRenderingHints(qualityHints); graphics2D.setPaint(Color.ORANGE); int width = getWidth(); int height = getHeight(); GeneralPath path = new GeneralPath(); path.moveTo(0, 0); path.lineTo(width, 0); path.lineTo(width, height-10); path.lineTo(width / 2 + 5, height-10); path.lineTo(width / 2, height); path.lineTo(width / 2 - 5, height-10); path.lineTo(0, height - 10); path.closePath(); graphics2D.fill(path); } public static void main(String[] args) { JWindow f = new JWindow(); f.setSize(100, 107); f.setLocationRelativeTo(null); MessagePane panel = new MessagePane(); f.add(panel); f.setBackground(new Color(0, 0, 0, 0)); f.setVisible(true); } }
}
文章標籤
全站熱搜