Components resizing!!!

hi,
I'm trying to design a UI using togglebuttons, textfields and comboboxes, ideally i did like them to all have the same dimensions, how to do this. The setPreferredSize doesn't seem to have any effect on these components, but works fine with the JButton component.
can i know how to do this?

Hi,
Try out like this.The below code will give the preferred size u need.
private Container contentPane;
//to hold dynamic lists
Vector products = new Vector();
Vector invoices = new Vector();
Vector lineItems = new Vector();
DefaultComboBoxModel customers = new DefaultComboBoxModel();
//data containers for lists
JList prodList = new JList(products);
JList invList = new JList(invoices);
JList invProdList = new JList(lineItems);
//so windows will scroll
JScrollPane prodScroll = new JScrollPane(prodList);
JScrollPane invScroll = new JScrollPane(invList);
JScrollPane invProdScroll = new JScrollPane(invProdList);
//labels for windows
JLabel prodLbl = new JLabel();
JLabel invLbl = new JLabel();
JLabel invProdLbl = new JLabel();
//data options buttons
//for product window
JButton creProd = new JButton();
JButton editProd = new JButton();
JButton remProd = new JButton();
//for invoice window
JButton creInv = new JButton();
JButton editInv = new JButton();
JButton remInv = new JButton();
//for invoice lineitems
JButton addItem = new JButton();
JButton remItem = new JButton();();
public void initComponents()
try
//contentpane
contentPane = this.getContentPane();
contentPane.setLayout(null);
this.setBounds(150, 50, 500, 500);
this.setTitle("Products and Invoices/Entry and Maintenance");
//labels for windows
prodLbl.setText("Products");
invLbl.setText("Invoices");
invProdLbl.setText("On this Invoice");
//data options buttons
//for product window
creProd.setText("Create");
editProd.setText("Edit");
remProd.setText("Remove");
//for invoice window
creInv.setText("Create");
editInv.setText("Edit");
remInv.setText("Remove");
//for invoice lineitems
addItem.setText("Add new Item");
remItem.setText("Remove Item");
//for JDialogs
btnDelete.setText("Confirm Delete");
//add to contentpane and locate
contentPane.add(prodLbl).setBounds(55, 30, 75, 25);
contentPane.add(prodScroll).setBounds(15,75, 140, 300);
contentPane.add(invLbl).setBounds(210, 30, 75, 25);
contentPane.add(invScroll).setBounds(170, 75, 150, 300);
contentPane.add(invProdLbl).setBounds(355, 30, 85, 25);
contentPane.add(invProdScroll).setBounds(335, 75, 140, 300);
contentPane.add(creProd).setBounds(15,388,75,25);
contentPane.add(editProd).setBounds(95,388,60,25);
contentPane.add(remProd).setBounds(40,418,90,25);
contentPane.add(creInv).setBounds(175,388,75,25);
contentPane.add(editInv).setBounds(255,388,60,25);
contentPane.add(remInv).setBounds(200,418,90,25);
contentPane.add(addItem).setBounds(345,388,120,25);
contentPane.add(remItem).setBounds(345,418,120,25);
Hope it may help you.
Regards,
Anil.
Technical Support Engineer.

