Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8110485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:46:27+00:00 2026-06-06T01:46:27+00:00

I have a frame extends from JWindow (because I want to handle my X

  • 0

I have a frame extends from JWindow (because I want to handle my X and – buttons) so I don’t want it decorated. My problem is when I run the application I can’t drag my window – it’s fixed in a certain location. My code is as follows (the class i big so i picked the related section):

public class StatisticsMainFrame extends 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;

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:46:28+00:00Added an answer on June 6, 2026 at 1:46 am

    You can add a custom drag using for example the following code:

    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);
        }
    });
    

    If you place this snippet directly in the constructor of StatisticsMainFrame you can use the mouse to drag the window by clicking anywhere inside the window. (You can also add the listener to any other component.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have downloaded Play Framework from GitHub and compiled it. Now I want to
I have an asynctask that reads data from a device and then I want
I have a strange problem that probably stems from lack of understanding of how
I want to create a single shape file from multiple mxd's that have multiple
I have a main frame and a attached collapsible panel that i got from
I have three JPanels inside a main Frame. Clockwise from the left, in the
I have a JFrame which contains a JPanel . The frame can be resized
My main class loads configuration from a file then shows a frame. I want
I have frame buffer, with depth component and 4 color attachments with 4 textures
I have data frame with some numerical variables and some categorical factor variables. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.