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

  • Home
  • SEARCH
  • 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 6692289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:51:03+00:00 2026-05-26T05:51:03+00:00

import java.awt.BorderLayout; import java.awt.FlowLayout; import javax.swing.*; public class FileCutter { public static void main(String[]

  • 0
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.*;

public class FileCutter
{
    public static void main(String[] args)
    {
        CutterWindow cw = new CutterWindow();
        cw.setResizable(false);
        cw.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        cw.setVisible(true);
    }
}

class CutterWindow extends JFrame
{
    private JTabbedPane tabbedPane = new JTabbedPane();

    public static final int DEFAULT_WIDTH = 470;
    public static final int DEFAULT_HEIGHT = 480;
    public CutterWindow()
    {
        this.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
        tabbedPane.add("File Cut",new FileCutPanel());
        this.add(tabbedPane);
    }

}

class FileCutPanel extends JPanel
{   
    private JLabel lblFileName =  new JLabel("File Name:");
    private JTextField txtFileName = new JTextField();
    private JLabel lblFileSize = new JLabel("File Size:");
    private JTextField txtFileSize = new JTextField();
    private JButton btnViewFiles = new JButton("...");

    private JPanel panelSelectOperatingFile = new JPanel();

    public FileCutPanel()
    {   
        panelSelectOperatingFile.setLayout(new FlowLayout());
        panelSelectOperatingFile.add(lblFileName);
        txtFileName.setColumns(20);
        txtFileName.setEditable(false);
        panelSelectOperatingFile.add(txtFileName);
        panelSelectOperatingFile.add(btnViewFiles);
        panelSelectOperatingFile.add(lblFileSize);
        panelSelectOperatingFile.add(txtFileSize);
        txtFileSize.setColumns(20);
        txtFileSize.setEditable(false);

        this.add(panelSelectOperatingFile);
    }
}

the result is that the five component in the panelSelectOperatingFile Panel are in the same line and beyond the width of the window. and i know that the default layout of the JPanel is flowlayout, i expected that the components will be put in the next line when there is no space in the previous line. and i try to figure out the problem, but i can’t

  • 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-26T05:51:04+00:00Added an answer on May 26, 2026 at 5:51 am

    Do not use the panelSelectOperatingFile panel. Just add your components to the JPanel you are extending.

    You can’t nest FlowLayouts. Here is why:

    Oracle FlowLayout Tutorial

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

Sidebar

Related Questions

Here is my code: import javax.swing.*; import java.awt.*; public class PanelModel { public static
import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class tictac2 implements ActionListener{ static
Here I found this code: import java.awt.*; import javax.swing.*; public class FunWithPanels extends JFrame
package test; import java.awt.*; import java.awt.event.*; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; import javax.swing.*; public class
Here is the code: import javax.swing.*; import java.awt.event.*; import java.awt.*; public class TestGrid {
I have a sample code : import java.awt.*; import javax.swing.*; import javax.swing.border.BevelBorder; public class
import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.lang.Thread; public class Lthread extends JPanel{ private
When I try to compile this: import java.awt.* ; class obj { public static
My code so far: import java.awt.BorderLayout; import java.awt.Container; import javax.swing.Box; import javax.swing.JFrame; import javax.swing.JLabel;
Consider: import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.crypto.*; import javax.crypto.spec.*; import java.security.*; import

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.