Panels resizable contained in a frame resizable

Hello to all,
I have the following question, how is it possible to make resizable the panels contained in the frame when frame's resized by the user?
I had already a look at the swing tutorial but I didn't find the solution :( (may be I didn't understand )
Can anybody help me?
I attach here bellow my code
Thansk in advance
Mandy
ublic class SecondClass  extends JFrame{     
     JTextArea cfgArea;
     JTextArea relArea;
     JTextArea resultArea;
     JComboBox searchModeCB;
     public SecondClass(){
         JFrame frame = new JFrame("title");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.setResizable(true);
         JPanel mainPanel = new JPanel();
         mainPanel.setBackground(Color.cyan);
         mainPanel.setSize(600,400);
         mainPanel.setLayout(null);
         JPanel  cfgPane = new JPanel ();
         cfgPane.setLayout(null);
         cfgPane.setBackground(Color.red);
         cfgPane.setBounds(10,10,370,280);
         mainPanel.add(cfgPane);
         cfgArea = new JTextArea();
         cfgArea.setBorder(BorderFactory.createEtchedBorder());
         cfgArea.setDragEnabled(true);
         cfgArea.setTransferHandler(new CustomedTransferHandler());
         cfgArea.setDropMode(DropMode.INSERT);
         JScrollPane cfgScrollPane = new JScrollPane(cfgArea);
         cfgScrollPane.setBounds(10, 20, 350, 200);
         cfgPane.add(cfgScrollPane);
         JButton clearCfgButton = new JButton("Clear");
         clearCfgButton.setBounds(70, 230, 70, 20);
         cfgPane.add(clearCfgButton);
         JButton addCfgButton = new JButton("Add");
         addCfgButton.setBounds(200, 230, 60, 20);
         cfgPane.add(addCfgButton);
         mainPanel.add(cfgPane);
         JPanel relPane =  new JPanel();
         relPane.setLayout(null);
         relPane.setBackground(Color.blue);
         relPane.setBounds(10,300,370,280);
         mainPanel.add(relPane);
         relArea = new JTextArea();
         relArea.setBorder(BorderFactory.createEtchedBorder());
         relArea.setDragEnabled(true);
         relArea.setTransferHandler(new CustomedTransferHandler());
         relArea.setDropMode(DropMode.INSERT);
         JScrollPane relScrollPane = new JScrollPane(relArea);
         relScrollPane.setBounds(10, 20, 350, 200);
         relPane.add(relScrollPane);
         JButton clearRelButton = new JButton("Clear");
         clearRelButton.setBounds(20, 230, 70, 20);
         relPane.add(clearRelButton);
         JButton addRelButton = new JButton("Add");
         addRelButton.setBounds(110, 230, 60, 20);
         relPane.add(addRelButton);
         String[] items = {"Something"};
         searchModeCB = new JComboBox(items);
         searchModeCB.setBounds(180, 230, 180, 20);
         searchModeCB.setSelectedItem("Something");
         relPane.add(searchModeCB);
         JButton okRelButton = new JButton("Ok");
         okRelButton.setBounds(300, 255, 60, 20);
         relPane.add(okRelButton);
         JPanel resultPane = new JPanel();
         resultPane.setLayout(null);
         relPane.setBackground(Color.yellow);
         resultPane.setBounds(390,10,580,570);
         resultArea = new JTextArea();
         resultArea.setBorder(BorderFactory.createEtchedBorder());
        mainPanel.add(resultPane);
         JScrollPane resultScrollPane = new JScrollPane(resultArea);
         resultScrollPane.setBounds(10, 20, 560, 490);
         resultPane.add(resultScrollPane);
         JButton clearResButton = new JButton("Clear");
         clearResButton.setBounds(120, 520, 80, 20);
         resultPane.add(clearResButton);
         JButton saveResultButton = new JButton("Save");
         saveResultButton.setBounds(380, 520, 80, 20);
         resultPane.add(saveResultButton);
         JButton exitButton = new JButton("Exit");
         exitButton.setBounds(495, 550, 80, 15);
         resultPane.add(exitButton);
         frame.add(mainPanel);
         frame.setLocation(200,200);
         int width = 980;
         int height = 650;
         frame.setSize(width, height);
         frame.setVisible(true);
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          SecondClass main = new SecondClass();
}

ok did some modifications.
Now it works as I want
     public SecondClass(){
         JFrame frame = new JFrame("title");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.setResizable(true);
         JPanel  mainPanel = new JPanel ();
         mainPanel.setSize(600,400);
         mainPanel.setLayout(new GridLayout(0,2));
         JPanel sxPanel = new JPanel();
         sxPanel.setBackground(Color.blue);
         sxPanel.setLayout(new GridLayout(2,0));
         mainPanel.add(sxPanel);
         JPanel dxPanel = new JPanel();
         dxPanel.setLayout(new BorderLayout());
         mainPanel.add(dxPanel);
         // Create cfgArea
          JPanel  cfgPane = new JPanel ();
          cfgPane.setLayout(new BorderLayout());
         sxPanel.add(cfgPane);
         cfgPane.add(new JLabel("  "),BorderLayout.NORTH);
         cfgPane.add(new JLabel("  "),BorderLayout.EAST);
         cfgPane.add(new JLabel("  "),BorderLayout.WEST);
         cfgArea = new JTextArea();
         cfgArea.setBorder(BorderFactory.createEtchedBorder());
         cfgArea.setDragEnabled(true);
         cfgArea.setTransferHandler(new CustomedTransferHandler());
         cfgArea.setDropMode(DropMode.INSERT);
         JScrollPane cfgScrollPane = new JScrollPane(cfgArea);
         cfgPane.add(cfgScrollPane,BorderLayout.CENTER);
         JPanel southCfgPanel = new JPanel();
         cfgPane.add(southCfgPanel, BorderLayout.SOUTH);
         JButton clearCfgButton = new JButton("Clear");
         southCfgPanel.add(clearCfgButton);
         JButton addCfgButton = new JButton("Add");
         southCfgPanel.add(addCfgButton);
         //end og cfg Area
         // Create relArea     
         JPanel relPane =  new JPanel();
         relPane.setLayout(new BorderLayout());
         sxPanel.add(relPane);
         relPane.add(new JLabel("  "),BorderLayout.NORTH);
         relPane.add(new JLabel("  "),BorderLayout.EAST);
         relPane.add(new JLabel("  "),BorderLayout.WEST);
         relArea = new JTextArea();
         relArea.setBorder(BorderFactory.createEtchedBorder());
         relArea.setDragEnabled(true);
         relArea.setTransferHandler(new CustomedTransferHandler());
         relArea.setDropMode(DropMode.INSERT);
         JScrollPane relScrollPane = new JScrollPane(relArea);
         relPane.add(relScrollPane,BorderLayout.CENTER);
         JPanel southRelPanel = new JPanel();
         relPane.add(southRelPanel, BorderLayout.SOUTH);
         JButton clearRelButton = new JButton("Clear");
         southRelPanel.add(clearRelButton);
         JButton addRelButton = new JButton("Add");
         southRelPanel.add(addRelButton);
         String[] items = {"Something"};
         searchModeCB = new JComboBox(items);
         searchModeCB.setSelectedItem("Something");
         southRelPanel.add(searchModeCB);
         JButton okRelButton = new JButton("Ok");
         southRelPanel.add(okRelButton);
        //RESULT PANEL
         JPanel resultPane = new JPanel();
         resultPane.setLayout(new BorderLayout());
         dxPanel.add(new JLabel("  "),BorderLayout.NORTH);
         dxPanel.add(new JLabel("  "),BorderLayout.EAST);
         dxPanel.add(new JLabel("  "),BorderLayout.WEST);
         dxPanel.add(resultPane,BorderLayout.CENTER);
         resultArea = new JTextArea();
         resultArea.setBorder(BorderFactory.createEtchedBorder());
         resultPane.add(resultArea,BorderLayout.CENTER);
         JScrollPane resultScrollPane = new JScrollPane(resultArea);
         resultPane.add(resultScrollPane);
         JPanel southPanel = new JPanel();
         resultPane.add(southPanel, BorderLayout.SOUTH);
         JButton clearResButton = new JButton("Clear");
         southPanel.add(clearResButton);
         JButton saveResultButton = new JButton("Save");
         southPanel.add(saveResultButton);
         JButton exitButton = new JButton("Exit");
         southPanel.add(exitButton);
         frame.add(mainPanel);
         frame.setLocation(200,200);
         // Show the frame
         int width = 980;
         int height = 650;
         frame.setSize(width, height);
         frame.setVisible(true);
     }

Similar Messages

  • Is there a way to achieve 'Panel Resize Event Filter' like function?

    Gopalakrishnan P
    Hi all,
    Panel resize filter is not available in Event structure. So if I use the below code, on pressing the maximize button, windows will maximize the front panel and later LabVIEW brings it back to the mentioned size. There will be a flicker during this operation. To avoid this flicker, is it possible to disable windows OS to perform maximize event or to set the default window maximum size in windows or any other way to implement this?
    The maximize button should not be disabled, but  have to maximize the panel to a specific size without that flicker. What I'm actually trying to do is to use windows messaging queue to capture the maximize event and then implement the same through LabVIEW. Related example is in this link http://zone.ni.com/devzone/cda/epd/p/id/4394 
    Has anyone tried solving a similar problem by this method?
    Also please suggest if there is any other way to achieve this.
    Gopal
    Thanks,

    Hi Krishgopal,
    Please try the following method
    File»VI Properties and choose Window Appearance from
    the Category pull-down menu.
    Click the Customize button and Deselect  the option : Allow user the resize window
    Attached is a screenshot of the same.
    Please let me know if this is able to help you out.
    Regards,
    Ankur
    Attachments:
    No_Resize_Front_Panel.pdf ‏274 KB
    Sample_NoResize.vi ‏6 KB

  • Limit Panel Resize to One Dimension?

    Is there an easy way to limit panel resizing to a single dimension? That is, can I make a front panel that allows resizing the HEIGHT but not the WIDTH?
    What would be nice is if there was a way to set the "VI Properties>>Window Size" MAXIMUM size along with minimum (default to <Inf>). But I would settle for a programmatic way to do it, too. I tried making a UE to catch the <Panel: Resize> event, and replace the "Left" and "Right" bounds of the NewBounds with those of the OldBounds, but that ended up doing some wonky stuff.
    Anyone out there found a solution for this problem?
    [I should add, I'm still running LV 8.6.1...maybe this has been addressed in later versions?]

    I'm pretty sure that there isn't, as I don't think Windows supports it and resizing windows is presumably handled by it.
    If there's a window message associated with the resize, you might be able to intercept it using some platform-specific code, but that's beyond the realm of my own experience.
    One thing you can try to do is disable the resizing completely and then add your own resizing logic and code (such as buttons near the edge which will expand or compact the UI by X pixels). I think this is what you usually see in programs which allow expanding in only one direction (although usually the buttons expose an entire pane at once).
    Try to take over the world!

  • Panel Resize - how to tell when mouse released?

    I need to programmatically resize all my controls when the panel is resized.  I can't use the automatic option, as I have some specific things to do, e.g. some controls stay at fixed size, others resize.
    I've used an event structure and am doing the resizing on the "Panel Resize" event.  The problem is that this takes a little time, mainly as one of the controls is an Adobe Reader ActiveX control, which takes a little time to rescale and redraw.
    The result is that the VI seems to queue up the events as the panel is resized - if you grab the corner of the window and move it around, the VI then sits and ploughs through all the events that were created as it was resized.
    What I'm really after is an event that fires after the panel has been resized and the mouse has been released.  Is there a way of achieving this?
    Thanks

    There's no event for this, but you can filter your events, for example, like this:
    There are other variations on this (setting a flag, using a case structure in the original event case, etc.).
    Try to take over the world!
    Attachments:
    Example_BD.png ‏2 KB

  • Problem with panel resize option

    Hi all,
    I am working on an application which i want to run on all the different resolutions. So, i searched the whole LV forum to get the solution for my problem.
    after going through many related discussions i found that one should develop the app in the min resolution which it should support and in the VI properties the option for panel resizing should be tick marked.
    i did exactly the same, but still couldn't get it worked for my application.
    i am developing my app on 1024*768 resolution. it runs fine on the same resolution if i don't tick mark the resizing option. but, when i tick mark the option and run the app on the same resolution, it crops some part from the bottom.
    I am attaching the picture of the interface when run with resizing option and without it.
    Pls look into the prob and let me know how can i make it work?
    Thanks,
    Ritesh 
    Attachments:
    Interface_With proportions.JPG ‏95 KB
    Interface_Without proportions.JPG ‏103 KB

    For a GUI of this nature, there is no easy answer to this problem.  Search the forums for "large font" to get many examples of how people have solved this issue.  I usually bite the bullet and handle all resizing myself.  An example of this can be found here.
    Since you want to cover the entire workspace, you need to know what this is.  There are two VI server methods which will give you pieces of this information.  Display:All Monitors will give you the valid coordinates for all monitors attached to the computer.  Display: Primary Workspace will give you the useable workspace of the primary monitor.  This does not include the space used by the Windows taskbar (and, I assume, the GNOME, OS X, or KDE equivalents, but have not verified this), so is different from the area given by the first property.  You can fairly easily determine which display is the primary workspace by checking bounds, but do not assume that the taskbar is on bottom of the display when you do this.
    If you have problems finding information or something is not clear, let us know.
    Message Edited by DFGray on 03-03-2010 08:10 AM
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • Front panel resize delay

    Hello,
    I am developing GUI that needs to look nice and user will have option to resize it. Since scale as the window property works bad I wanted to use panel resize event.
    But there is delay - controll is resized some time after I resize front panel and that looks bad. When I look on project window or error list it resizes instantly. 
    Why I can't achieve that result in Labview??
    I could always read panel size lets say every 10ms and calculate ontrolls size based on that,  but is there better option using this panel resize event??
    Solved!
    Go to Solution.

    Right click on the pane (right click in the bottom right hand corner) and select the 'Scale objects while resizing' option.
    That should fix it for you
    Certified LabVIEW Architect, Certified TestStand Developer
    NI Days (and A&DF): 2010, 2011, 2013, 2014
    NI Week: 2012, 2014
    Knowledgeable in all things Giant Tetris and WebSockets

  • Panel resize event bug?

    I'm having a bit of hassle with a panel resize event.
    For reasons best known to me, I have some parallel loops monitoring certain UI behaviour and reacting appropriately.
    I have noticved that when a loop which is monitoring the "Panel Resize" event stops, (No dynamic registration) the next panel resize will freeze the VI.  It's as if the Event case is not releasing the handle to the "Panel resize" event.
    If I handle the "Panel Resize" event via a dynamic registration and subsequent release, everything works fine.
    This is in LV 8.2.1.
    Shane.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant
    Attachments:
    Freezes.vi ‏22 KB
    Doesnt freeze.vi ‏24 KB

    tst wrote:
    I think this has to do with LabVIEW locking the FP (as configured) even when the event structure should not execute any more. I actually created a simple example of it recently, but saved it in one my projects instead of where I would see it, so I forgot about it. I now dug it up and back saved it to 8.0. You can also simplify this example by removing the value change event and making the key down event lock the UI.
    Message Edited by tst on 11-10-2008 02:14 PM
    Sorry Yair,
    but this is not a bug!, it is explainable behaviour and expected behaviour.
    What happens, the front panel is locked on the second edit. (use exectuion high-lighting) The event structure is always listening for events where it is registered for, even if the event case will never execute, on the first edit (key down) the event is triggered and the VI is locked and unlocked. The second edit the event is triggered again and the FP is locked. Because the event structure can't execute the FP stays locked.
    Shane's behaviour is truly a bug.
    The same behaviour is seen with the 'Pane:size' event. (in 8.6)
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Panel Resize respect to Text Size : How To?

    I have a panel named "description", It has only one text
    control named "detail".
    "detail" is a dynamic text control which gets data from an
    xml file and displays the
    detail of required thing.
    things have long and short details.
    I want that Panel resize its height according to the height
    of text control.
    I am a newbie and have no idea.
    Please Help

    Text object resize with the text it holds.
    Add Text object to a VBox and set the width property of the
    Text to 100%.
    It should do what you want.

  • I've created a photo book in iPhoto on my iPad.  When I go to order it, it says that "Your Book contains Empty Photo Frames" but when I check each page, they all have photos.  How to I order the book?

    I've created a photo book in iphoto on my ipad.  When I try to order it (by clicking the price of the book in the top right corner) it says that Your book contains empty photo frames - add photos to the empty frames, or change the page layout to include fewer photos" but when I look at each page, there are photos in all the frames.  What do I need to do to order this book??????
    Thanks so much for any help offered!

    It doesn't appear under the iPad device on the left-hand sidebar of iTunes, you need to select the iPad device on the sidebar and then select the Photos tab on the right-hand side of iTunes e.g.
    And then on the right-hand side :

  • Document contains an invalid frame

    On open, on a long document in InDesign CS6 (8.0) I'm getting:
    ==
    Document contains an invalid frame.
    Story text begins -
    [figure]
    Delete frame and associated story?
    ==
    If I click 'No' it gives me the next figure (about forty of them) and then ultimately, the document opens.
    Ideas?
    Thanks

    Your file won't open, right?
    Legacy files are known to have problems from time to time, and the most reliable way I know to avoid those problems is to export .inx, when possible, from the original version. The second most reliable is to export .idml from the original version.
    There are some scripts that will do a batch conversion to .inx or .idml to help you, if you have a lot of files, and if you think you don't have to thoroughly check every legacy file you open in a new version you are sadly mistaken. If you open a .indd file directly, as soon as you start to edit any text it will reflow to confrom to the new text engine and you may not see the problems on the page where you are working. .inx/.idml forces the entire document to recompose as soon as it opens.

  • How to draw a shape to Panel instead of draw to Frame

    I have a Frame and add a Panel into this Frame. I want to draw a shape to Panel instead of draw to Frame. how do i do?

    You can do two different things:
    1) For temporary drawings that will disappear when the component is repainted, you can use getGraphics() on the Panel, draw on the Graphics, then dispose the Graphics.
    2) For persistant drawings, subclass Panel and override the paint(Graphics g) method. Anything in there will be painted along with the panel. Start with super.paint(g); when you override for good coding practice.

  • Unresponsive Document - Document contains an invalid frame.

    I'm getting a message on a print document that I'm working that reads "Document contains an invalid frame. Story text begins -  Delete frame and associated story?" Regarless of my choice, ID becomes unresponsive. Anybody now what's going on/how to save it?

    Yes. There's a script that does just that. Give me a moment while I find it.
    Found it:
    // blindOpen_and_IDML-Export.jsx
    var _file = File.openDialog("InDesign-Datei"); // Selection of a file
    if(_file != null)
    var d = app.open(_file, false); // Open the file without showing it
    d.exportFile(ExportFormat.INDESIGN_MARKUP,  File(_file.fullName.replace(/.indd$/i,'.idml'))); // Export im IDML-Format
    d.close(SaveOptions.NO); // Close without saving
    And this is how to install it:
    http://indesignsecrets.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-o r-blog-post.php

  • Difference between panel and container

    if both panel and container can contain components inside , then that is the defference between them?
    thanks in advanced.

    if both panel and container can contain components insideJPanel inherits this ability because it extends Container. The point of extending classes is to provide additional functionality. Read the API to see what additional functionality JPanel provides.
    The main difference is that JPanel is a Swing component. You should always use Swing components in a Swing application. This will ensure painting of the panel and all its child components are done correctly.

  • Photoshop CC 2014 - color panel resizing by itself?

    Hello,
    I am wondering if anyone else has reported (or even experienced) the new color panel in Photoshop CC 2014 resizing itself when maximizing and then restoring the Photoshop CC 20114 application frame?
    Here are some images to illustrate the issue I am experiencing:
    This is on initial launch of PS CC 2014 after install and then reboot.
    This is the initial maximize of PS CC 2014 application frame (using green button).
    This is the initial restore command (using green button).
    This is the second maximize (using green button).
    This is the second restore command (using green button).
    This is the third maximize (using green button).
    ... and the fourth maximize (using green button).
    As you can probably see through the progressive process that the color panel is stretching vertically with each maximize / restore combination. It seems to stop stretching after the fourth series.
    Machine specs:
    MacBook Pro 17" (late 2011)
    2.5 Ghz. i7 Intel Processor
    AMD Radeon HD 6770M - 1 GB VRAM
    16 GB RAM - OWC Brand
    480 GB SSD - OWC Brand
    OS X 10.9.3 - Clean Install (all updates installed)
    PRAM and SMC refreshed
    Permissions repaired
    Disk verified
    Clean Install of:
    Adobe Creative Cloud app
    Adobe Photoshop CC 2014 app
    Adobe Illustrator CC 2014 app
    No plug-ins or other third-party add-ons.
    I thought I would mention it in case this hasn't been reported yet (or perhaps there is something bizarre going on with my machine).
    Thanks for any insight or acknowledgement.

    Just giving this a bump and a quick note.
    I just performed a clean install of OS X 10.9.3 again on machine spec'd above and then installed Photoshop CS6 and Illustrator CS6 perpetual license versions. While the new color panel seen in PS CC 2014 is not part of CS6, I wanted to test to see if the color panel was resizing itself as I saw with PS CC 2014. It is not.
    I am running Adobe CC 2014 versions at work on a Dell workstation under Windows 7 Professional. I will test on that system to see if the same resizing of color panel by itself occurs and post back sometime tomorrow.
    Note - if an engineer, staff member or moderator could mention whether this has been logged as a potential issue that would be great. I will of course log a report with a link to this post this morning.
    Thanks for any response.

  • Spry Collapsible Panel Resize Problem

    I have 2 collapsible panels within  a table on a site, and it works great, except for the fact that when all of the panels are closed:
    In IE7: The tabs move to the middle of the table and break the layout.
    In Firefox: The tabs move to the BOTTOM of the table and break the layout.
      The example can be found here:
    http://www.go9production.com/agm/products1.php
    It looks to me like it's resizing the entire cell and making it too small, but I don't know how to fix this without preventing it from getting larger either.  Can anyone help me at least get them to close at the TOP of the page rather than the middle or bottom?

    This is what I see in Chrome
    and similarly in IE7/8/9, FF and Safari
    Gramps