Similar Messages

  • Components Resizing to follow width of applet

    Hi,
    does anyone know how i can stop components from resizing to follow the width of the applet they are in once i have grabbed the applets edges?
    Thanks
    Richard.

    Darryl.Burke gave some excellent advice.
    Still, I am prepared to go out on a limb and make a WAG that you are talking about a floating applet.
    This occurs in three cases..
    1) The applet is in development/testing and launched by applet viewer.
    2) The applet is deployed, and launched using webstart (also shown using applet viewer).
    3) The applet is targeted at a 1.6.0_10+ VM, and has a JNLP file specified - so it is dragable.
    In the first case, it is irrelevant if the applet will become a 'plain old embedded' applet, which is (usually) not resizable.
    In the second and third cases, you probably need to look to the layouts used for the components. To prevent the components from resizing, either a FlowLayout or BoxLayout would probably be required.
    As an aside, one way to indicate interest in a solution is to add [Duke stars|http://wikis.sun.com/display/SunForums/Duke+Stars+Program+Overview], though DB's advice will get you further. I recommend doing/acting on both.
    Edited by: AndrewThompson64 on Aug 28, 2008 11:05 AM

  • Let user drag drop dynamic components, resize them

    I'm just wondering how you can create UI components and let
    the user drag and drop them on the screen
    let the user resize the elements, change the text for example
    or rotate the element (just like scrapblog)
    Lets say you want to have an image object.
    Do have to create your own custom components that inhertis
    from the image component
    add some kind of handle objects and handle al the events so
    the user can change the size and rotate it
    Or is there a much easier way of doing this kind of cool
    stuff
    If anyone knows how this kind of technique is called, let me
    know its hard to find something about it (in any language,
    if i search for wysiwyg drag and drop in flex or .NET i
    mostly get results like FlexBuilder en Visual Studio not how to
    program such special components)
    grtz

    Did some more searching and already found some cool examples
    http://www.rogue-development.com/objectHandles.html
    http://blogs.adobe.com/flexdoc/2007/03/creating_resizable_and_draggab.html
    more examples are still welcome :)

  • Components Resize Unexpectedly

    I have a window that uses borderlayout. The CENTER panel contains a table. The NORTH panel is in flowlayout. It contains 3 other panels that contains components. My problem is that occasionaly when the table becomes populated with data, the components in the north panel resize unexpectedly. This behavior is not desired. I have set the minimum sizes for the components, but that doesn't make a difference. Any suggestions or help would be appreciated. Thanks.
    Kevin

    Simple answer? Don't use flowlayout. ;o)
    Try using something like boxlayout, you can ensure that the north panel objects stay next to each other this way.

  • How to avoid resize to only grow up components

    Hello,
    In my application using the latest Flex on WinXP, my button components resize well only when they have to grow up. When I reduce the window, components never reduce their size.
    The problem occurs only when I use a skin for the Application. The contentGroup fails to reduce its size.
    Code from the Skin:
        <s:Group id="contentGroup"
                 left="15" right="15" top="15" bottom="15" >
        </s:Group>
    Code from the Application:
        <s:layout>
            <s:VerticalLayout/>
        </s:layout>
        <toolbar:ApplicationMainButtons id="mainButtons" width="100%" height="11%" />
    Where could be the problem please?
    Regards,
    Bernard

    Does your Application have a minimum size set on it?  The default template in Flash Builder generates this:
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    If you have something similar then try removing those min sizes or updating them to a smaller more appropriate value for your application.

  • Auto resizing of components to fit into full-screen

    hi,
    does anyone know how to autoresize components so that
    when the frame is at full-screen mode, components resize
    automatically?
    thanx =)

    Use the appropriate [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]Layout Manager.

  • Flex 3 Window Resize Issue

    Hello all,
    I'm a beginning Flex programmer and I've run into an issue I
    don't know how to resolve. The problem is this: when my app is
    compiled under Flex 2 all of my window components resize nicely
    when the browser window is resized (<mx:Application width="100%"
    height="100%">). However, when I compile under Flex 3 this
    doesn't work; all components stay the same size and I get
    scrollbars at the edges of the browser window if I shrink the
    browser window.
    The backwards compatibility and migration documentation
    doesn't say anything about this functionality being changed. Anyone
    have any idea why this is happening, and how I can get the older
    functionality back?

    Setting the scroll policy to off certainly gets rid of the
    scrollbars, but it doesn't actually fix the resize behavior of the
    application.
    I ended up fixing this problem by cheating: I set up a resize
    handler for mx:Application that resizes the main Container in the
    app.
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    xmlns:custom="components.*" layout="absolute"
    width="100%" height="100%" minWidth="780"
    minHeight="580">
    <mx:resize>
    <![CDATA[
    try { bpanel.width = width; bpanel.height = height; }
    catch (err:Error) {}
    ]]>
    </mx:resize>
    A hack, yes, but at least things work again.

  • JFrame resizing question

    When i resize a JFrame the components it hold remain unchanged until I stop resizing the frame. Then the components conform to the frame size. Is there a way to have the components resize dynamically?

    Thank for the answer, that's exactly what I nedded!

  • Relative Resizing issues

    Hi I started with java a few weeks back and I am really getting into using swing to make my problems.
    I've got the hang of GUIs for the most part but I've been having difficulty with the TextAreas and the sizing of panels
    1) My TextArea problem:
    When the user writes into the TextArea and the text becomes wider than the textfield's specified size, the textarea gets wider, rather than the words wrapping onto the next line as I would like. Additionly when the Tab key is pressed, a tab is inserted into the text, rather than the cursor moving to the next text field (as I would like)
    2) My panel size problem
    I have been using the GridBagLayout for the layout of my GUIs and it works great except my panels size themselves to the objects inside them, and the objects inside them change size quite often, this means the wondow is constantly resizing itself. Is there any way of making the panels fixed at a certain size?
    3) One other thing that came up is can you make a window un-resizable so that users can't maximise and minimise it?
    I know these problems seem a bit basic but I have looked around and I think they are just overlooked as "too obvious" by most people!!
    Thanks
    James

    Read the docs, most of this stuff is well commented in the swing API javaDocs.
    1) setLineWrap()
    2) don't pack() your Frame, instead set it to a size larger enough for your components. That way if the components resize, the frame won't. This is not a clean solution BTW
    3) setResizable(), setUndecorated();
    have fun using swing to SOLVE your problems

  • Dynamic resize of JButton and JFrame in response to Font

    Im supposed to increase the font size of the text with JButton by 1 within each click.
    Eventually the text becomes shorter and less visible like WORD becomes WOR... then WO... etc
    How to make the button always resize with text so that the text is fully visible and JFrame always resize with button so that the button doesn't change its position within the Frame ?
    edit:
    I managed to make buttons resize with increasing font
    by making
    JButton b = new JButton("button");
    b.setHorizontalTextPosition(CENTER);
    b.setVerticalTextPosition(CENTER);However the window size doesnt increase with components ;[
    any help would be appretiated.
    Edited by: pimpcane on Dec 11, 2007 12:16 PM

    Ok I managed to get it working moreless by
    adding pack() to the actionPerformed(...) function
    public void actionPerformed(ActionEvent e)
                 int index = Integer.parseInt(e.getActionCommand());
              int size = buttons[index].getFont().getSize();
              size++;
              buttons[index].setFont(new Font(name, style, size));
              pack();
    }The problem is in the task im given it is forbidden to use pack();
    Is there any other method to obtain the same result of JFrame resizing dynamically in response to components resize ?
    Edited by: pimpcane on Dec 12, 2007 12:13 PM
    Edited by: pimpcane on Dec 12, 2007 12:15 PM

  • Image resize problem

    For the life of me I can't figure out why this isn't working properly. I've been resizing images this way for months now and I must have changed some setting or whatever cause it simply doesn't work. Please be kind if I'm posting improperly as this is my first time posting here.
    Here's the situation. I have an image below at resolution 5000x2048.
    When I trim the canvas everything works properly as seen below.
    Due to the Trim canvas, the image is now 2071x1252. I want to resize the entire image to 1680 & keep proportions as shown below.
    Here's where I run into problems. I've never had it do this before, and I can't figure out how to fix it. When I resize the image, I get the following.
    As you can see, the canvas resized properly, but the vectors resized a whole lot smaller. Any help would be greatly appreciated.
    Message was edited by: A. Buskov

    That's perplexing. Just out of curiousity: Is everything a vector, or is it a mix of vectors and bitmaps? It appears that some of the components resized properly, where others did not.
    Since you know what dimensions you're shooting for, you could try reversing the order of things: resize, then trim. First figure out the percentage by which you were reducing the trimmed image size: 1680 / 2071 = 81.12%. Now apply that percentage to your initial image size: 5000 x 2048 becomes 4056 x 1661. Do the same sizing discrepancies occur? If not, then apply the Trim Canvas command, and you should be good to go.
    Alternatively, if you're resizing this graphic for output, you could simply use the Image Preview dialog instead (after trimming).
    Another troubleshooting idea: Have you tried saving the graphic immediately after applying the Trim command, and then resizing?
    Finally, how about using Modify > Transform > Numeric Transform... and then choosing either Resize or Scale?

  • How to create a navigation that resizes with browser window

    Hello,
    I came upon this site http://www.smetana.net/. In it the navigation components resize with the browser window change of size but the content remains the same size. I would like to build something similar for my site but I have no idea how this is done. I don't mind doing the work but I need a direction
    Thanks
    Ravital

    The following links are for tutorials that address various aspects of Flash Full Screen Adaptable design
    http://www.tutorio.com/tutorial/liquid-flash-layout
    http://www.gotoandlearn.com/play?id=31
    http://www.developphp.com/Flash_tutorials/show_tutorial.php?tid=128

  • Automatic Resizing Problems

    I am having serious troubles with my components resizing automatically when the window is resized or the contents within the component change. Namely, tree and list components. Every time I add an element to a tree or list component, the container that the tree or list is placed in resizes to match the longest element within the tree or list. I have researched my Pure JFC Swing book from cover to cover trying to find a fix for this, and have had no luck. Can somebody help me remedy this problem?

    Ok, I haven't added anything to exit the system when you close the window. Also, I have chosen not to repeat any code for a JTree at all. It would take too long. This is code for a JList component. Try entering a really long e-mail and also a short one.
    class NameFrame extends JFrame{
         Container contentPane = getContentPane();
         public NameFrame(String title, int w, int h){
              super(title);
              setSize(w,h);
              contentPane.add(new NamePanel());
    class NamePanel extends JPanel implements ActionListener{
         JList list;
         JTextField email;
         JButton addButton;
         Container contentPane = getContentPane();
         Vector listData = new Vector();
         public NamePanel(){
              addButton = new JButton("Add");
              addButton.addActionListener(this);
              addButton.setActionCommand("Add");
              add(addButton);
              email = new JTextField("", 20);
              add(email);
              list = new JList();
              list.setVisibleRowCount(4);
              list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
              list.setSelectionBackground(Color.blue);
              list.setSelectionForeground(Color.white);
              list.addListSelectionListener(this);
              JScrollPane sp = new JScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
              add(sp);
         public void actionPerformed(ActionEvent ae){
              String but = ae.getActionCommand();
              if(but.equals("Add")){
                   listData.addElement(email.getText());
                   list.setListData(listData);
                   email.setText("");
    class A{
         public static void main(String[] args){
              NameFrame nf = new NameFrame();
              nf.show();
    Then, click the window and watch it re-size to match the longest one. I don't like this, I would like to keep it the same size at all times no matter what size e-mail is entered.
    Your dilligence is greatly appreciated....

  • Auto-resize a jFrame

    Hello!
    I have a jFrame which I want the size of to change so all the components will fit. Pack() didnt work, and neither did getting the jPanels size and setting is as the preffered size. So Now I've out of ideas.. Here's where it will add components later, but I need to resize it so that it will fit the new ones. Any ideas?
    jComboBox1.addItemListener(new java.awt.event.ItemListener() {
                        public void itemStateChanged(java.awt.event.ItemEvent e) {
                             String premium = jComboBox1.getItemAt(jComboBox1.getSelectedIndex()).toString();
                             if (premium == "TestPremiumServer") {
                                                                                    //add components
                             //resize window to fit the new components
                   });

    whenever you add components to an already visible container, these are generally the steps
    container.add(...);
    container.revalidate();
    container.repaint();//sometimes required, if just revalidate() is called, but not if pack() is also called
    container.pack();
    if you have all the above and it's still not working, post your code so we can see exactly what you're doing
    (if the code is long, remove all the unrelated stuff - menu's etc)

  • FAQ: How can I make my Flash Catalyst application scale/use a liquid layout?

    Flash Catalyst CS5 currently only supports applications with fixed dimensions. Custom components you create in Catalyst have absolute sizing.
    If you want to experiment with creating resizable applications (liquid layouts) and components in a preview of the next version of Flash Catalyst, codenamed "Panini",  you can find more information here:
    Introducing Adobe Flash Catalyst "Panini"
    Download Adobe Flash Catalyst "Panini"
    Adobe Flash Catalyst "Panini" help
    Keep in mind that Flash Catalyst "Panini" preview is meant for exploration and testing, not real production. If you are doing real production work, here are some options that work with Flash Catalyst CS5 and Flash Builder:
    Liquid Layouts
    If you are building an application that requires relative constraints, you can take the FXP file from Flash Catalyst into Flash Builder, and apply constraints there so that your components resize according to your application dimensions.
    For more info, see this Help topic:
    Using constraint-based layouts in Flash Builder
    SWF Scaling
    If you want your swf to scale, without relative constraints, there's a simple way to make that work in Builder as well. Simply save out your FXP file from Flash Catalyst and import it into Flash Builder. Open up the "Main.mxml" file. Remove the width and height attributes on the Application tag, and add the attribute:
    preinitialize="systemManager.stage.scaleMode='showAll'
    The entire Application tag should look something like:
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:s="library://ns.adobe.com/flex/spark"
                      xmlns:d="http://ns.adobe.com/fxg/2008/dt"
                      xmlns:fc="http://ns.adobe.com/flashcatalyst/2009"
                      xmlns:ATE="http://ns.adobe.com/ate/2009"
                      xmlns:ai="http://ns.adobe.com/ai/2009"
                      xmlns:flm="http://ns.adobe.com/flame/2008"
                      xmlns:lib="assets.graphics.*"
                      xmlns:components="components.*"
                      backgroundColor="#FFFFFF"
                      preloaderChromeColor="#FFFFFF"
                      preinitialize="systemManager.stage.scaleMode='showAll'"
                      >
    There are a couple other scale modes you may want to try, such as "exactFit", which are outlined at the below link:
    Flash Stage Scale Modes
    Finally, you will have to adjust the object embed code in your html page to set the size of your swf.
    Original discussion here

    you can`t. allow your application internet access without the network admin defining an exception for it specifically.
    If you have admin rights use the router`s/proxy`y configuration software to allow an exception.

Maybe you are looking for

  • After importing from iPhoto, Originals are still in the iPhoto Library

    I have imported my iPhoto library in the Aperture but when I look to see where the originals actually reside I see that they are still saved in the iPhoto Library directory structure. How can I make sure that all the previous iPhoto pictures have the

  • How to get rid of maintaining transaction IDX2

    Hy everybody, is there a way to get rid of maintaining transaction IDX2, when an IDoc structure changes? Thanks a lot, Thomas

  • Unable to re-install CC Desktop

    I had to uninstall the CC Desktop App because it was not working correctly. For uninstalling I used the uninstaller of the Adobe CC Desktop App. Not I wanted to re-install it, but it doesen't work! On the CC website I get this link: aam://SAPCode=KCC

  • How to export Synonym where owner=PUBLIC

    Hi, Im using oracle 11g on AIX 5.3, I have taken the export backup with data pump of one schema. its imported successfully, but the all synonyms are not imported, My table onwer is user whose backup i have taken , bt the owner of the synonyms are PUB

  • Color changes from FCP to Quicktime to Youtube

    I'm editing on FCP7 and I add color correction but then the color changes once I export to quicktime conversion. And then it changes again when I upload it to youtube. I'm editing on Apple ProRes 422 1920 x 1080. I export with quicktime conversion to