Placing Components in FlowLayout

I have to place fixed size panels inside a panel which in flowlayout.
How to place those fixed size panels inside that container panel in both the directions horizontal and vertical?... After that, the container panel must be added to a JScrollPane....

I am adding components to the container at runtime.. the components must be of fixed size(ex:- 75 * 75). If i use Borderlayout and the component count is 1, then it occupies the entire display area. my actual goal is to display the components like windows thumbnail view .

Similar Messages

  • Problem In Placing Components

    hi this is anandkumar from india now i am working with Java studio creator 2 update 1. I am facing probelms with placing the components because when i place the components in the design view they look fine but when i will run that page the components width will be sometimes go small and there will be allignment problem between the compenents even though i have alligned all the components correctly in the design view. If any body helps me to come out of this problem i am really thankful to them.
    Regards
    Anandkumar

    Hi Anand,
    I too faced a similar issue. The work around I did was to place all my components in a[b] table and after that the look n feel in the Design View matched the same in my browser.
    Hope this helps :)
    Let me know, if your still facing any issues with positioning components.
    Good Luck
    Anil Mahadev
    http://anilm001.myfreewebs.net/index2.php
    Java Studio Enterprise and Creator User
    Bangalore
    INDIA

  • Placing components without layout manager not working

    Hey there, I am working on a java game version of pong which I have begun to try and do using Java Swing. The problem I am currently having is reposition the components in the main window part of the game which is were the user can start a new game or close the program. I having tried using the absolute positioning by setting the layout manager to null but then everything goes blank. I can't figure out why this is not working. Here is the code so far...
    import javax.swing.*;
    import java.awt.*;
    public class SwingPractice extends JFrame
        private Container contents;
        private JLabel titleLabel;
        private JButton startGameButton;
        public SwingPractice()
            super("SwingPractice");       
            contents = getContentPane();
            contents.setLayout(null);
            this.getContentPane().setBackground(Color.BLUE);
            startGameButton = new JButton("Start Game");
            startGameButton.setFont(new Font("Visitor TT1 BRK", Font.PLAIN, 24));
            startGameButton.setForeground(Color.cyan);
            startGameButton.setBackground(Color.blue);       
            startGameButton.setBounds(350,350, 75, 75);
            titleLabel = new JLabel("The Amazing Ping Pong Game!!");
            titleLabel.setForeground(Color.cyan);
            titleLabel.setBackground(Color.blue);
            titleLabel.setOpaque(true);
            titleLabel.setFont(new Font("Visitor TT1 BRK", Font.PLAIN, 24));
            titleLabel.setBounds(0,350, 75, 75);
            contents.add(startGameButton);
            contents.add(titleLabel);
            setSize(700,350);
            setResizable(false);
            setVisible(true);
        /*private class SwingPracticeEvents implements ActionListener
        public static void main(String [] args)
            SwingPractice window = new SwingPractice();
            window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       Any other critiquing would be greatly appreciated. Thank you.
    Edited by: 804210 on Oct 21, 2010 1:30 PM

    804210 wrote:
    Hey there, I am working on a java game version of pong which I have begun to try and do using Java Swing. The problem I am currently having is reposition the components in the main window part of the game which is were the user can start a new game or close the program. I having tried using the absolute positioning by setting the layout manager to nullDon't. Ever. Never. Well, mostly.
    Read the tutorial chapter about [url http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html]Laying out components. It even features a section on absolute positioning - which you should skip reading, of course! :o)
    And read this old Sun topic: http://forums.sun.com/thread.jspa?threadID=5411066
    Edited by: jduprez on Oct 21, 2010 10:48 PM

  • JViewport not drawing partially visible components

    I have a JViewport (no scrollbars; I control the viewPosition programatically).
    Its View component is a JPanel containing left-to-right components in FlowLayout.
    Sometimes if a component of the FlowLayout would be only partially visible, it does not get drawn at all.
    If user resizes the window (and the viewport gets resized that way), the partially visible component is always drawn. (I am not even manually handling this Event.)
    But if I programatically resize one of the FlowLayout components, then I expect the ones to the right to move accordingly. They do, but then if the last visible one becomes only partially visible as a result of the move, then it is not drawn AT ALL. Calling validate() on the FlowLayout-JPanel and on the JViewport does not seems to solve this.
    Anyone know about this? Is it something that FlowLayout is doing on purpose?
    /Mel

    The reason that FlowLayout wraps my stuff when an already-contained component is widened but does not wrap when a new component is added (alway at the right; never on new row), is because the width field of the container component is not automatically changed upon the resize but must be recalculated upon the add.
    I looked at code from FlowLayout's layoutContainer method (included below), and it appears that the decision to wrap is based solely upon the target container's existing width:
          int maxwidth = target.width - (insets.left + insets.right + hgap*2);
              // (where target is the container being laid out)
          if ((x == 0) || ((x + d.width) <= maxwidth)) // (where
                                                                                 // x is the x-"pixel counter" for placing next component
                                                                                 // d.width is width of the component being placed)
              then will be put on same row
          else
              will start a now rowHowever, while reading FlowLayout, I also discovered that its preferredLayoutSize method calculates a size for as if components were all on one row, i.e. returns width = (sum of all components + insets + hgaps), height = (max of all components + insets + vgaps). Therefore, I believe the simplest solution to my problem is to change the container's width field anytime a component resizing occurs, with the following line inserted right after the resize but before the validate:
    [existing code that sets the label's new text, which used to be followed by validate()]
    this.setSize(this.getLayout().preferredLayoutSize(this).width, this.getHeight());
    validate();It works! (But I know it is making the calculation loop through all of the container's components occur more often than I would like in gui's event thread -- response doesn't look too bad though...)
    /Mel

  • How to set the cell size in a JFrame

    Hello. Is there any way of setting the cell size in a JFrame. The reason why I want to set the cell size is that I want to be sure of their location that when I am placing components on the JFrame. So is there any way of setting the cell size beforehand. Also for the following code.
    JFrame frame = new JFrame("Window");
    frame.setSize(100,100);is the size 100 by 100 is he size of the cell?

    smithbrian wrote:
    When I am placing a component on the grid I want to be sure the component is exactly where I place it. In order to do that I would need to know what is the size of the gird and how to change the size of the gird in the JFrame.What grid?? You're assuming that we know much more about your program than we actually do. We actually know zip. Please read this help site which will help you to avoid similar errors in posting questions here. It has helped me in the past: [smart questions|http://www.catb.org/~esr/faqs/smart-questions.html]

  • Board Size in Ultiboard

    This is probably going to ne one of the most stupid questions ever asked, but I'm going to ask anyway. This is an Ultiboard question.
    How do I know what board size I am going to need in advance of placing components?  The way I have been doing this is that I would place my components either manually or with the autoplacer and then adjust my board outline size at that point. Would this be considered proper design procedure? What, if any, effect would my method have on the autoplacer in determining where components will be placed?
    Thanks for any replys in advance.
    Kittmaster's Component Database
    http://ni.kittmaster.com
    Have a Nice Day

    Lacy, the autoplacer uses algorithms accounting for the force vectors and ratsnest configuration in oder to place the components, rather than the 'space' available.
    However, with that said, imagine that you have a weird outline, the autoplacer 'does' knows what the boundaries are that it needs to abide to when placing components.
    Usually your mechanical enclosure or place where the board will be gives you a clue on how the PCB outline should look like... then place components and traces on that outline...  however there are times in which you can place a default board outline and then according to how the parts, and part groups, etc, are being placed you can then tweak the outline to your favor.
    Nestor
    National Instruments

  • TextField1.setText("fahimaamir"); this code give me error in netbeans 6.1

    hi master
    sir i use netbean 6.1
    i have one textfield and one button in page
    when i use this code in button
    public String button1_action() {
    textField1=("fahimaamir");
    return null;
    that give me error line in
    textField1=("fahimaamir"); this code
    when i deploy that show this error
    F:\BACKUP\WebApplication8\src\java\webapplication8\Page1.java:142: cannot find symbol
    symbol : variable textField1
    location: class webapplication8.Page1
    textField1.setText("sjflskjf");
    1 error
    F:\BACKUP\WebApplication8\nbproject\build-impl.xml:392: The following error occurred while executing this line:
    F:\BACKUP\WebApplication8\nbproject\build-impl.xml:213: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 1 second)
    please see this error and give me idea how i give value to textfield
    thank you
    aamir

    hi!
    Since Netbeans 6.1 the IDE doesn't add Bindings Attributes for placed components like textFields...
    When you place an textField or any other component you have to right click on it an choose: Add Binding Attribute
    Then the component is known in the source code.
    Greetings,
    Remi
    Edited by: remifreiwald on Jun 25, 2008 11:00 AM

  • Can't change pin mapping of a capacitor in multisim

    I have an annoying problem in that all the eletrolytic capacitor footprints in the database seem to have their pins mapped to the opposite pin in the symbol, i.e.
    1              2
    2              1
    The problem arises when you transfer the schematic to Ultiboard and the only way I can make ultiboard connect the capacitor properly is to reverse the connections of the electrolytic capacitor in multisim, i.e.
    +             GND
    -              Vcc
    And there seems to be no way of changing the pin mapping in multisim. You can go to 'edit footprint' and go throug the motions of changing the pin mapping. But as soon as you close the dialog box and then go back into to 'edit footprint' the previous reveresed pin mapping is back.
    How do you fix this extremely irritating problem?

    Hi,
    This reply is almost the same as the one on this item:
    http://forums.ni.com/t5/Circuit-Design-Suite/Updat​e-footprint-of-already-placed-components/td-p/3145​...
    Normally you can not edit the master database...
    You can open the part in the master database, and save it to your user database,
    YOU MUST USE THE SAME FOOTPRINT NAME.
    In you user database you can now change the footprint pin names (properties)
    save it after you're done and keep the same footprint name
    next do a footprint update: Tools/Update shapes
    when Ultiboard updates its shapes , it looks in the User database first, and afterwards in the master database.
    So if you kept the same name, your shape will be updated to the one you changed.
    Now your polarity should be OK
    succes!

  • Importing netlist

    I have an existing board layout and I wish to add a new circuit.  How do I handle the netlist for the new circuit?  Will the importing process adjust net names/numbers for the new circuit so as not to connect to any existing nets that might have a common net name/number?

    That is correct Lacy, if you just have two different netlists and you want to merge them together I would rather do that at the schematic level, however there is a nice workaround...
    So... this workaround works for the case in which you have one single PCB design, and you wish to add a new netlist to the current netlist, assuming you are not doing so at the schematic level...
    1. Import the new netlist into a new Ultiboard project... (have the target project open as well).
    2. With the two projects open, go to the design that has the new netlist...
    3. You have not routed or placed components yet (you still see the ratsnest)... so you can go ahead and select all the components, and right-click select Copy.
    4. Go to the original project (target), and select Edit >> Paste Special... >> Paste with Net.
    5. Your new components and nets are now part of the original project.
    IMPORTANT NOTES:
    a) RefDes will be renumbered to avoid conflicts.
    b) Netnames will not change... so if you have a "TXpos" net in the first project and a "TXpos" net in the second project they WILL BE merged... most likely you don't really want this, so you have to make sure that you rename your nets before doing this process.
    c) You will not be able to forward annotate changes from Multisim to Ultiboard in the future since the netlists will not match and your components will be sent out of the board boundaries...
    So, in other words, only do this if you can't work this out at the schematic level which is the preferred way, since your one PCB should be one project in Multisim as well... I will indeed file a feature request to have the ability to merge netlists in an easier way...
    Message Edited by nestor on 03-12-2008 06:53 PM
    Nestor
    National Instruments

  • How To Arrange JTextField.

    Ok, this is embarassing, but does anybody know how do i place or arrange a JTextField, JPasswordField, JButton and so on by using pixels manually? Thanks in advance.

    In the future Swing related questions should be posted in the Swing forum.
    We recommend against manually placing components. You should learn how to use Layout Managers. Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html]Using Layout Managers.
    If you don't decide to use a Layout Manager, then the section on Absolute Positioning is what you want.

  • How do draw square in application

    Hi,
    am learing java and am trying to develop a stand alone application ( not applet) by using pure AWT. In my application I want to use rectangle as a border to my window. Can any one tell me how to draw a rectangle in application. Thanks a lot.

    but I am writing an application not an applet, in applet
    you have paint methond application do not have paint
    methodAu contraire (sp?)... you have a window (or a frame), which has a paint method. Chances are you are placing components inside your frame/window, all of which have paint methods.
    The simplest way to paint a rectangle into a window is to create a subclass of Canvas and override the paint method to draw the rectangle. This canvas then gets placed in the window. Keep in mind that this approach becomes less appropriate if you want your rectangle to frame other components... that requires a more creative approach with paintable Panels.

  • Draw a grid(different)

    Hi,
    I am trying to draw a circular grid, i.e. like a dartboard, where each ring is split into a number of parts.
    So far I have managed to do that by drawing an image of the board. This creates other problems like reading mouse clicks,scaling, and placing components in correct coordinates.
    I can provide more info. Thank you

    This kinda solves my problem
    for(int i = 0; i < 8; i++)
                   g2d.draw(new Ellipse2D.Double(i*45, i*45,
                        getWidth()-(2*i*45),
                        getHeight()-(2*i*45)));
    for(int i = 0; i < 24; i++)
                   double temp = Math.toRadians(i*15);               
                   Line2D line = new Line2D.Double(getWidth()/2,getHeight()/2, getWidth()/2,0);
                   g2d.draw(line);               
                   at.rotate(Math.toRadians(15),(getWidth()/2), (getHeight()/2));
                   g2d.setTransform(at);
    }This draws the grid. Now if I want to place something or read a click my best bet is:
    x = a + r cos(t)
    y = b + r cos(t)
    So a code of this sort:
    Point point = new Point((int)(center.x+(getWidth()/2)*Math.cos(temp)),
                             (int)(center.y+(getHeight()/2)*Math.sin(temp)));Will produce results slightly different from the actual drawing.
    Thanks again for the help

  • Connect digital analog ground

    Greetings.
    I have a mixed-signal Multisim design which I have forward annotated to Ultiboard.  My Multisim circuits use 2 different grounds - net 0 and net DGND.  For simplicity, I would like to prototype a first version of the boards with the grounds logically connected, so I don't need to worry about ground loops being created by the fact that I'm using separate digital and analog lab supplies.
    I have checked the box in Multisim under "Sheet Properties -> PCB -> Connect digital ground to analog ground."  I have transferred my design to Ultiboard 11 and specified a 4 layer board.  Layer 3 is my ground plane, with a large copper area connected to Net 0.  While placing components and vias on my board, I'm noticing that the thru-holes and vias I define as connected to Net 0 appear as I expect - with the "+" thermal relief on layer 3.  However, vias logically connected to DGND are appearing on layer 3 with large areas of copper removed (I've specified 12 mils clearance on each copper layer).  If I change the copper area on layer 3 to net DGND, instead of net 0, I notice the reverse situation.  All of my analog ground vias and thru-holes have copper cleared away, and the DGND vias are now filled.
    I don't believe a logical connection exists between net 0 and DGND in the forward annotated netlist.  Is there some way I can confirm this?  Did I miss a step in the process while trying to connect these two?

    Thank you for your reply, Mark.
    I was going to upload my Multisim project file, but then realized a lot of my components are now in my Corporate Database, so I can keep vendor and manufacturer-specific part numberings and inventory quantities all together in the same place.  Instead, I took some screenshots and created a .pdf file.  I uploaded the pdf file to transferbigfiles.com, here.
    First, I snipped some sections of my design to illustrate the current state of things.  On the first page, you can see that my default sheet properties are setup such that digital and analog grounds should be connected.  I have an FMC-LPC connector "J17" in my design, with the "DGND" wired to it.  The J17B pin actually represents about 40 different SMD pads on a VITA 57 connector.  The DGND component is from the Master Database under Power Sources, though I think I renamed it from "DGND" to "GND."  As you can see, Ultiboard is showing a lot of DRC errors right now because the vias are set to assume net "0" while the SMD pads were exported as connected to net DGND.
    Next page, I unchecked the box "Connect digital ground to analog ground" and forward annotated the changes.  Ultiboard found no differences.
    Next I thought that perhaps my renaming of the default Refdes from "GND" to "DGND" could be the problem.  So I went through my design and replaced all of my "DGND" triangles with the DGND component from the Master Database.  As you pointed out, though the component is named "DGND" the Refdes is actually "GND."  I left the sheet properties as is, with digital /analog grounds not connected.  When I forward annotate the changes, I observe what I expect - the DGND connections are removed and replaced with GND connections.  (Next page) The SMD pads are now logically connected to the net named GND instead of DGND.
    Finally, I went back to Multisim and tried combining the nets "GND" and "0" automatically by selecting the check box in Sheet Properties.  Unfortunately, when I forward annotate, Ultiboard detects no changes.
    Following are 2 relevant sections of my .ewnet file I opened in a text editor, after my latest changes.
    (net "0"
    (trackwidth "6.00000000e+000")
    (trackwidth_max "3.93700787e+002")
    (trackwidth_min "6.00000000e+000")
    (clearance_to_trace "6.00000000e+000")
    (clearance_to_pad "6.00000000e+000")
    (clearance_to_via "6.00000000e+000")
    (clearance_to_copper "6.00000000e+000")
    (routing_layer "1111")
    (net_GUID "{8704ACB4-9808-4086-9C22-02206D379B13}")
    (net "GND"
    (net_GUID "{8EFCFB7F-F038-4362-A59D-667354159F44}")
    Message Edited by pcurt on 02-22-2010 10:48 AM

  • JD3 vs JD2 - jTabbedPane bug?

    In a JD3 applet, after placing several infobus components on each of several jTabbedPane jPanels, the applet runs in neither the appletviewer nor when deployed. However, when the applet is run in the appletviewer, it can be seen if you select the "restart" item in the pull-down menu of the appletviewer.
    When the components are placed on only the first of the jPanels, the applet does run correctly in the appletviewer and also when deployed. However, if after placing components on more than one JPanel, you remove the components from all but the first jPanel, the problem persists.
    The problem described above does not exist in JD2.

    The following problem applies to JD3 but not JD2, where things work correctly.
    The code below produces an applet with three tabs. Each tab has one or more components on it. If you drag and drop (reposition) the components on the second or third tab, the applet can neither be seen in the appletviewer nor deployed. You can reposition the components programatically, but this is impractical for the case where a few hundred components are involved.
    Is there a way to drag and drop components on these tabs without "breaking" the application?
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import javax.swing.*;
    import oracle.jdeveloper.layout.*;
    public class Applet1 extends JApplet {
    boolean isStandalone = false;
    JPanel jPanel1 = new JPanel();
    JTabbedPane jTabbedPane1 = new JTabbedPane();
    JPanel jPanel2 = new JPanel();
    JPanel jPanel3 = new JPanel();
    JPanel jPanel4 = new JPanel();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JButton jButton3 = new JButton();
    XYLayout xYLayout1 = new XYLayout();
    JTextField jTextField1 = new JTextField();
    JTextField jTextField2 = new JTextField();
    //Get a parameter value
    public String getParameter(String key, String def) {
    return isStandalone ? System.getProperty(key, def) :
    (getParameter(key) != null ? getParameter(key) : def);
    //Construct the applet
    public Applet1() {
    //Initialize the applet
    public void init() {
    try {
    jbInit();
    catch (Exception e) {
    e.printStackTrace();
    //Component initialization
    private void jbInit() throws Exception {
    this.setSize(400,300);
    jPanel1.setLayout(null);
    jTabbedPane1.setBounds(new Rectangle(49, 5, 303, 274));
    jPanel4.setLayout(xYLayout1);
    jPanel3.setLayout(xYLayout1);
    jPanel2.setLayout(xYLayout1);
    jButton1.setText("jButton1");
    jButton2.setText("jButton2");
    jButton3.setText("jButton3");
    jTextField1.setText("jTextField1");
    jTextField2.setText("jTextField2");
    this.getContentPane().add(jPanel1, BorderLayout.CENTER);
    jPanel1.add(jTabbedPane1, null);
    jTabbedPane1.addTab("Pane 0", jPanel4);
    jPanel4.add(jButton3,new XYConstraints(126, 57, -1, -1));
    jPanel4.add(jTextField1, new XYConstraints(73, 143, 102, 23));
    jTabbedPane1.addTab("Pane 1", jPanel3);
    jPanel3.add(jButton1, new XYConstraints(126, 57, -1, -1));
    jPanel3.add(jTextField2,new XYConstraints(59, 140, 90, 23));
    jTabbedPane1.addTab("Pane 2", jPanel2);
    jPanel2.add(jButton2, new XYConstraints(126, 57, -1, -1));
    //Get Applet information
    public String getAppletInfo() {
    return "Applet Information";
    //Get parameter info
    public String[][] getParameterInfo() {
    return null;
    null

  • Components vanish when placed on a layer below an imported Symbol

    AS2 Components vanish  or get severely corrupted when placed on a layer below an Imported  symbol.
    Very easy to reporduce:
    Flash CS4 create a new AS2 FLA  called Share.fla
    Create an  empty MovieClip symbol in the library and set its properties to export for  runtime sharing URL: "Share.swf".
    Build.
    Now create another  new AS2 FLA in same folder called TestShare.fla.
    Create an empty  MovieClip symbol in the library and set it's properties to "Import for runtime  sharing" URL: "Share.swf".
    Drop an instance of  this empty symbol in frame 1 layer 1.
    Create a second  layer and drop an instance of any Component from the components  panel for example the Button component.
    Build.
    The component appears as a blank square block.
    If you add a trace statement to the components constructor you'll see it is never called.
    Now swap the layers,  drag layer 2 above layer 1 and build again.
    Now the component  shows just fine.
    You might say so just swap the layers and carry on but this is simplified example to demonstrate the problem, in practice I have many shared libraries containing many component and many apps with many layers and I've been shuffling the layers for what seems like an eternity and found that there is no order that will work for everything. If anyone can explain this behaviour or suggest a permanent work around I would be very grateful.

    Thought I would attach the source so just unzip and build TestShare.fla you'll see the Button component, then swap layers 1 and 2 and rebuild and you will see just an empty Button frame. Would love to find an answer to this.

Maybe you are looking for

  • ALV Grid multiple row selection, disabling some

    Does anyone know if it is possible to have an ALV grid with multiple row selection allowed but for some rows the row selection is disabled? Kind regards, John.

  • DataMart Interface - Date and time of the transferred data

    Hello, We have a requirement to build a datamart (cube to cube) between two BW systems, using deltas; this is OK and should not present any issue. However a further requirement has arisen, requiring to provide date and time of the created files to ou

  • My replied messages contain only HTML code apparently.

    Hey guys! Pretty new to Thunderbird. When I reply to people on my Thunderbird, the recipients are just receiving html code. I'm using one account on 2 different computers for my eBay messages, how do I stop this? Weird thing is, one of the accounts w

  • Accidentally deleted entire external drive using terminal!

    wow I never thought this would happen to me but it did.... Upon trying to eject my external drive, I get the "cannot eject drive because it is busy" error. Looking around, it seems to be a spotlight indexing problem according to this page http://itsm

  • Why dropping frames?

    Hi all.. I'm running FME 3.2 on a quad-core box with plenty of memory, and I'm dropping a ton of frames whenever there's a fair amount of motion on the screen.  FME settings (VP6) are pretty much default. Any suggestions on how I can reduce this??