Maybe you are looking for

  • How to make a report based on a search box containg IDs for multiple rows

    Hello everyone, I'm using APEX to build a database application. My users want to search a table by submitting multiple IDs in a search box. They want to list the row IDs for all the rows they want to search in one input box, and after clicking the Su

  • In Lion, can I hide the address book without the application closing?

    In Snow Leopard, when I clicked the red circle in the upper left-hand corner of the address book, the application automatically hid without closing entirely. In Lion, the same action closes the application so every time I need to use it, the address

  • How to Transform using multiple input sources to one target

    Hello - I'm trying to figure out a way in which I can map retrieved values from more than one table (defined via db adapter links) into a single target flat file (defined via file adapter). I can establish a 1-1 transformation process fine, but when

  • Upgrade from 10.4.11 to leopard on White 24"intel iMac?

    I am totally new to MACs and purchased a white Intel iMac for my daughter. It came with a Leopard upgrade or install disc. What is the preferred method to upgrade the system? I have nothing in data at all, its brand new. Should I just do the upgrade

  • Mac pro left USB port can't connect to iPad

    Hi, I just got my new Mac Pro days ago and I really love this new gift, except that when I plug in my ipad air to the left USB port, it gets connected then disconnect instantly after a few seconds, then detected... This happnes over and over. I tried