JDesktopPane
에 버튼을 추가 할 수 있습니다. JDesktopPane
에는 레이아웃 관리자가 없으므로 크기와 위치를 지정하는 것을 잊지 마세요. 다음은 예입니다

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import javax.swing.*;
public class TestInternalFrame {
private static void createAndShowUI() {
JDesktopPane pane = new JDesktopPane() {
@Override
public Dimension getPreferredSize() {
return new Dimension(300, 200);
}
};
pane.setBackground(Color.WHITE);
addFrame(pane, new Point(50, 20), "Window1");
addFrame(pane, new Point(60, 30), "Window2");
addIcon(pane, new Point(5, 5), "Action",
UIManager.getIcon("OptionPane.informationIcon"));
JFrame frame = new JFrame("Desktop");
frame.add(pane);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
private static void addFrame(JDesktopPane pane, Point p, String title) {
JInternalFrame frame = new JInternalFrame(title);
frame.setSize(200, 100);
frame.setLocation(p);
frame.setResizable(true);
frame.setMaximizable(true);
frame.setIconifiable(true);
frame.setClosable(true);
frame.setVisible(true);
pane.add(frame);
}
private static void addIcon(JDesktopPane pane, Point p, String text, Icon icon) {
JButton button = new JButton(text, icon);
button.setVerticalTextPosition(SwingConstants.BOTTOM);
button.setHorizontalTextPosition(SwingConstants.CENTER);
button.setBounds(new Rectangle(p, button.getPreferredSize()));
pane.add(button);
}
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
createAndShowUI();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
무엇을, 어디서, 어떻게, 왜, 빨리 SSCCE, 짧은 실행 가능한, – mKorbel
컴파일 가능한 내 전체 프로그램을 게시 할 것을 게시 더 나은 도움을. 나는 올바른 방향으로 나를 가리키게 할 무언가가 필요하다. 나는 질문을 더 많은 정보로 업데이트 할 것이다. –