形状反锯齿
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
文字反锯齿
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
Swing拆分窗格控件
package Text;
import javax.swing.*;
import java.awt.Color;
public class demo1 {
public static void main(String[] args)
{
JFrame frame=new JFrame ("显示");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
JPanel j1= new JPanel();
JPanel j2= new JPanel();
j1.setBackground(Color.red);
j2.setBackground(Color.green);
JSplitPane splitPane=new JSplitPane();//创建一个分割容器类
splitPane.setOneTouchExpandable(true);//让分割线显示出箭头
splitPane.setContinuousLayout(true);//操作箭头,重绘图形
splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);//设置分割线方向 纵向分布
splitPane.setLeftComponent(j1);//设置左边的组件
splitPane.setRightComponent(j2);//设置右边的组件
splitPane.setDividerSize(1);//设置分割线的大小(分割线的宽度)
splitPane.setDividerLocation(60);//设置分割线的起始位置
frame.setContentPane(splitPane);
//frame.pack(),这个函数的作用就是根据窗口里面的布局及组件的preferedSize来确定frame的最佳大小。
frame.pack();
}
}
形状反锯齿
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
文字反锯齿
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);