Overlap of components in the panel

This is for an application which computes the total cost of configured laptop.
The main window has 2 panels. The top panel should have a label, and textfield. 3 comboboxes, radiobuttton group, 2 check boxes. I am not able to display the components next to each other. They overlap in the top panel.(This panel has a GridLayout) The code is as follows(does not have all the components yet)
The 2nd panel has a 2 buttons and textarea. Can anybody please help.
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class WClass extends JFrame implements ActionListener
     private Container pane;
     private JPanel P1;
     private JPanel P2;
     private JButton submit;
     private JButton clear;
     private JTextArea Out;
     private JLabel name;
     private JTextField Custname;
     private JComboBox processor;
     private JComboBox harddrive;
     int row;
     public WClass()
          super("Laptop Computer Configuration");
          P1 = new JPanel();
          P1.setLayout(new GridLayout(2,4));
          P2 = new JPanel(new BorderLayout());
          name = new JLabel("Customer Name");
          add(name);
          Custname = new JTextField(10);
          Custname.addActionListener(this);
          add(Custname);
          String p[] = {"Pentium 4", "Celeron", "AMD", "Intel Centrino"};
          processor = new JComboBox(p);
          processor.setMaximumRowCount(3);
          processor.addItemListener(
                         new ItemListener()
               public void itemStateChanged(ItemEvent e)
                    if(e.getStateChange() == ItemEvent.SELECTED)
                    row = processor.getSelectedIndex();
          add(processor);
          String h[] = {"30 GB", "40 GB", "60 GB"};
          harddrive = new JComboBox(h);
          harddrive.setMaximumRowCount(2);
          harddrive.addItemListener(
                         new ItemListener()
               public void itemStateChanged(ItemEvent e)
                    if(e.getStateChange() == ItemEvent.SELECTED)
                    row = harddrive.getSelectedIndex();
          add(harddrive);
     add(P1, BorderLayout.NORTH);
          submit = new JButton("Submit");
          clear = new JButton("Clear");
          Out = new JTextArea(10,5);
          P2.add(submit, BorderLayout.WEST);
          P2.add(clear, BorderLayout.EAST);
          P2.add(Out,BorderLayout.CENTER);
          add(P2, BorderLayout.SOUTH);
     public void actionPerformed(ActionEvent event)
import javax.swing.JFrame;
public class Win
     public static void main(String args[])
          WClass window = new WClass();
          window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
          window.setSize( 500,400);
          window.setVisible( true);
}

It is not easy to read your code due to lack of formatting. When you post code you should highlight it and click the "code" button. This preserves the formatting.
I see some lines that say "add(whatever)". Shouldn't these be "P1.add(whatever)". In other words you want to be adding components to a panel rather than the base JFrame if I understand your requirement..

Similar Messages

  • JLable components not being displayed in the panel of the applet

    I am having the problem with the display of the JLabel components in the Panel component of the Applet.
    The JLabel components do not appear in the Panel of the applet unless i minimize or maximize the applet.

    hello...
    i just had the same problem... it was solved by using the .updateUI() method.
    in my case several textFields were dynamically added to a jpanel, there we called the method on that panel.
    ptf.updateUI();     
    hope it works.
    ----------++-----+
    ...algun dia todos seremos luz...
    -zoe

  • How to place event callback components and "main-VI" components in the same Front Panel?

    What I'm trying to accomplish:
    Place a .NET component, which generates events, and other standard LabVIEW components in the same Front Panel. The standard LabVIEW components should be updated when events are being generated in the .NET component.
    How I tried to solve it:
    Problem:
    The event callback code must reside in a separate event callback VI. In order to "pass the event up" to the main VI I tried to use a global variable. The interrupt does occur:
    but I was hoping that the string indicator would be updated when the event occurred, but it wasn't.
    Questions:
    What's the best way to solve what I try to accomplish? If I want to solve the problem on the picture above, how would I do it (it may not be the best solution, but I'm still curious what's wrong)? Please feel free to be over-explicit when replying as I am novice LabVIEW programmer. Thanks in advance for any help.

    There are two bundle functions for creating clusters. The function simply called Bundle operates almost exactly like the Build Array function I showed. The type of the output cluster depends on whatever you wire in as inputs. You don't have to supply a specific type parameter.
    The function called Bundle by Name takes in a specific type of cluster in the top input and allows you to fill in the values of that specific type of cluster. To create the specific type of cluster you want, you need to create a cluster of string references. Here's how to do that:
    Go to the Front panel and drop down an empty cluster shell.
    Go to the Refnum palette and drop down a Generic Control Refnum. Now here's a cool trick to turn that generic refnum into a string-specific refnum (a so-called strictly-typed refnum). Grab a string from the controls palette and drag it into the Generic Control Refnum. Once you drop it, you'll see the refnum change its icon to display a string picture.
    Make copies of this string refnum (as many as you need) and add it to the cluster shell.
    Now, if you're making specific types of clusters to work with, now is the absolute best time to learn about typedefs if you haven't already. It will save you hours and hours (if not days) of development time in the future. Trust me!
    Jarrod S.
    National Instruments

  • Adding a panel over other components in the main mxml application

    Hi,
    I've created a main mxml file that contains,among other things, a button, and another mxml that contains a panel with some options. I want to be able to add that panel to the main mxml OVER all other components in the main mxml file with a mouse click on the button in that main mxml. How can this be done, please help ?

    Hi mesanarapscallion,
    Can you please post the sample code you are working...
    Do you want to show the panel component on all the thing above in the main.mxml file...Do you have all the other things positioned at the same position..?
    Thanks,
    Bhasker Chari

  • Disable all the components of a panel ( panels within the main panel )

    Hi guys!
    I have a problem!
    i have to disable all the components of a panel. please note that i am also having panels within the main panel. please tell me how to do that!!!
    its urgent!!

    Hi guys!
    I have a problem!Wouldn't have figured that one out by myself ...
    its urgent!!No, it's not.
    You know, a panel is most often a subclass of Container, so all you need to do is recursively disable all child components. The methods getComponents and getComponent are very helpful when trying to access child components. Code likeif ( comp instanceof Container )
      // do soemthing
    }will help in determining whether a child component is yet another Container.

  • Aligning group of components in a panel grid

    I have a panelGrid that has two columns. The first is a table and the second is a groupPanel.
    I want the components in the groupPanel to be left justified but even using css styles such as the following the groupPanel is always centered.
    .alignTopLeft {
      vertical-align: top;
      text-align: left;
    }I have also tried the following:
    .alignTopLeft {
      vertical-align: top;
      text-align: left;
        position: relative;
        top: 1px;
        left: 1px;
    }I notice that their does not seem to be a horizontal-align attribute which would make more sense to me. I also suspect that the above styles do not work because I am dealing with a group of components instead of a single component (such as a text field).
    In order to get the look I want I have had to resort to using a layout panel set to 'grid' and hand placing my sub elements. I keep on thinking I am missing something and that their is a better way to do this.
    Granted this is based on my experience with Swing which has rich set of layout managers...
    If anyone has a better solution please let me know. (And remember that a sample is always welcome)

    Some more information.
    I also tried using the following setting:
    .alignTopLeft {
      vertical-align: top;
      float: left;
    }While this placed the component in the desired location it had an unfortunate side effect. When I set the text area to have some value (in my back bean) the value did not show up in the text area but instead appeared to overlap the left most component on row of the panelGrid.
    So far the only way I have been able to get this to appear the way I would like is to use a panelLayout with a grid (fixed) layout.
    I hope that future versions of Woodstock will have better layout managers. Coming from Swing it is very frustrating to have to use tricks like this.

  • The difference between the bubble and the panel

    I just experienced another reason why I hate the bubble instead of the drawer/panel, besides the whole data entry thing.
    I had the calendar on my smaller 20" monitor on my right - I use my 30" monitor for the nuts and bolts of my work. The calendar was set to fill the screen vertically. I needed to enter something into a date near the bottom of the calendar, so I double-clicked it to edit, and the bubble ran off the bottom of my screen! I had two options - resize the calendar so I could see all of the bubble, or move the bloody thing to my 30" monitor so I could finish my task. With the old iCal, the panel would have just been to the right - no problem. I really miss the old iCal. A lot.

    Yah when I tried to add multiple components without sucess I got rather confused here is what I tried...
    I was making a non applet or a JFrame whatever you call them, so I made these two variables as class variables
    MyOtherComponent me = new MyOtherComponent();
    MyComponent mc=new MyComponent();
    (I definded the components later on in the class)
    I then wanted to display them, I did this in the class constructor which is called by main().
    MyComponent one;
    MyOtherComponent two;
    JButton button;
    me.setPreferredSize(new Dimension(40,40));
    mc.setPreferredSize(new Dimension(40,40));
    me.setPreferredSize(new Dimension(400,400));
    me.setVisible(true);
    mc.setVisible(true);          
    content.add(one = new MyComponent(), BorderLayout.CENTER);
    content.add(two = new MyOtherComponent(), BorderLayout.WEST);
    content.add(button = new JButton("yo"), BorderLayout.EAST);
    content.add(button = new JButton("S"), BorderLayout.SOUTH);
    content.add(button = new JButton("N"), BorderLayout.NORTH);
    I wanted to make a BorderLayout, and have two of my custom components in the layout but every time I try to run this mc is visible (the first component, and me is not visible...
    it says me is not visible but i set it to visible clearly in the code, what is the problem..
    dukes for this one

  • Refreshing the panels when new content added?

    Hey, guys. My first post here; hope I'm not too much of a JNewbie for you. :)
    I'm getting my feet wet in Swing, working on an invoice program for work. I want it to look like a regular invoice, with fields for SKU, description, cost per unit, units, and total per line item. Right now, I have those five fields in a Jpanel that I add to the bottom of the layout.
    The problem is that I need the ability to go to File => Add New Item... and have another JPanel with those five fields add to the bottom so a 2nd item can be added to the form below the first. I tried making a function that adds them to the panel, using the same type of syntax that the generated code (using a form builder in NetBeans) did. I don't see the lines get added.
    My thought is that there is some function I need to call to redraw or refresh the panel so that the new components start drawing. However, my Great Javadoc Adventure has turned up no clues.
    Can anyone please give me a hand with making this happen, or at the least coming up with an alternate solution that will achieve similar results?
    Thanks much.
    Jaeden Stormes
    [email protected]

    I tried revalidate() , but no change.
    Here's the function I'm using to try to add the item...
    private void NewLineItem()
    javax.swing.JPanel jLine = new javax.swing.JPanel();
    jLine.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
    jItemCode.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    jLine.add(jItemCode, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 110, -1));
    jCourseDelivery.setHorizontalAlignment(javax.swing.JTextField.LEFT);
    jLine.add(jCourseDelivery, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 0, 240, -1));
    jItemQuantity.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    jLine.add(jItemQuantity, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 0, 110, -1));
    jItemRate.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    jLine.add(jItemRate, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 0, 100, -1));
    jItemAmount.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    jLine.add(jItemAmount, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 0, 100, -1));
    jLineItemSection.add(jLine);
    jLineItemSection.revalidate();
    pack();
    JLineItemSection is a JPanel inside my frame.
    Any suggestions? I think the way I am using the AbsoluteContraints is screwed up, as I'm having a lot of trouble with the layouts in general. The form editor in NetBeans (at least, the version in 3.6) needs a LOT of work.

  • How do I disable all non-essential components in the CS6 installer

    A new question in the spirit of http://forums.adobe.com/thread/548877 and http://forums.adobe.com/message/2778575, where I asked this question for CS4 and CS5 and eventually discovered how to do this (at least for CS4; CS5 was a mess...): How do I disable all the non-essential components in the Photoshop CS6 installer?
    I already found the payloads/Media_db.db sqlite 3 database and wiped the DependencyData table. This goes a long way - unlike CS5, which was a maze of hidden xml configs and sqlite databases, for CS6 just wiping this single table will give the user full control over what the installer will put in the computer. With the dependencies wiped, we can now see all the stuff it's actually going to install:
    Bridge (normal and x64) - 187 and 262 MB
    CMaps (normal and x64) - 7.2 and 7.2 MB
    CSXS Extensions - 1.3MB
    CSXS Infrastructure - 6.8MB
    Color - photoshop, EU, JA, NA - 1.5, 2.1, 3.0, 2.5MB
    Video profiles - 4.7KB
    Dynamic Link Media Server - 96MB
    DynamicLink Support - 6.1MB
    ExtendScript Toolkit - 19MB
    Extension Manageer - 16MB
    Fonts recommended (normal and x64) - 110 and 110MB (why are there x86 and x64 versions? more of an open question than one that really needs an answer, but this is not how fonts work. There are no separate x86 and x64 flavoured OpenType fonts)
    Fonts required (normal and x64) - 123 and 123MB
    Hunspell Linguistics Plugin (normal and x64) - 181 and 181MB
    Linguistics (normal and x64) - 46 and 46MB
    Mini Bridge (normal and x64) - 4.0MB
    PDF Library Files (normal and x64) - 75 and 75MB
    Photoshop (normal and x64) - 486 and 563MB
    Photoshop Support - 9.4MB
    Player for Embedding 3.3 (normal and x64) - 21 and 26MB
    Switchboard 2.0 - 1.1MB
    Type Support (normal and x64) - 6 and 6MB
    Winsoft Linguistics Plugin (normal and x64) - 8.2 and 8.5MB
    XMP Panels - 4.9MB
    ColorCommonSetCMYK - 13MB
    ColorCommonSetRGB - 8.6KB
    Camera Profiles Installer - 285MB
    MSVC++2005 redist. (normal and x64) - 11 and 11MB
    MSVC++2008 redist. (normal and x64) - 11 and 11MB
    MSVC++2010 redist. (normal and x64) - 11 and 11MB
    MSVC80_CRT (normal and x64) - 0.0 and 0.0KB
    PDF Settings - 2.4MB
    Camera Raw 7  (normal and x64) - 22 and 24MB
    Suite Shared Configuration - 3.2MB
    Some of these things we really want installed (Photoshop, CMaps, XMP panels, Type Support and required fonts and color profiles are pretty much the minimal set required for a functional Photoshop installation), but some of these things really have no right to be silentedly installed. There's a good gigabyte of nonsense that someone who just wants Photoshop has no need for. Denying them the option to unselect these things during installation is a bit evil (whatever happened to the 'advanced' or 'custom' installation option? That was a good option).
    That said, there's still something funky going on - unselecting all components indicates that the installation will required 0.0KB on disk. However, selecting Photoshop CS6 x64, which indicates its size is 563MB, results in an installation that requires 677MB on disk. Similar things happen for other components; CMaps is 7.2MB, but when you select it, it suddenly requires 121MB on disk.
    Much last last time, I fully appreciate the install team's choices in making sure the installer will always work as long as people don't tamper with it, but I'm not one of those people - I do tamper with it, because I want to control exactly what lands on my disk. So: how do I find out what these secret things are that are not listed after wiping the dependency data so that I can explicitly pick individual components? Which additional steps are required to reveal the hidden dependencies that will apparently still be installed, or aren't factored into the size indication for the various components? And finally, how do I make the installer NOT determine that "this is not a genuine installer, you may have a counterfeit product" =)
    I know it's been altered; I modified it, because I think your install process is trying to force stuff onto my computer that I never asked for, nor will ever use (I know they're quality products, they just have no right to exist on my computers. If I had the choice to say no, I'd acknowledge them as quality products instead).
    - Mike Kamermans
    nihongoresources.com
    NB: if Eric Wilde ends up replying to this post: I still remember your willingness to help figure this out for CS5, two years ago. Thank you again for that.

    I can see why you wouldn't want to release information that lets people set up arbitrary installers, but that's why I mostly wanted those two specific hashes. The installer team can just generate them without ever saying how, and we will only be able to use them to validate the installer for the modification that lets you pick components. This should in no way interfere with the desire to prevent dangerous installers making it into the wild; in fact, it kind of guarantees that's impossible.
    I know you can't guarantee it'll work or test it, and that's fine. Past experience has shown that CS3, CS4 and CS5 work fine with updates (and most updates don't apply to Photoshop, they apply to the additional components that I traditionally don't install), so I'm pretty sure it'll work fine with CS6 too, although of course it could go wrong in which case I can always fall back to a normal install.
    Would you be willing to ask the install team whether they could generate just these two numbers, based on the single SQL command run on Media_db.db from the main payload directory? I can fully understand not wanting to give the "here is how you generate the hashes" information, but generating two specific numbers that don't work for anything but this specific query should be just as safe as the various hashes we can already see for the other Media_db.db files in the various payload directories (so they wouldn't reveal anything not already known about how to reverse engineer the hashing algorithm). It'd help tech-savvy customers quite a bit without playing into the hands of criminally minded jerks (I actually had the pleasure of running into a duped CS3 Extended disc several years ago! I had ordered CS3 for personal use, and mysteriously received a CS3 extended version with a volume licensing key in what looked like an official normal CS3 box. Needless to say, authorities and Adobe were notified).
    <<I think the right answer to this issue is to simply remove from the products those items that are not required to execute the product. That's actually something we're aggressively pursuing this summer so that the product size reduces in future releases, particularly for PS.>>
    It's not possible to take components out of the payloads directory without the installer complaining that errors have occurred. It really wants all those files there when it starts =(
    <<Have you investigated using AAMEE? I don't think that will get rid of all the "extraneous" pieces; but, it does provide some flexibility in creating an install package that can then be pushed out through normal deployment tools (e.g. SCCM).>>
    I did, but unfortunately AAMEE requires the use of a volume license key, which I don't have. We only have individual products keys for the machines that will get Photoshop CS6.
    - Mike

  • JCheckBox as a Title for the Panel

    I have a group of checkboxes which will get enabled when their parent is checked.
    I want to put all the child checkboxes in a panel and the panel tile should hold the parent checkbox.
    So that whenever user checks/unchecks the parent checkbox, the child checkboxes gets enabled/disabled accordingly.
    Note:
    My aim is to have a checkbox as a title of the panel.
    Any code sample will be helpful.
    Thanks
    Meghu

    Hope this code will help you:
    /** CheckTitledPanel - class defining a panel with a Check box title
    * IMPORTANT NOTE: This class is managing 2 panels: the outer panel and the
    *                 inner panel. The inner panel acts as a "content pane", so
    *                 every method for adding/removing components or laying out
    *                 the contents must be called on the inner panel.
    *                 The method <code>getSubPanel()</code> is made for this
    *                 purpose.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class CheckTitledPanel extends JPanel {
       private JCheckBox checkbox;          // The title check box
       private JPanel subpanel;             // The sub-panel (content pane)
       /** Constructs a new Check box titled panel
         * @param title  the title of the panel
       public CheckTitledPanel(String title) {
          // The outer panel is set with no layout 
          super(null);
          // Creates the check box for the title, enabled by default,
          // set its size and no border
          checkbox = new JCheckBox(title, true);
          checkbox.setSize(checkbox.getPreferredSize());
          checkbox.setBorder(null);
          // Add the listener for title checking
          checkbox.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                boolean enabled = checkbox.isSelected();
                // When clicked, we enable/disable all
                // the children of the sub-panel
                setComponentEnabled(subpanel, enabled);
                subpanel.revalidate();
          // Create the sub-panel
          subpanel = new JPanel();
          // Define the outer panel with titled border (on which
          // will be over-painted the check box)
          setBorder(BorderFactory.createTitledBorder("X"));
          // Add the 2 components: check box and sub-panel
          add(checkbox);
          add(subpanel);
          // Add the listener for panel resizing
          addComponentListener(new ComponentAdapter() {
             public void componentResized(ComponentEvent e) {
                Dimension size = getSize();
                Insets insets = getInsets();
                // Relocate and resize the sub-panel
                subpanel.setLocation(insets.left, insets.top);
                subpanel.setSize(size.width - insets.left - insets.right,
                                 size.height - insets.top - insets.bottom);
                subpanel.doLayout();
                // Relocate and resize the check box
                checkbox.setLocation(insets.left + 2, 0);
                checkbox.setSize(checkbox.getSize().width, insets.top);
       /** Returns the preferred size of the panel */
       public Dimension getPreferredSize() {
          Dimension dim  = checkbox.getPreferredSize();
          Dimension dim2 = subpanel.getPreferredSize();
          Insets insets = getInsets();
          int width = dim.width + 12;
          if (dim2.width > width) width = dim2.width;     
          width = width + insets.left + insets.right;
          int height = dim2.height + insets.top + insets.bottom;
          return new Dimension(width, height);
       /** Returns the sub-panel (content pane)
         * @return  panel  the sub-panel
       public JPanel getSubPanel() {
          return subpanel;
       /** Standalone launching for tests */
       public static void main(String[] args) {
          CheckTitledPanel checkPanel = new CheckTitledPanel("Check to enable");
          checkPanel.getSubPanel().add(new JLabel("A label"));
          checkPanel.getSubPanel().add(new JTextField("A text field"));
          checkPanel.getSubPanel().revalidate();
          JFrame frame = new JFrame("Checkbox title test");
          frame.getContentPane().add(new JTextField("North field"), BorderLayout.NORTH);
          frame.getContentPane().add(new JTextField("South field"), BorderLayout.SOUTH);
          frame.getContentPane().add(new JTextField("West field"), BorderLayout.WEST);
          frame.getContentPane().add(new JTextField("East field"), BorderLayout.EAST);
          frame.getContentPane().add(checkPanel, BorderLayout.CENTER);
          frame.pack();
          frame.setVisible(true);
       /** Returns the sub-panel (content pane)
         * @return  panel  the sub-panel
       /** Enable/disable a component and its children
         * @param  rootcomp  the component to enable/disable
         * @param  enable    a boolean (true to enable)
       public static void setComponentEnabled(Component rootcomp, boolean enabled) {
          if (rootcomp==null) return;
          rootcomp.setEnabled(enabled);
          if (rootcomp instanceof java.awt.Container) {
             Component[] comps = ((Container)rootcomp).getComponents();
             String subvalues = "";
             for (int i=0; i<comps.length; i++) {
                setComponentEnabled(comps,enabled);
    // The following methods can be overwritten if you want to manage children
    // of the panel exactly the same way as a standard panel. In this case, you
    // will no more need to call getSubPanel().
    public Component add(Component comp) {
    subpanel.add(comp);
    public Component add(String name, Component comp) {
    subpanel.add(name, comp);
    public Component add(Component comp, int index) {
    subpanel.add(comp, index);
    public Component add(Component comp, Object constraints) {
    subpanel.add(comp, constraints);
    public Component add(Component comp, Object constraints, int index) {
    subpanel.add(comp, constraints, index);
    public Component findComponentAt(int x, int y) {
    return subpanel.findComponentAt(x, y);
    public Component findComponentAt(Point p) {
    return subpanel.findComponentAt(p);
    public Component getComponent(int n) {
    return subpanel.getComponent(n);
    public Component getComponentAt(int x, int y) {
    return subpanel.getComponentAt(x, y);
    public Component getComponentAt(Point p) {
    return subpanel.getComponentAt(p);
    public LayoutManager getLayout() {
    return subpanel.getLayout()
    public int getComponentCount() {
    return subpanel.getComponentCount();
    public Component[] getComponents()
    return subpanel.getComponents();
    public void remove(Component comp) {
    subpanel.remove(comp);
    public void remove(int index) {
    subpanel.remove(index);
    public void removeAll() {
    subpanel.removeAll();
    public void setLayout(LayoutManager mgr)
    subpanel.setLayout(mgr);
    Regards.

  • Unable to find the  'Panel Container 2' object

    Hi,
    I am unable to find the  'Panel Container 2' object under the containers folder of components. I am using xcelsius enterprise 2008.
    I have a scenario where in which i need to use it, Is there any way I can get it into the canvas.
    Thanks in advance,
    Shreesh.

    Hi,
    Which Theme are you using now? Not all of the themes have "Panel Container 2" object. Theme "Aqua" and Theme "Nova" have "Panel Container 2", please try them.
    Thanks,
    Grace

  • ADF Swing - Moving bound components to another panel (actually JFrame)

    We have an old(er) application developed on ADF Swing connecting to an Oracle Lite database using jdev 10.1.3.5. Everything works fine, but we want to reduce some screen clutter and move some fields off the main panel to be revealed in a separate "window" if the user presses a button. I created a JFrame (obviously not with the jdev designer as it doesn't seem to know what a JFrame is) and a JPanel where I move the "Address" fields (some fields that are only occasionally used). I drop the JPanel into the JFrame, make sure all of the code is in the jbInit section, add a button to do the setVisible and voila! As I scroll through the records in the main screen after a Find Execute, the address information changes along with it. However, if I try to enter Find mode and use one of the Address fields (like City), these fields do NOT become part of the find conditions. And yes, they are query-able in the BC4J component and yes, it did work when they were all on one pane.
    I suspect its the fact that the components don't identify themselves as being part of the panel that is bound to the iterator. So, how SHOULD I have done this so that I can use these fields in a Find AND in the results?

    Hi,
    try
    jTable1.setModel((TableModel)panelBinding.bindUIControl("JobHistoryView1",jTable1));
    jTable1.setColumnSelectionAllowed(true);
    jTable1.setRowSelectionAllowed(true);
    jTable1.getColumnModel().addColumnModelListener(new TableColumnModelListener(){
    public void columnAdded(TableColumnModelEvent e) {}
    public void columnRemoved(TableColumnModelEvent e){}
    public void columnMoved(TableColumnModelEvent e) {}
    public void columnMarginChanged(ChangeEvent e) {}
    public void columnSelectionChanged(ListSelectionEvent e) {
    boolean editMode = jTable1.editCellAt(jTable1.getSelectedRow(),jTable1.getSelectedColumn());
    if (editMode){
    jTable1.changeSelection(jTable1.getSelectedRow(),jTable1.getSelectedColumn(), false, true);
    Note that this works not 100% on row change, so make sure the select boxes are not on the first column
    Frank

  • How can I change the menubar depeneding on the panel selected?

    Hi,
    I am having the[b] AppMain.java extends JFrame and the Navigator extends AppMain.
    There is a perspective.java interface which has a getMenu() method as follows
    public JMenubar getMenu()
    There are 2 panels which are being interchenged depending on the button selected in the navigator.
    THey are the Admin and the Config which implements Perspective extends JPanel
    and they also have the method for getmenu()as follows.
    public JMenuBar getMenu()
    return Navigator.getInstance().getJMenuBar();
    in the Navigator I have the code for the setJMenuBar as follows
    String xmlFile = "/metadata/guidef.xml";
    //Parse the xml file that represents the gui menus, toolbars, actions, icons
    try
    ErrorFactory.getInstance().parse();
    GuiFactory.getInstance().setInputSource(xmlFile);
    GuiFactory.getInstance().parse();
    this.setIconImage(IconFactory.getInstance().getIcon("appicon").getImage());
    this.setJMenuBar(createMenuBar());
    catch (Exception e)
    e.printStackTrace();
    But what I need to do is I need to change the menubar depending on panel selected ?
    Thanks in advance.

    public class MQENavigator extends ApplicationMain {
    /** Main Content panel for the application Frame */
    public JPanel mainContentJPanel_;
         public JPanel mainViewPanel = null;
         JPanel perspectiveButtonBar = new JPanel();
    public JPanel perspectiveViewPanel = new JPanel();
    public JPanel configViewPanel = new JPanel();
    public JPanel commandStatPanel = new JPanel();
    private Hashtable panelsHash = null;
    static private final String mqenterpriseKey = "application.title";
    static private final String guidefKey = "ldmkxml.guidef.text";
         static private final String initmqKey = "ldmkxml.mqelayout.text";
         static private final String toolbarKey = "ldmkxml.create.toolbars.text";
         static private final String statusKey = "ldmkxml.create.statusbars.text";
         static private final String mainappKey = "ldmkxml.create.mainapp.view.text";
         static private final String launchKey = "ldmkxml.launch.mqenterprise.text";
         static private final String imgfnfKey = "ldmkxml.imgfile.notfound.text";
         //ints to keep track of heights of various components
    int iHeight_;
    //Splash window for updating status
    SplashWindow _splash = null;
    * Constructor for the main application frame
    public MQENavigator()
    super();
    try
    initComponent();
    initGUI();
    soleInstance_ = this;
    catch(Exception e)
    e.printStackTrace();
    * This will initialize the component defaults
    * @param None
    * @return None
    * @exception <{Exception}>
    protected void initComponent() throws Exception
    setAppKeyName("mqe");
    setIniFile("mqe");
    Locale.setDefault(SupportedLanguages.getLocale(
    Integer.parseInt(getIniFile().getProperty("selected.language", "0"))));
              String key = StringFactory.getString(mqenterpriseKey);
    setAppName(key);
    Log.init();
    Log.log(Log.NOTICE, this, Utilities.getResource("/metadata/version.info").trim());
    super.initComponent() ;
              String hs = getIniFile().getProperty("helpset.name");
              GuiResource.initializeHelp(hs);
    * This will initialize this components GUI
    * @param None
    * @return None
    * @exception Exception
    private void initGUI() throws Exception
              String guidefkey = StringFactory.getString(guidefKey);
              String initmqkey = StringFactory.getString(initmqKey);
              String toolkey = StringFactory.getString(toolbarKey);
              String statuskey = StringFactory.getString(statusKey);
              String mainappkey = StringFactory.getString(mainappKey);
              String launchkey = StringFactory.getString(launchKey);
    // Start the splash screen
    _splash = displaySplashScreen(createSplashPanel());
    // Create the Menu Bar
    _splash.incrementProgressTo(10, guidefkey);
    String xmlFile = "/metadata/guidef.xml";
    createJMenuBar(xmlFile);
    /**String configxmlFile = "/metadata/configguidef.xml";
    //Parse the xml file that represents the gui menus, toolbars, actions, icons
    try
    ErrorFactory.getInstance().parse();
    GuiFactory.getInstance().setInputSource(xmlFile);
    GuiFactory.getInstance().parse();
    this.setIconImage(IconFactory.getInstance().getIcon("appicon").getImage());
    this.setJMenuBar(createMenuBar());
    catch (Exception e)
    e.printStackTrace();
    // Set the main content panel for all the GUI components
    _splash.incrementProgressTo(15, initmqkey);
    mainContentJPanel_ = (JPanel) this.getContentPane();
    mainContentJPanel_.setLayout(new BorderLayout());
    mainContentJPanel_.setSize(new Dimension (800,600));
    //Lets create the panels that we need
    //Keep track of the height of the toolbar and status so we now the max
    //real estate we can use for the actual "guts" display of the application
    //ToolBar
    _splash.incrementProgressTo(20, toolkey);
    //Status Bar
    _splash.incrementProgressTo(30, statuskey);
    JPanel statusBarPanel = createStatusBar();
    iHeight_ += statusBarPanel.getHeight();
    /**commandStatPanel = new JPanel();
         commandStatPanel.setLayout(new BoxLayout(commandStatPanel, BoxLayout.Y_AXIS));
              CommandStatsPanel commands = new CommandStatsPanel();
              ApplicationMain.getInstance().setCommandPanel(commands);
    String shouldOpen = MQEPreferencesDialog.getPreferenceValue("enable.trace.commands");
              if (shouldOpen != null)
                   Boolean traceOn = new Boolean (shouldOpen);
                   if (traceOn.booleanValue())
                        AbstractAction action = LandMarkMQActions.getInstance().getActionForName("viewcommand");
                        action.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "enabled"));
                        //splitPane.setBottomComponent(commands);
                        commandStatPanel.add(commands);
              commandStatPanel.add(statusBarPanel);*/
    //MainView
    _splash.incrementProgressTo(40, mainappkey);
    mainViewPanel = new AdminPerspectivePanel();
              perspectiveViewPanel.setLayout(new BorderLayout());
              perspectiveViewPanel.add(mainViewPanel,BorderLayout.CENTER);
              perspectiveButtonBar.setLayout(new BoxLayout(perspectiveButtonBar, BoxLayout.Y_AXIS));
              perspectiveButtonBar.setBorder(BorderFactory.createRaisedBevelBorder());
              JButton adminPerspectiveButton = ComponentFactory.getInstance().createImageButton(IconFactory.getInstance().getIcon("navigator"));
              JButton configPerspectiveButton = ComponentFactory.getInstance().createImageButton(IconFactory.getInstance().getIcon("addicon"));
              JButton monitoringPerspectiveButton = ComponentFactory.getInstance().createImageButton(IconFactory.getInstance().getIcon("staricon"));
              configViewPanel = new ConfigPerspectivePanel();
              perspectiveButtonBar.add(adminPerspectiveButton);
              adminPerspectiveButton.addActionListener(new ActionListener()
                   public void actionPerformed (ActionEvent ae)
                        setPerspectivePane(mainViewPanel);
              perspectiveButtonBar.add(configPerspectiveButton);
              configPerspectiveButton.addActionListener(new ActionListener()
                   public void actionPerformed (ActionEvent ae)
                        setPerspectivePane(configViewPanel);
              // Done adding perspectiveButtonBar, perspectiveViewPanel and statusBarPanel to content pane
              mainContentJPanel_.add(perspectiveViewPanel, BorderLayout.CENTER);
    mainContentJPanel_.add(perspectiveButtonBar, BorderLayout.WEST);
    //mainContentJPanel_.add(commandStatPanel, BorderLayout.SOUTH);
    mainContentJPanel_.add(statusBarPanel, BorderLayout.SOUTH);
    //Launch the application
    _splash.incrementProgressTo(100, launchkey);
    launch(getAppName(), false) ;
    //To get around a swing bug set the locations of the splitpanes here
    setSplitDividers();
    validate();
    //This seems to fix the problem of the details panel split going to the correct location
    setSplitDividers();
    _splash.closeSplashWindow();
    setVisible(true);
    public void setPerspectivePane(JPanel panel)
              perspectiveViewPanel.removeAll();
              perspectiveViewPanel.add(panel);
              perspectiveViewPanel.revalidate();
              perspectiveViewPanel.repaint();
    public void setSplitDividers()
    double dividerLoc = .40;
    //The main split pane you want a 90 /10 split
    ApplicationMain.getInstance().getTreeDetailSplit().setDividerLocation(dividerLoc);
    ApplicationMain.getInstance().getTreeDetailSplit().setResizeWeight (dividerLoc);
    dividerLoc = .80;
    ApplicationMain.getInstance().getTreeCommandSplit().setResizeWeight (dividerLoc);
    ApplicationMain.getInstance().getTreeCommandSplit().setDividerLocation(dividerLoc);
    dividerLoc = .50;
    ApplicationMain.getInstance().getDetailEventSplit().setResizeWeight (dividerLoc);
    ApplicationMain.getInstance().getDetailEventSplit().setDividerLocation(dividerLoc);
    ((DetailPanel)ApplicationMain.getInstance().getDetailsPanel()).resetTableColumns();
    ((EventPanel)ApplicationMain.getInstance().getEventPanel()).resetTableColumns();
    //((CommandStatsPanel)ApplicationMain.getInstance().getCommandPanel()).resetTableColumns();
    public void createJMenuBar(String xmlFile)
              //Parse the xml file that represents the gui menus, toolbars, actions, icons
              try
                   ErrorFactory.getInstance().parse();
                   GuiFactory.getInstance().setInputSource(xmlFile);
                   GuiFactory.getInstance().parse();
                   this.setIconImage(IconFactory.getInstance().getIcon("appicon").getImage());
                   this.setJMenuBar(createMenuBar());
                   validate();
                   repaint();
              catch (Exception e)
                   e.printStackTrace();
    private JPanel createSplashPanel()
    String imagekey = StringFactory.getString(imgfnfKey);
    JPanel splashPanel = new JPanel(new BorderLayout());
    splashPanel.setBackground(Color.white);
    JLabel l = null;
    ImageIcon img = Utilities.getImage("/images/MQENavigator.jpg");
    if (img != null)
    l = new JLabel(img);
    else
    l = new JLabel(imagekey);
    l.setBackground(Color.white);
    l.setBorder(BorderFactory.createCompoundBorder());
    splashPanel.add(l, BorderLayout.CENTER);
    splashPanel.setPreferredSize(new Dimension ((int) l.getPreferredSize().getWidth(),
    (int) l.getPreferredSize().getHeight()));
    return splashPanel;
    static public void main (String[] args) throws Exception
    MQENavigator landMarkApp = new MQENavigator();
    Here in the code there is a setPerspectivePane() when the button are created and the admin and config are two different panels I meant to say.

  • How to reduce the size of the message box when appearing on the panel?

    When a user display message appearing on the panel,it overlaps my graphs due to its big size.How can I reduce its size or locate it at the corner of the panel? 

    Can you post an example? If you're referring to the User Message or User Prompt or the other dialogs, I'm not sure if the hooks are there to control where the dialog appears. Someone else might know different.
    “A child of five could understand this. Send someone to fetch a child of five.”
    ― Groucho Marx

  • Align Components how a panel Form Layout

    hi,
    I have the panel form layout with components, fine perfect, but...
    when I want to put a LOV such an output the text
    the center together the alignment of the components is lost i have the picture :)
    http://img100.imageshack.us/img100/7164/perfectoif.png
    but i want put the output text join component , example:
    http://img525.imageshack.us/img525/4543/asiquiero.png
    the logic solution, i group component with panel group layout but the form i see:
    http://img97.imageshack.us/img97/1096/erroryd.png
    Any idea?? i use jdev 11.1.1.2
    Joaquin
    Edited by: ADFboy on 03-may-2010 10:54
    Edited by: ADFboy on 03-may-2010 11:43

                  <af:panelFormLayout id="pfl1" labelAlignment="start"
                                      maxColumns="2" rows="1">
                    <af:panelGroupLayout id="pgl2" layout="horizontal"
                                         valign="bottom" halign="start"
                                         inlineStyle="text-align:left;">
                      <af:inputListOfValues label="ghdghd ghdghdf"
                                            popupTitle="Search and Result Dialog"
                                            id="ilov2"/>
                      <af:outputText value="outputText2" id="ot2"/>
                    </af:panelGroupLayout>
                    <af:inputListOfValues label="Label 1 fgs d"
                                          popupTitle="Search and Result Dialog"
                                          id="ilov1"/>
                    <af:inputListOfValues label="Label 2"
                                          popupTitle="Search and Result Dialog"
                                          id="ilov4"/>
                    <af:panelGroupLayout id="pgl1" layout="horizontal">
                      <af:inputListOfValues label="dghd ghdhd"
                                            popupTitle="Search and Result Dialog"
                                            id="ilov3"/>
                      <af:outputText value="outputText3" id="ot1"/>
                    </af:panelGroupLayout>
                    <af:inputListOfValues label="Label 3"
                                          popupTitle="Search and Result Dialog"
                                          id="ilov5"/>
                    <af:inputListOfValues label="Label 4"
                                          popupTitle="Search and Result Dialog"
                                          id="ilov6"/>
                    <af:inputListOfValues label="Label 5"
                                          popupTitle="Search and Result Dialog"
                                          id="ilov7"/>
                    <af:inputListOfValues label="Label 6"
                                          popupTitle="Search and Result Dialog"
                                          id="ilov8"/>
                  </af:panelFormLayout>

Maybe you are looking for