需要按照以下编程进行操作就行:
HSSFCellStyle style = (HSSFCellStyle) wb.createCellStyle()
style.setFont(font)
cell.setCellStyle(style)
CellStyle style = workBook.createCellStyle()
HSSFFont font = workBook.createFont()
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD)//粗体显示
style.setFont(font)
cell1.setCellStyle(style)//给cell1这个单元格设置样式
比如按钮里面的文字需要黑色加粗;buttons1.setFont(new Font("",Font.BOLD,25))三个参数分别为:指定名称、样式和大小; BOLD为粗体;至于颜色默认为黑色,其他颜色我也忘了怎么设置了;应该是可以的;import javax.swing.*import java.awt.*
class DrawPanel extends JPanel{
private int x = 25
private int y = 50
public void paintComponent(Graphics g)
{
super.paintComponent(g)
int radius = 10
Graphics2D g2d=(Graphics2D)g
Stroke stroke=new BasicStroke(3.0f)//设置线宽为3.0
g2d.setStroke(stroke)
Font f = new Font("Times New Roman", Font.BOLD+Font.ITALIC, 30)
g2d.setFont(f)
g2d.drawString("2008 Beijing Olympic Game ", x, y)
g2d.setColor(new Color(255,0,0))
g2d.drawArc(35 , 65 , radius, radius, -90, 360)
g2d.setColor(new Color(36,56,242))
g2d.drawArc(85 , 65 , radius, radius, -90, 360)
g2d.setColor(new Color(49,222,35))
g2d.drawArc(10 , 105 , radius, radius, -90, 360)
g2d.setColor(new Color(240,245,33))
g2d.drawArc(60 , 105 , radius, radius, -90, 360)
g2d.setColor(new Color(0,0,0))
g2d.drawArc(110 , 105, radius, radius, -90, 360)
}