다음 코드를 고려하십시오JPanel을 확장하는 클래스에서 파일로드/저장을위한 메뉴 막대를 추가하는 방법은 무엇입니까?
/**
* Main class
* @author X2
*
*/
class DrawingPanel extends JPanel implements MouseListener, MouseMotionListener ,KeyListener
{
/**
* private variables
*/
// dimensions of the window
private static final long serialVersionUID = 1L;
private static final Dimension MIN_DIM = new Dimension(300, 300);
private static final Dimension PREF_DIM = new Dimension(500, 500);
/**
* Setting the dimensions of the window
*/
public Dimension getMinimumSize() { return MIN_DIM; }
public Dimension getPreferredSize() { return PREF_DIM; }
/**
* The constructor
*/
DrawingPanel()
{
super();
addMouseListener(this);
addMouseMotionListener(this);
addKeyListener(this);
setFocusable(true);
requestFocusInWindow();
}
public void paintComponent(Graphics g)
{
// code
}
public void mouseClicked(MouseEvent evt)
{ // code
}
// more code
어떻게 내가 개방 및 저장 파일에 대한 옵션을 필요로 내 창에 패널을 추가 할 수 있습니다.
는 순간 창은 다음과 같습니다
감사