2012-06-16 6 views
0

프레임을 JWindow (X 및 - 버튼을 처리하고 싶기 때문에)에서 확장하고 있으므로 장식하고 싶지 않습니다. 내 문제는 응용 프로그램을 실행할 때 내 창을 끌 수 없다는 것입니다. 특정 위치에서 고정되어 있습니다.JWindow의 윈도우가 움직이지 않는다.

공용 클래스 StatisticsMainFrame이 JWindow의 {

public StatisticsMainFrame() 
{ 
    bodyPane = new JPanel(); 
    bodyPane.setLayout(new BoxLayout(bodyPane, BoxLayout.X_AXIS)); 
    sideBannerPane = new JPanel(); // program banner 
    buttonsPane = new JPanel(); // contains buttons 
    contentPane = new JPanel(); 
    contentPane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); 
    contentPane.setPreferredSize(new Dimension(500,500)); 
    // contentPane contains some panel for display data 


    Container container = new Container(); 
    container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS)); 
    container.add(Box.createVerticalGlue()); 
    container.add(sideBannerPane); 
    container.add(buttonsPane); 
    container.add(contentPane); 

    Container cont = new Container(); 
    cont.setLayout(new BoxLayout(cont, BoxLayout.Y_AXIS)); 
    //cont.add(Box.createHorizontalGlue()); 
    //cont.add(custDecorationPane); 
    cont.add(container); 
    add(cont); 
    // Adding Panes 

    setAlwaysOnTop(true); 
    //setUndecorated(true); 
    pack(); 

} 

public static void main(String[] arg) 
{ 
    new StatisticsMainFrame().setVisible(true); 
} 


private CustomFrameDecorationButtons custDecorationPane; 
private JPanel bodyPane; 
private JPanel contentPane; 
private JPanel sideBannerPane; 
private JPanel buttonsPane; 

// buttonsPane components 
private JLabel general_lbl; 
private JLabel Diagnosis_lbl; 
private JLabel chemotherapy_lbl; 
private JLabel radiotherapy_lbl; 
private JLabel surgery_lbl; 
private JLabel hermonalTherapy_lbl; 

private RootButton generalStatistics_btn; 
private RootButton statOfAffectedSys_btn; 
private RootButton statOfGrade_btn; 
private RootButton statOfCombinations_btn; 
private RootButton statOfResponses_btn; 
private RootButton statOfRadiotherapy_btn; 
private RootButton statOfSurgery_btn; 
private RootButton statOfHermonaltherapy_btn; 

private GeneralStatisticsContentPanel generalStatPane; 
private StatisticsOfAffectedSystemPanel2 statOfAffectedSysPanel2; 
private StatisticsOfGradePanel statOFGradingPanel; 
private ChemotherapyCombinationStatisticsPanel statChemotherapyCombinationPanel; 
private ChemotherapyResponseStatisticsPanel statChemotherapyResponsePanel; 
private RadiotherapyStatisticsPanel radiotherapyPanel; 
private SurgeryStatisticsPanel surgeryStatPanel; 
private HermonaltherapyStatisticsPanel hermonaltherapy; 

}을 확장 당신은 예제에 대한 사용하여 사용자 정의 드래그를 추가 할 수 있습니다

+0

코드에서'JWindow'를 볼 수 없습니다. [SSCCE] (http://pscode.org/sscce.html)를 게시 하시겠습니까? – Howard

+0

thnx asif ... 실제로 나는이 일을하지만 때로는 부적절한 답변을 .. 어쨌든 thnx .. – BDeveloper

+0

나는 내 코드를 지금 업데이트했습니다. – BDeveloper

답변

6

: (클래스 내가 큰 그래서 난 관련 섹션을 집어)는 다음과 같이 내 코드는 다음 코드는 StatisticsMainFrame의 생성자에서 직접이 조각을 배치하면

addMouseMotionListener(new MouseMotionListener() { 
    private int mx, my; 

    @Override 
    public void mouseMoved(MouseEvent e) { 
     mx = e.getXOnScreen(); 
     my = e.getYOnScreen(); 
    } 

    @Override 
    public void mouseDragged(MouseEvent e) { 
     Point p = StatisticsMainFrame.this.getLocation(); 
     p.x += e.getXOnScreen() - mx; 
     p.y += e.getYOnScreen() - my; 
     mx = e.getXOnScreen(); 
     my = e.getYOnScreen(); 
     StatisticsMainFrame.this.setLocation(p); 
    } 
}); 

당신은을 클릭하여 창을 드래그하여 마우스를 사용할 수 있습니다 창 안쪽. (다른 컴포넌트에도 리스너를 추가 할 수 있습니다.)

관련 문제