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 7622517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:28:28+00:00 2026-05-31T04:28:28+00:00

I have a Jwindow, and when I added a Jtextfield to it, the textfield

  • 0

I have a Jwindow, and when I added a Jtextfield to it, the textfield became uneditable.

JWindow window = new JWindow();
window.setBounds(400, 100, 700,500);
window.setVisible(true);
window.setLayout(null);
JTextField text = new JTextField();
text.setBounds(300, 300, 150, 30);
text.setEditable(true);       
window.getContentPane().add(text);

But when I tried to use Jframe as Jwindow’s owner, the textfield was now editable, but the frame showed up together with the jwindow :

JFrame frame = new JFrame();
frame.setVisible(true);
JWindow window = new JWindow();
window.setBounds(400, 100, 700,500);
window.setVisible(true);
window.setLayout(null);
JTextField text = new JTextField();
text.setBounds(300, 300, 150, 30);
text.setEditable(true);       
window.getContentPane().add(text);

So, I have 2 questions :

  1. Why JTextField is uneditable in JWindow and how could I make it editable?
  2. What is the main purpose of using JFrame as JWindow’s border?
  • 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-05-31T04:28:29+00:00Added an answer on May 31, 2026 at 4:28 am

    EDIT,

    • contents of JWindow is accesible only if its parent is displayed on the screen

    • for editable and accesible contents use un_decorated JDialog instead of JWindow, jDialog doesn’t caused non_accesible contents,

    • reason why …, I can’t explain, not undestand why, no way in this moment, the API says me nothing about caused accesible, editable …

    .
    .
    .

    1. Why JTextField is uneditable in JWindow and how could i let it able to edit?
    

    really don’t know

    import java.awt.*;
    import javax.swing.*;
    
    public class WindowTest {
    
        private JFrame frame;
    
        public JPanel createContentPane() {
            JTextField text = new JTextField("Whatewer");        
            JPanel panel = new JPanel();
            panel.add(text);
            createAndShowWindow();
            return panel;
        }
    
        void createAndShowGUI() {
            frame = new JFrame("Window Test");
            frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            frame.setContentPane(createContentPane());
            frame.setLocation(50, 50);
            frame.pack();
            frame.setVisible(true);
        }
    
        private void createAndShowWindow() {
            JTextField text = new JTextField("Whatewer");
            JWindow win = new JWindow(frame);
            win.setLayout(new GridLayout(0, 1));
            win.add(text);
            win.pack();
            win.setLocation(150, 50);
            win.setVisible(true);
        }
    
        public static void main(String args[]) {
            EventQueue.invokeLater(new Runnable() {
    
                public void run() {
                    new WindowTest().createAndShowGUI();
                }
            });
        }
    }
    

    EDIT

    Yes, both are editable, and i wannt only JWindow to be displayed. Thanks!! 
    
    • by default JWindow required JFrame for correct workaround

    • nobody tell that this JFrame must be visible (valid for GUI), then remove these code lines from frame.setDefaultClose…. including frame.setVisible(true); from my example

    • in this form current JVM instance never gone from RAM, untill your PC restarted or swith off, you have to add separated exit JButton with code line System.exit(0) inside ActionListener

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

Sidebar

Related Questions

I have 3 layered window (like Gimp software). All my JWindow is assigned to
I have a frame and a JWindow. In my frame I have a textfield,
I have a JWindow and a JFrame both I have made runnable and both
Have following listener for keyboard ArrowDown event(it's key code is 40 ): window.onload =
Have converted devise new session from erb to Haml but doens't work, this is
I am new to Swing. There is a silly question that I have. It
Have some code: using (var ctx = new testDataContext()) { var options = new
I have to create a Matlab figure window with custom maximize/minimize and close buttons.
have an an array String classname[]={'a','b','c','d'}; ArrayAdapter<CharSequence> adapterClasses = new ArrayAdapter<CharSequence>( getApplicationContext(), R.layout.spinner_item_class, R.id.spinnerclasstxt,
I have a JFrame , inside the JFrame code I create a JWindow and

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.