0
좋은 하루도구 모음 크기 조정
ImageIcon 단추를 추가 한 기본 도구 모음이 있습니다. 그러나 이미지의 크기가 다릅니다. 아이콘의 크기를 조정하면 모든 크기가 같아집니다.
super("ToolBar");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//creating the icons for the toolbar
ImageIcon savePic = new ImageIcon("c:/Exercises/unitTwo/Chapter Three/Images/save.png");
ImageIcon openFilePic = new ImageIcon("c:/Exercises/unitTwo/Chapter Three/Images/open.png");
ImageIcon printPic = new ImageIcon("c:/Exercises/unitTwo/Chapter Three/Images/print.png");
//creating buttons with initial text and icons. I.o.w. the buttons for the toolbar are created
JButton save = new JButton("Save", savePic);
JButton open = new JButton("Open", openFilePic);
JButton print = new JButton("Print", printPic);
JToolBar bar = new JToolBar();
bar.add(save);
bar.add(open);
bar.add(new JToolBar.Separator());
bar.add(print);
JTextArea text = new JTextArea(10, 40);
add(BorderLayout.NORTH, bar);
add(BorderLayout.CENTER, text);
pack();
setVisible(true);
Gimp (http://www.gimp.org/)와 같은 일부 이미지 편집기를 사용하여 프로그램 외부의 이미지를 편집하십시오. –
저장, 열기 및 인쇄와 같은 아이콘 라이브러리를 사용할 수있는 경우 (동일한 너비와 높이의 아이콘을 제공함), 페인트 프로그램을 사용하거나 실행 중에 일부 이미지를 적용하려고 시도하는 것보다 그 세트 중 하나를 사용하는 경향이 있습니다 -시각. 이러한 작은 이미지의 크기를 조정하면 종종 끔찍한 아이콘이 나타납니다. –