Tabs in JList

Hi all!
I have just used JList for the first time and have run into problem. I would like to print a name and then have some spaces and in the end print another string representing a date. The problem is that depending on which characters the name contains the indenting of the date string isn't always the same. Example:
Andreas 25FEB
iiiiiii 24FEB
There are equal amout of characters but they have different "size". Anyone have a tip of how to solve this? I have tried to add '\t' between the strings but then it prints a box in between the strings in the list. Do I have to use JTable?
Thanks in advance!
regards,
Andreas

Yeah, your right. Unfortunatelly then it isn't possible to use the icons I want to use. Somebody knows of how to modify the example to get it to work using icons as well? What I want to show in the list is:
* A small icon
* A short text
* A tab
* Another short text
Example:
ICON MyName'\t'Date
// Andreas

Similar Messages

  • JTabbedPane lose JList contents

    Hi , this is my first question in the forum :D, i have a problem with a JTabbedPane with two tabs, each with a JList in a JPanel, the problem is that i populate the Jlists in a dynamic way using a vector. the Jlist in the first index (tab) is populated first and then I select the second tab and populate the second Jlist, but when I return to the first tab the Jlist is empty, i guess because it is repainted, which method or what i need to do to keep my JList populated !!

    In the future Swing related questions should be posted in the Swing forum.
    Without seeing your code we can only guess!
    Swing components can't be shared.
    You need to create two JLists, one for each tab.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the [Code Formatting Tags|http://forum.java.sun.com/help.jspa?sec=formatting], so the posted code retains its original formatting.

  • Setting size.... goes terrible wrong

    Dear mr. java,
    I have some troubles of setting the size of my JPanels... I thought I just could with setsize(), but that doesn't work... If I run my code now, I have a very wide window. with very big buttons.
    Also In my left panel I added GridBagLayout (I thought that would solve the problem) but It doesn't stay fixed, the buttons doesnt do wath Im telling them.
    In short it doesnt do anything I tell him about placement and sizing :-s!
    Some poeple have any idea?
    my code:
    import javax.swing.BoxLayout;
    import javax.swing.DefaultComboBoxModel;
    import javax.swing.DefaultListSelectionModel;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JFrame.*;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JRadioButton;
    import javax.swing.JSpinner;
    import javax.swing.JTabbedPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.JWindow;
    import javax.swing.ListModel;
    import javax.swing.SpinnerListModel;
    import javax.swing.JTextPane;
    import javax.swing.ButtonGroup;
    import javax.swing.JList;
    import javax.swing.JMenuItem;
    import javax.swing.JPopupMenu;
    import javax.swing.JScrollPane;
    import javax.swing.SwingUtilities;
    import java.awt.BorderLayout;
    import java.awt.Button;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.FlowLayout;
    import java.awt.Frame;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.GridLayout;
    import java.awt.Panel;
    import java.awt.PopupMenu;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.Insets;
    import javax.swing.WindowConstants;
    import javax.swing.JFileChooser;
    import java.io.*;
    import java.util.*;
    import javax.swing.border.TitledBorder;
    import javax.swing.border.LineBorder;
    public class Buttons3 extends JFrame {
         private JTextArea progress;
         private JButton Analyse;
         private JButton parameters;
         private JPanel files;
         private JTextField filename;
         private JButton browse;
         private JRadioButton SDDS;
         private String filenamepub;
         private JLabel name;
         private JPanel data;
         private JTabbedPane tab;
         private JList listraw;
         private JList listanal;
         private JPanel graph;
         private JTextArea plot;
         private JPanel info;
         private JButton test;
         public static void main (String args[]){
              new Buttons3();
         public Buttons3(){
              super("main Window");
              Container content = getContentPane();
         content.setBackground(Color.lightGray);
         JPanel analyse = new JPanel(new GridLayout(3, 1));
         GridBagConstraints gbc = new GridBagConstraints();
         gbc.fill = GridBagConstraints.BOTH;
                        Analyse = new JButton("Analyse");
                        gbc.gridy = 0; // telling where the row start
                        gbc.gridx = 0; // telling at which column
                        gbc.gridwidth = 1; // number of columns
                        gbc.gridheight = 1; // number of rows     
                        gbc.weightx = gbc.weighty = 0.0;
                        analyse.add( Analyse,gbc); // adding the button
                        Analyse.addActionListener(
                                  new ActionListener()
                                       public void actionPerformed (ActionEvent event)
                                                 DriveCall god_lin = new DriveCall();
                        gbc.gridy = 1; // telling where the row start
                        gbc.gridx = 0; // telling at which column
                        gbc.gridwidth = 1; // number of columns
                        gbc.gridheight = 1; // number of rows
                        gbc.weightx = gbc.weighty = 0.0;
                        parameters = new JButton("Parameters");
                        analyse.add( parameters,gbc); // adding the button
                        parameters.addActionListener(
                                  new ActionListener()
                                       public void actionPerformed (ActionEvent event)
                                                 Parameters para = new Parameters();
                                                 para.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                                                 para.setSize(400,400);
                                                 para.setVisible(true);
                        progress = new JTextArea();
                        gbc.gridy = 3; // telling where the row start
                        gbc.gridx = 0; // telling at which column
                        gbc.gridwidth = 1; // number of columns
                        gbc.gridheight = 1; // number of rows
                        gbc.weightx = gbc.weighty =1.0;
                        analyse.add( progress,gbc ); // adding the button
                        progress.setText("sfsfdfsdfsdfsd \n fadsfsdfsdfsdf \n safdsfasdfdfdsf \n sfafafasfafaf");
                   analyse.setBorder(new TitledBorder(new LineBorder(Color.BLACK),"Analyse"));
                   analyse.add(progress);
                   ///// beginning of the JPanel files!
                   files = new JPanel();               
                   files.setLayout(new GridLayout());
                   files.setSize(200,50);
                   filename = new JTextField();
                   filename.setColumns(40);          
                        name = new JLabel("Filename :");
                        browse = new JButton("browse");
                        SDDS = new JRadioButton("SDDS");
                        //adding actionlistener that activates the converter
                   files.setBorder(new TitledBorder(new LineBorder(Color.BLACK),"Files"));
                   files.add(name);files.add(filename);files.add(browse);files.add(SDDS);
              ////// This is the end of the JPanel Files
         ////// beginning of the JPanel data ....
                   data= new JPanel();
                        tab = new JTabbedPane();
                        data.add(tab);
                        listraw = new JList();
                        data.add(listraw);
                        listanal = new JList();
                        data.add(listanal);
                   data.setBorder(new TitledBorder(new LineBorder(Color.BLACK),"Data"));
              ///// end of the JPanel     data
              /// beginning of the JPanel graph
                   graph = new JPanel();
                        plot = new JTextArea();
                        graph.add(plot);
                   graph.setBorder(new TitledBorder(new LineBorder(Color.BLACK),"plotting"));
         /////// end of the JPanel graph
         ///// beginning of the JPanel info
                   info = new JPanel();
                        test = new JButton("test");
                        info.add(test);
                   info.setBorder(new TitledBorder(new LineBorder(Color.BLACK),"info"));
         ///// end of the JPanel info
         //// adding everything together
         content.add(analyse, BorderLayout.WEST);
         content.add(files,BorderLayout.NORTH);
         content.add(data,BorderLayout.EAST);
         content.add(graph,BorderLayout.CENTER);
         content.add(info,BorderLayout.SOUTH);
         pack();
         setVisible(true);     
    }

    can u explain what u want???
    I observed something like u add twice this line analyse.add(progress) u delete the second time add(progress).
    Set the size to the JFrame,
    and use GridBagLayout, instead of GridLayout,
    GridLayout will divide the space equally, that's why u'r getting Analyse
    and Parameter Buttons in the Bigger and equal in size.

  • Urgent : UI refresh problem on dual processor or hyper threaded machine

    Hello,
    I am developing an applet that displays a set of tabs to the user. Each tab contains JLists.
    When user selects from any of the JList(s), all lists are updated to reflect what is still available for selection. Number of elements in the list can be as large as few hundred thousands. This all works fine on single processor machine.
    However, when running same on dual processor or Intel hyperthreaded processor, lists are not updated correctly. What I meant is that, for example, if a list originally has 100 thousands elements in it, then when I select an element from it, list is updated with available elements.Assume there are only 2 thousand elements available after above selection.Everything is fine so far, but when I de-select my selection, list is suppose to be updated again with original 100 thousands elements displayed again. The real problem is list indeed gets updated properly but few elements from list are not visible on the screen. However, If I minimize the browser(as it is an applet) and restore it again, all elemnets within the list are displayed correctly. Any help will be highly appreciated.

    When your JLIst refresh occurs, the items are loaded into the JList from some other Object right? Nt knowing more about your code, I can't say exactly what that would be.Yes, you are right. Let me explain in breif about the architecture of the code.
    I have a class,say CatPanel, that extends from JPanel and has BorderLayout with JList (wrapped in JScrollPane) in the center.
    The main GUI class controls all such CatPanels.So, when the list is to be updated, GUI class invokes a method from CatPanel with Vector of elements to be inserted as an argument. Elements are inserted using setListData method of the JList.
    If I'm right, the this might explain the behavior you are seeing. In a single processor environment, the data >is not cahced and therefore everything is fine. When you go to the dual-processor machine, the threads >have their own caches and are not always in sync. When you mimize the window and restoer it, this could >trigger a resync of the cache.Is there a way to trigger such synchronization?
    One thing I'm not sure about is, when you return to the 'main' list, do you still see the selected sublist or >the main list with some elements missing? When a list is updated as a result of de-selection, few elements from start of the list are not visible.
    I can see all other elements by using ScrollBar. So, if there are some selections that belong to the begining portion of the list, then selected sublist is not visible.
    Let me explain with following example. Assume that with current selection, I have 100 elements in the list and all of them are visible on the screen. Now as a result of de-selection, suppose now the list should contain 200 elements rather than 100 elements. So, what happens in this case is that if first 50 elements are not visible in the list then I can see blank space corresponding to first 50 elements at the start of the list followed by remaining elements. I tried overloading paint method of an element that is actually inserted into the list, but still the result is same.

  • Selection problem in a JList !!!!

    I am using a JList and on the selection of an item in this JList - I enable and disable some buttons.
    I have currenlty added a ListSelectionListener that allows me to trap the valuechanged event and thus if any item in the list is selected / deselected, i can enable/ disable the buttons.
    Now the abuv works fine with click and Ctrl clicking (to deselect),
    However if i come into the JList from another control (a JCombo) by tabbing and then use the arrow keys once the control is in the JList, the up and down arrow keys allow me to change the selection in the list.
    But, the valueChanged event does not come in the above case and hence the buttons do not enable/disable !!!
    Can you tell me what can be the problem?????

    Add a key listener and handle the KeyEvent
    Sachin

  • How to specify the font in a JList?

    My application has four columns of data represented in a JList. The default font style does proportional spacing.
    I need to specify a fixed width font to control column alignment in the JList. Unless there's something like tab positions? If I can specify a fixed width font, I can format the display strings appropriately.
    I think I need to use a cell renderer to control the actual drawing of each cell in the JList?
    Also, where do I find a list of the font types?
    Thanks in advance!

    I don't think you need a cell renderer. You find out how to specify font names by (oddly enough) looking in the API documentation for the Font class; the info for the most usable-looking constructor tells you what you want to know.

  • Add the same component in 2 different tabs

    I am trying to add the same component in two different tabs in a tabbed pane. When I add it (programaticaly) the first instance disappears. Is this at all possible. I dont want to clone the component first and then add it.
    Thank you

    In my appllication I have a tab (call it main tab) that includes many components, like a textfield and texteditorpane that form a command line tool, a list of connected clients (names) and several other components in the same tab. Now the user, can issue a command from the command line to open any component in a new tab, for example he might want to open the clients list in a separate tab, while still having an instance of the clients list in the main tab.
    Also when something is updated (for example a new name is added in the list) I want both instances to be updated at the same time (since there is actually one Jlist object there shouldn't be any additional code to do that).
    So far, when i am opening a new tab holding a component from the command line (the one i made), the same component disappears from the main tab.
    I ll try what was mentioned above.
    Edited by: FreshPrince1 on Apr 12, 2010 6:50 AM

  • Interesting Focus II: JComboBox, 2 JLists and 1 Button

    Hi All,
    Another Interesting Keyboard Focus Question:
    What we want to do?
    Let's say we want to build a JComboBox whose popup contains 2 JLists and a button.
    What we would probably want to do is:
    comboBox.setUI(new MyComboBoxUI());
    MyComboBoxUI will extend BasicComboBoxUI and
    ovveride createPopup to return a BasicComboPopup subclass
    which will add the other JList and JButton.
    (One can argue that this is not a JComboBox anymore, but bare with me)
    Does it work?
    This will work great with the Mouse, but with the Keyboard we face a problem:
    After our popup is displayed, The JComboBox Still Has The Focus - Any UP or DOWN Events are really proccessed by the JComboBox which simulates JList navigation...
    This is happening because the popup is not keyboard-focusable (and so do all of its components)
    Where' s the problem?
    We want to be able to:
    1. Press TAB to navigate thru the 3 components
    2. Press UP and DOWN to navigate the two JLists
    3. Press Space to activate the JButton
    Possible solutions:
    1.
    Don't subclass BasicComboPopup and write a ComboPopup which uses a Focusable JWindow.
    Problem: The JComboBox will lose the focus when the popup opens
    2.
    Simulate all the DOWN/UP/TAB/SPACE events to the popup
    Problem: The components are not focusable, hence there is no indication
    of who is the current focused component
    (Might be solved by surrounding the 'focused' component with a border)
    Your thoughts?
    If you haven't fell asleep by now, you are welcomed to share you ideas, Thanks
    Eyal Katz

    Sorry, I don't understand what you are trying to accomplish. However one line did catch my eye.
    This is happening because the popup is not keyboard-focusable The code in the popupPopup() method in the following post might help:
    http://forum.java.sun.com/thread.jspa?threadID=636842

  • Rather Specific JList Conundrum

    Hi Guys,
    I've come to a bit of a brick wall on the project I'm working on, but as my problem is so specific no amount of Googling is helping me.
    Essentially my coursework is to make a twitter client using the Twitter4JAPI, the part I'm stuggling with is showing the home feed. I want it to show the Icon, with the User and Status next to it which I'm doing using my own custom cell renderer. Now it works fine, but the program takes ages to load as it pulls all the avatars off the web, swapping to and from that tab takes ages (for the same reason), and scrolling the list is so mind blowingly slow, as every tick it refreshes all the images (from the web).
    Any suggestions how to stop this?
    Here is my custom cell renderer code:
    public Component getListCellRendererComponent(JList list, Object value,
                   int index, boolean isSelected, boolean cellHasFocus) {
              input = value.toString();
              final String splitArray[] = input.split("`");
              Image avatar = null;
              try {
                   final URL avatarURL = new URL(splitArray[0]);
                   avatar = ImageIO.read(avatarURL);
              } catch (final IOException e) {
                   JOptionPane.showMessageDialog(null,
                             "Error retriving some users avatars",
                             "Image download error", JOptionPane.ERROR_MESSAGE);
              usersAvatar.setIcon(new ImageIcon(avatar));
              tweet.setText(splitArray[2]);
              userName.setText(" " + splitArray[1] + "    ");
              return mainPanel;
         }I cut out all the layout junk.
    And the input for the list is in the form avatarurl`username`tweet, which is then split and stored in the split array.
    I've had a bash at threading it based on [Improve Application Performance With SwingWorker in Java SE 6|http://java.sun.com/developer/technicalArticles/javase/swingworker/] but it meant that the avatars were all identical.
    Do I need to thread the entire list creation section instead of just the image retrival.
    All help greatly appreciated.
    For your reference --->

    I can safely say you answered my question.
    The 2 classes I added were:
    User Class import javax.swing.ImageIcon;
    public class UserClass {
         String userName;
         ImageIcon userAvatar;
         public UserClass(String user, ImageIcon avatar) {
              userName = user;
              userAvatar = avatar;
         public String getUserName() {
              return userName;
         public ImageIcon getUserAvatar() {
              return userAvatar;
    }and UserDB
    import java.awt.Image;
    import java.io.IOException;
    import java.net.URL;
    import java.util.ArrayList;
    import javax.imageio.ImageIO;
    import javax.swing.ImageIcon;
    public class UserDB {
         private ArrayList<UserClass> users;
         public UserDB(){
              users = new ArrayList<UserClass>();
         public ImageIcon getAvatar(String username){
              ImageIcon avatar = null;
              for (int i = 0; i < users.size(); i++) {
                   String beingChecked = users.get(i).getUserName();
                   if (username.equals(beingChecked)) {
                        avatar = users.get(i).getUserAvatar();
              return avatar;
         public String getUserName(int index){
              return users.get(index).getUserName();
         public int getTotalUsers() {
              return users.size();
         public void addUser(String userName, URL profileImageURL){
              Image avatar = null;
              try {
                   final URL avatarURL = profileImageURL;
                   avatar = ImageIO.read(avatarURL);
              } catch (final IOException e) {
              ImageIcon avatarIcon = new ImageIcon(avatar);
              UserClass tooAdd = new UserClass(userName, avatarIcon);
              users.add(tooAdd);
         public boolean isEmpty(){
              return users.isEmpty();
    }So now the first time it encounters a unique user for the first time it add's it too the database.
    Honestly that's an approach i would never have thought of in a million years!
    Thanks a bunch

  • Stop "Ctrl-Page Down" in a JList but propergate the event

    Hi all. I have a JList inside a tabbed pane.
    On my tabbed pane I have hot keys such that Ctrl-Page Up and Ctrl-Page Down change the tab. This works fine except when a JList has focus in the tab.
    When I press Ctrl-Page Up or Page Down on the JList I don't want it do anything and I would like the tab to change as expected.
    If I add this to my JList:
    list.getInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, InputEvent.CTRL_DOWN_MASK), "none")it stops my JList from reacting to the Ctrl-Page Down but it doesn't propergate it up to the tabbed pane.
    Does anyone know how I can do this?
    Thanks, Nick.

    Hi guys. Thanks for the responses but it still isn't working.
    I changed my component to this:
    list.getInputMap(JComponent.WHEN_FOCUSED).getParent().remove(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, InputEvent.CTRL_DOWN_MASK));and it does remove the ctrl-page down from the JList. However, it still isn't being propergated to the JTabbedPane.
    In case it helps, this is how I'm adding the action in the tabbed pane:
    tabbed.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, InputEvent.CTRL_DOWN_MASK), "nextTabAction");Am I doing something wrong?
    Thanks, Nick.

  • Jlist with database?

    I have to get a few members out of a database and put them in a list.
    Then the admin can select the member he wants and alter his information.
    Now i was thinking of putting those members into a Jlist but I have a few problems with that.
    I want it in the list like this
    Membernumber1 membername1 memberadres1 .....
    Membernumber2 membername2 memberadres2 .....
    this gives me a problem, since i will know wich listindex is selected but i won't know what's the membernumber of the one that's selected so I won't really be able to change it in the database. Also not every name is the same length so the information in the list will look scrambled since \t tabs seem not to be working in listmodels.
    Is a list the right choice here, do I have to choose something different or can I solve these problems in some way.
    Tnx in advance.

    All you need to do is to store the data retrieved in a temporary object (say DbData) and this can give you the data for each member.
    Then create your own renderer for you JList that takes your object and uses a JPanel with JLabels to display your data. Alternatively, the DbData object can be the JPanel itself and this can passed directly to the JList renderer.
    eg
    class DbData extends JPanel {
       JLabel number, name;
      public DbData(String number, String name) {
         super();
         setDbData(number, name);
    public void setDbData(String number, String name) {
        // create and initialize JLabels with text
    public String[] getDbData() {
        // return number and name as string[]
    class DbDataRenderer extends DefaultListCellRenderer {
       public Component getListCellRendererComponent(JList list, Ojbect value, int index,
                           boolean isSelected, boolean hasFocus) {
            if(value instanceof DbData) {
                 return (DbData)value;
            return this;
    }However, if the data your retrieving to display is more than three items, then it might be better to use a JTable to display the items
    ICE

  • How to put tabs on ListModel

    I'm trying to print an object using ListModel + JList. Is necessary some tabs to print the information.
    The code:
    public String toString(){
    return (getNumeroConta() + "\t" +
    getTipoConta() + "\t" +
    "R$" + mascara.format(getValorConta()) + "\t" +
    getCodAgencia() + "\t" + getBanco());
    When it is printed the information appears all together without spaces.
    How can I fix this?

    you need your own cell renderer which understand tabs. the default (JLabel) doesn't.
    thomas

  • JTable used as a JList

    I am using a JTable as a JList (because it displays two columns). Above the JTable is an entry field when the user selects an item in the list with the mouse it adds it the entry field, I use a ListSelectionlistener This is fine.
    I then tested it using the keyboard. As I scroll down the list with the up/down cursor keys it adds each entry to the entry field. This is not what I was expecting I thought you would be able to scroll down the list and then press Enter/Space to select the record and add it to the list.
    I could add a button that the user has to select after selecting from the list before it is added to the entry field, but that creates an extra uneccessary stepo for mouse users. And one of my design goals for this project was to minimize the number of steps needed to complete any task.
    Does anybody know how to do what i want, or its it a bad idea ?

    Tables don't support the concept of an ActionEvent when you press the enter key. You could use a JList with a custom renderer to display two columns:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class ListMultiColumn extends JFrame
         public ListMultiColumn()
              String[] tabs =
                   "123456\tone",
                   "2\ta really really long description goes here",
                   "3\tthree",
                   "41\tfour"
              JList list = new JList( tabs );
    //          list.setCellRenderer( new TextAreaRenderer() );
              list.setCellRenderer( new TextPaneRenderer() );
              list.setSelectedIndex(2);
              getContentPane().add( list );
         public static void main(String[] args)
              JFrame frame = new ListMultiColumn();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible( true );
         **  Tabs are easier to use in a JTextArea, but not very flexible
         class TextAreaRenderer extends JTextArea implements ListCellRenderer
              public TextAreaRenderer()
                   setBackground(Color.blue);
                   setTabSize(10);
              public Component getListCellRendererComponent(JList list, Object value,
                   int index, boolean isSelected, boolean cellHasFocus)
                   System.out.println(getBackground());
                   setText(value.toString());
                   setBackground(isSelected ? list.getSelectionBackground() : null);
                   setForeground(isSelected ? list.getSelectionForeground() : null);
                   return this;
         **  Tabs are harder to use in a JTextPane, but much more flexible
         class TextPaneRenderer extends JTextPane implements ListCellRenderer
              private final int TAB_COLUMN = 10;
              public TextPaneRenderer()
                   setMargin( new Insets(0, 0, 0, 0) );
                   FontMetrics fm = getFontMetrics( getFont() );
                   int width = fm.charWidth( 'w' ) * TAB_COLUMN;
                   TabStop[] tabs = new TabStop[1];
                   tabs[0] = new TabStop( width, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE );
                   TabSet tabSet = new TabSet(tabs);
                   SimpleAttributeSet attributes = new SimpleAttributeSet();
                   StyleConstants.setTabSet(attributes, tabSet);
                   getStyledDocument().setParagraphAttributes(0, 0, attributes, false);
              public Component getListCellRendererComponent(JList list, Object value,
                   int index, boolean isSelected, boolean cellHasFocus)
                   setText( value.toString() );
                   setBackground(isSelected ? list.getSelectionBackground() : null);
                   setForeground(isSelected ? list.getSelectionForeground() : null);
                   return this;
    }

  • Can't select when JList populated by LOV

    I'm at a loss here...
    JDev 10.1.2.1 (1913)
    I'm creating a simple Swing Shuttle panel. I want standard action, i.e. when the 'shuttle' button is pressed, the selected items in JList1 move to JList2.
    I first created this with JList1 bound to a VO. I quickly realized that I couldn't remove elements from the list without removing the appropriate rows from VO...tried to do that but ran into errors.
    Ok, so i figured I'd create a programmatic VO and followed the documentation to populate this with a LOV from the db-backed VO attribute I want.
    The problem is that all list values are grayed out and un-selectable
    Steps:
    1 - Create DB-backed VO and programmatic-backed VO with same attributes (I created these using the Ename field from Scott.EMP)
    2 - Create JPanel
    3 - Find the programmatic-backed VO on the Data Control palette
    4 - Expand to find the attribute I want to show in my JList; select "Drag and drop as List"; drag onto my panel
    5 - Open the List binding editor from the Structure window
    6 - On the LOV Update attributes tab I select the DB-backed VO as the source and the programmatic VO as the target
    7 - On the LOV display attributes tab I shuttle over the attribute I want to display (Ename)
    I tried the three different selectionModes...I compared the properties of the VO-backed JList with the LOV-backed list and can't find a difference. I fooled around with the "Updatable" settings in the VO...
    Any ideas why this doesn't work as i expect?
    thanks
    John

    I'm not sure that there is anything in the ADF Bindings to help you here. What we have done is to programatically execute the query and add each Row to the JList. You will need a custom renderer to the JList so that the list knows which attribute from the Row to display. Then when you shuttle the row over, you just remove it from the first JList and add it to the 2nd JList. It is also very easy to create a generic ListCellRenderer that knows how to display Row objects. Here is one that we use:
    import java.awt.Component;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.ListCellRenderer;
    import oracle.jbo.Row;
    public class ADFRowListCellRenderer extends JLabel implements ListCellRenderer {
      private String attributeName = null;
      public ADFRowListCellRenderer(String attributeToDisplay) {
        this.attributeName = attributeToDisplay;   
      public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {  
        Row row = (Row) value;
        String fieldValue = null;
        if( row != null ) {
          Object objectValue = row.getAttribute(attributeName);  
          if( objectValue != null ) {
            fieldValue = objectValue.toString();  
        setText(fieldValue == null ? "" : fieldValue);
        setOpaque(true);
        setBackground(isSelected
               ? list.getSelectionBackground()
               : list.getBackground());
        setForeground(isSelected
               ? list.getSelectionForeground()
               : list.getForeground());    
        return this;
    }One thing to remember is that a Row instance has some internal id assigned to it, so if you re-execute the query, your list's Row references will be invalid. If you have to re-execute the query, then you will need to clear the JLists and reload the Rows.
    Hope this helps
    Erik

  • JTabbedPane keeps track of last selected tab

    Hi everybody,
    experiencing some problems with swing...
    I've got a javax.swing.JTabbedPane whose behaviour is kind of strange: I need my application to have always the same tab selected at initialisation, which is very simple in theory. In my initialisation method I just do:
    MainTab.setSelectedIndex(0);
    But instead of selecting the first tab (index 0), it keeps selected the one I last chose in the previous run.
    Any idea?
    Thanks in advance.
    JON HAITZ

    Hi calvino_ind,
    I am unfortunately not allowed to disclose my entire code, but I'm posting the code part where the problem may lie so that you can try to guess where the problem comes from:
    public class VitalSignMonitorView extends FrameView {
    public VitalSignMonitorView(SingleFrameApplication app) {
    super(app);
    initComponents();
    init();
    // status bar initialization - message timeout, idle icon and busy animation, etc
    ResourceMap resourceMap = getResourceMap();
    int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
    messageTimer = new Timer(messageTimeout, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    statusMessageLabel.setText("");
    messageTimer.setRepeats(false);
    int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
    for (int i = 0; i < busyIcons.length; i++) {
    busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
    busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
    statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
    idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);
    // connecting action tasks to status bar via TaskMonitor
    TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
    taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
    public void propertyChange(java.beans.PropertyChangeEvent evt) {
    String propertyName = evt.getPropertyName();
    if ("started".equals(propertyName)) {
    if (!busyIconTimer.isRunning()) {
    statusAnimationLabel.setIcon(busyIcons[0]);
    busyIconIndex = 0;
    busyIconTimer.start();
    progressBar.setVisible(true);
    progressBar.setIndeterminate(true);
    } else if ("done".equals(propertyName)) {
    busyIconTimer.stop();
    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);
    progressBar.setValue(0);
    } else if ("message".equals(propertyName)) {
    String text = (String)(evt.getNewValue());
    statusMessageLabel.setText((text == null) ? "" : text);
    messageTimer.restart();
    } else if ("progress".equals(propertyName)) {
    int value = (Integer)(evt.getNewValue());
    progressBar.setVisible(true);
    progressBar.setIndeterminate(false);
    progressBar.setValue(value);
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
    mainPanel = new javax.swing.JPanel();
    MainTab = new javax.swing.JTabbedPane();
    panelWelcome = new javax.swing.JPanel();
    labelPatientChoice = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    tablePatientList = new javax.swing.JTable();
    buttonSelectPatient = new javax.swing.JButton();
    buttonCreatePatient = new javax.swing.JButton();
    jSeparator5 = new javax.swing.JSeparator();
    panelPatient = new javax.swing.JPanel();
    jSeparator1 = new javax.swing.JSeparator();
    jSeparator2 = new javax.swing.JSeparator();
    jSeparator3 = new javax.swing.JSeparator();
    jSeparator4 = new javax.swing.JSeparator();
    m_PanelPI = new javax.swing.JPanel();
    mPI_LabelSex = new javax.swing.JLabel();
    mPI_LabelName = new javax.swing.JLabel();
    mPI_Name = new javax.swing.JTextField();
    mPI_LabelSurname = new javax.swing.JLabel();
    mPI_Surname = new javax.swing.JTextField();
    mPI_LabelBirthDate = new javax.swing.JLabel();
    mPI_BirthDateChooser = new com.toedter.calendar.JDateChooser();
    mPI_SexComboBox = new javax.swing.JComboBox();
    m_PanelAI = new javax.swing.JPanel();
    mAI_LabelWeight = new javax.swing.JLabel();
    mAI_Height = new javax.swing.JTextField();
    mAI_LabelHeight = new javax.swing.JLabel();
    mAI_Weight = new javax.swing.JTextField();
    m_PanelSI = new javax.swing.JPanel();
    mSI_CentreRegDate = new javax.swing.JLabel();
    mSI_LabelSystemRegDate = new javax.swing.JLabel();
    mSI_CentreRegDateChooser = new com.toedter.calendar.JDateChooser();
    mSI_SystemRegDateFormattedTextField = new javax.swing.JFormattedTextField();
    jButton1 = new javax.swing.JButton();
    mG_PatientId = new javax.swing.JTextField();
    mG_LabelPatientId = new javax.swing.JLabel();
    jButton2 = new javax.swing.JButton();
    panelContactPerson = new javax.swing.JPanel();
    panelIllness = new javax.swing.JPanel();
    panelDrugs = new javax.swing.JPanel();
    panelDevice = new javax.swing.JPanel();
    panelMeasurement = new javax.swing.JPanel();
    jScrollPane2 = new javax.swing.JScrollPane();
    listMeasurementType = new javax.swing.JList();
    labelSelectMeasurementType = new javax.swing.JLabel();
    jSeparator6 = new javax.swing.JSeparator();
    jScrollPane3 = new javax.swing.JScrollPane();
    tableMeasurements = new javax.swing.JTable();
    labelTableMeasurements = new javax.swing.JLabel();
    jSeparator7 = new javax.swing.JSeparator();
    labelSelectedMeasurementType = new javax.swing.JLabel();
    textFieldSelectedMeasurementType = new javax.swing.JTextField();
    panelMeasurementDisplay = new javax.swing.JPanel();
    jTextFieldSelectedPatient = new javax.swing.JTextField();
    jLabel14 = new javax.swing.JLabel();
    menuBar = new javax.swing.JMenuBar();
    javax.swing.JMenu fileMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
    javax.swing.JMenu helpMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
    statusPanel = new javax.swing.JPanel();
    javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
    statusMessageLabel = new javax.swing.JLabel();
    statusAnimationLabel = new javax.swing.JLabel();
    progressBar = new javax.swing.JProgressBar();
    mainPanel.setAutoscrolls(true);
    mainPanel.setName("mainPanel"); // NOI18N
    MainTab.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(vitalsignmonitor.VitalSignMonitorApp.class).getContext().getResourceMap(VitalSignMonitorView.class);
    MainTab.setToolTipText(resourceMap.getString("MainTab.toolTipText")); // NOI18N
    MainTab.setName("MainTab"); // NOI18N
    panelWelcome.setToolTipText(resourceMap.getString("panelWelcome.toolTipText")); // NOI18N
    panelWelcome.setEnabled(false);
    panelWelcome.setName("panelWelcome"); // NOI18N
    labelPatientChoice.setFont(resourceMap.getFont("labelPatientChoice.font")); // NOI18N
    labelPatientChoice.setText(resourceMap.getString("labelPatientChoice.text")); // NOI18N
    labelPatientChoice.setEnabled(false);
    labelPatientChoice.setName("labelPatientChoice"); // NOI18N
    jScrollPane1.setName("jScrollPane1"); // NOI18N
    tablePatientList.setAutoCreateRowSorter(true);
    tablePatientList.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {
    new String [] {
    "Patient_ID", "Surname", "Name"
    boolean[] canEdit = new boolean [] {
    false, false, false
    public boolean isCellEditable(int rowIndex, int columnIndex) {
    return canEdit [columnIndex];
    tablePatientList.setName("tablePatientList"); // NOI18N
    tablePatientList.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    tablePatientListMouseClicked(evt);
    jScrollPane1.setViewportView(tablePatientList);
    buttonSelectPatient.setText(resourceMap.getString("buttonSelectPatient.text")); // NOI18N
    buttonSelectPatient.setName("buttonSelectPatient"); // NOI18N
    buttonSelectPatient.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    buttonSelectPatientMouseClicked(evt);
    buttonCreatePatient.setText(resourceMap.getString("buttonCreatePatient.text")); // NOI18N
    buttonCreatePatient.setName("buttonCreatePatient"); // NOI18N
    buttonCreatePatient.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    buttonCreatePatientMouseClicked(evt);
    jSeparator5.setName("jSeparator5"); // NOI18N
    javax.swing.GroupLayout panelWelcomeLayout = new javax.swing.GroupLayout(panelWelcome);
    panelWelcome.setLayout(panelWelcomeLayout);
    panelWelcomeLayout.setHorizontalGroup(
    panelWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(panelWelcomeLayout.createSequentialGroup()
    .addGap(20, 20, 20)
    .addGroup(panelWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
    .addComponent(jSeparator5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelWelcomeLayout.createSequentialGroup()
    .addComponent(labelPatientChoice, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelWelcomeLayout.createSequentialGroup()
    .addComponent(buttonSelectPatient)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 53, Short.MAX_VALUE)
    .addComponent(buttonCreatePatient)))
    .addGap(514, 514, 514))
    panelWelcomeLayout.setVerticalGroup(
    panelWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(panelWelcomeLayout.createSequentialGroup()
    .addGap(19, 19, 19)
    .addGroup(panelWelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(buttonSelectPatient)
    .addComponent(buttonCreatePatient))
    .addGap(11, 11, 11)
    .addComponent(labelPatientChoice)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(13, 13, 13)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 539, Short.MAX_VALUE)
    .addGap(29, 29, 29))
    MainTab.addTab(resourceMap.getString("panelWelcome.TabConstraints.tabTitle"), panelWelcome); // NOI18N
    panelPatient.setFocusable(false);
    panelPatient.setName("panelPatient"); // NOI18N
    panelPatient.addComponentListener(new java.awt.event.ComponentAdapter() {
    public void componentShown(java.awt.event.ComponentEvent evt) {
    panelPatientComponentShown(evt);
    jSeparator1.setName("jSeparator1"); // NOI18N
    jSeparator2.setName("jSeparator2"); // NOI18N
    jSeparator3.setName("jSeparator3"); // NOI18N
    jSeparator4.setName("jSeparator4"); // NOI18N
    m_PanelPI.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("m_PanelPI.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("m_PanelPI.border.titleFont"))); // NOI18N
    m_PanelPI.setName("m_PanelPI"); // NOI18N
    mPI_LabelSex.setText(resourceMap.getString("mPI_LabelSex.text")); // NOI18N
    mPI_LabelSex.setName("mPI_LabelSex"); // NOI18N
    mPI_LabelName.setText(resourceMap.getString("mPI_LabelName.text")); // NOI18N
    mPI_LabelName.setName("mPI_LabelName"); // NOI18N
    mPI_Name.setBackground(resourceMap.getColor("mPI_Name.background")); // NOI18N
    mPI_Name.setText(resourceMap.getString("mPI_Name.text")); // NOI18N
    mPI_Name.setDisabledTextColor(resourceMap.getColor("mPI_Name.disabledTextColor")); // NOI18N
    mPI_Name.setName("mPI_Name"); // NOI18N
    mPI_LabelSurname.setText(resourceMap.getString("mPI_LabelSurname.text")); // NOI18N
    mPI_LabelSurname.setName("mPI_LabelSurname"); // NOI18N
    mPI_Surname.setText(resourceMap.getString("mPI_Surname.text")); // NOI18N
    mPI_Surname.setDisabledTextColor(resourceMap.getColor("mPI_Surname.disabledTextColor")); // NOI18N
    mPI_Surname.setName("mPI_Surname"); // NOI18N
    mPI_LabelBirthDate.setText(resourceMap.getString("mPI_LabelBirthDate.text")); // NOI18N
    mPI_LabelBirthDate.setName("mPI_LabelBirthDate"); // NOI18N
    mPI_BirthDateChooser.setBackground(resourceMap.getColor("mPI_BirthDateChooser.background")); // NOI18N
    mPI_BirthDateChooser.setName("mPI_BirthDateChooser"); // NOI18N
    mPI_SexComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Male", "Female" }));
    mPI_SexComboBox.setName("mPI_SexComboBox"); // NOI18N
    javax.swing.GroupLayout m_PanelPILayout = new javax.swing.GroupLayout(m_PanelPI);
    m_PanelPI.setLayout(m_PanelPILayout);
    m_PanelPILayout.setHorizontalGroup(
    m_PanelPILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(m_PanelPILayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(m_PanelPILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
    .addGroup(m_PanelPILayout.createSequentialGroup()
    .addComponent(mPI_LabelName, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(mPI_Name, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(m_PanelPILayout.createSequentialGroup()
    .addComponent(mPI_LabelSurname, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(mPI_Surname, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(m_PanelPILayout.createSequentialGroup()
    .addComponent(mPI_LabelBirthDate, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(mPI_BirthDateChooser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    .addGroup(m_PanelPILayout.createSequentialGroup()
    .addComponent(mPI_LabelSex, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(mPI_SexComboBox, 0, 159, Short.MAX_VALUE)))
    .addContainerGap(36, Short.MAX_VALUE))
    m_PanelPILayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {mPI_Name, mPI_Surname});
    m_PanelPILayout.setVerticalGroup(
    m_PanelPILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(m_PanelPILayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(m_PanelPILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(mPI_LabelName, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(mPI_Name, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(m_PanelPILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(mPI_LabelSurname, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(mPI_Surname, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(m_PanelPILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(mPI_LabelBirthDate, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(mPI_BirthDateChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(m_PanelPILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(mPI_LabelSex, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(mPI_SexComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    m_PanelAI.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("m_PanelAI.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("m_PanelAI.border.titleFont"))); // NOI18N
    m_PanelAI.setName("m_PanelAI"); // NOI18N
    mAI_LabelWeight.setText(resourceMap.getString("mAI_LabelWeight.text")); // NOI18N
    mAI_LabelWeight.setName("mAI_LabelWeight"); // NOI18N
    mAI_Height.setDisabledTextColor(resourceMap.getColor("mAI_Height.disabledTextColor")); // NOI18N
    mAI_Height.setName("mAI_Height"); // NOI18N
    mAI_LabelHeight.setText(resourceMap.getString("mAI_LabelHeight.text")); // NOI18N
    mAI_LabelHeight.setName("mAI_LabelHeight"); // NOI18N
    mAI_Weight.setDisabledTextColor(resourceMap.getColor("mAI_Weight.disabledTextColor")); // NOI18N
    mAI_Weight.setName("mAI_Weight"); // NOI18N
    javax.swing.GroupLayout m_PanelAILayout = new javax.swing.GroupLayout(m_PanelAI);
    m_PanelAI.setLayout(m_PanelAILayout);
    m_PanelAILayout.setHorizontalGroup(
    m_PanelAILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(m_PanelAILayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(m_PanelAILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(mAI_LabelHeight, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(mAI_LabelWeight, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(m_PanelAILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(mAI_Weight, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(mAI_Height, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(38, Short.MAX_VALUE))
    m_PanelAILayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {mAI_Height, mAI_Weight});
    m_PanelAILayout.setVerticalGroup(
    m_PanelAILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(m_PanelAILayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(m_PanelAILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(mAI_Weight, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(mAI_LabelWeight, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(m_PanelAILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(mAI_LabelHeight, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(mAI_Height, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    m_PanelSI.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("m_PanelSI.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("m_PanelSI.border.titleFont"))); // NOI18N
    m_PanelSI.setName("m_PanelSI"); // NOI18N
    mSI_CentreRegDate.setText(resourceMap.getString("mSI_CentreRegDate.text")); // NOI18N
    mSI_CentreRegDate.setName("mSI_CentreRegDate"); // NOI18N
    mSI_LabelSystemRegDate.setText(resourceMap.getString("mSI_LabelSystemRegDate.text")); // NOI18N
    mSI_LabelSystemRegDate.setName("mSI_LabelSystemRegDate"); // NOI18N
    mSI_CentreRegDateChooser.setBackground(resourceMap.getColor("mSI_CentreRegDateChooser.background")); // NOI18N
    mSI_CentreRegDateChooser.setName("mSI_CentreRegDateChooser"); // NOI18N
    mSI_SystemRegDateFormattedTextField.setBackground(resourceMap.getColor("mSI_SystemRegDateFormattedTextField.background")); // NOI18N
    mSI_SystemRegDateFormattedTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter()));
    mSI_SystemRegDateFormattedTextField.setText(resourceMap.getString("mSI_SystemRegDateFormattedTextField.text")); // NOI18N
    mSI_SystemRegDateFormattedTextField.setDisabledTextColor(resourceMap.getColor("mSI_SystemRegDateFormattedTextField.disabledTextColor")); // NOI18N
    mSI_SystemRegDateFormattedTextField.setEnabled(false);
    mSI_SystemRegDateFormattedTextField.setName("mSI_SystemRegDateFormattedTextField"); // NOI18N
    javax.swing.GroupLayout m_PanelSILayout = new javax.swing.GroupLayout(m_PanelSI);
    m_PanelSI.setLayout(m_PanelSILayout);
    m_PanelSILayout.setHorizontalGroup(
    m_PanelSILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(m_PanelSILayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(m_PanelSILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
    .addComponent(mSI_LabelSystemRegDate, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(mSI_CentreRegDate, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(m_PanelSILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
    .addComponent(mSI_CentreRegDateChooser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(mSI_SystemRegDateFormattedTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE))
    .addContainerGap(44, Short.MAX_VALUE))
    m_PanelSILayout.setVerticalGroup(
    m_PanelSILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(m_PanelSILayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(m_PanelSILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(mSI_LabelSystemRegDate, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(mSI_SystemRegDateFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(m_PanelSILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(mSI_CentreRegDate, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(mSI_CentreRegDateChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
    jButton1.setEnabled(false);
    jButton1.setName("jButton1"); // NOI18N
    jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    ButtonSavePatientDataMouseClicked(evt);
    mG_PatientId.setText(resourceMap.getString("mG_PatientId.text")); // NOI18N
    mG_PatientId.setDisabledTextColor(resourceMap.getColor("mG_PatientId.disabledTextColor")); // NOI18N
    mG_PatientId.setName("mG_PatientId"); // NOI18N
    mG_LabelPatientId.setText(resourceMap.getString("mG_LabelPatientId.text")); // NOI18N
    mG_LabelPatientId.setName("mG_LabelPatientId"); // NOI18N
    jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
    jButton2.setName("jButton2"); // NOI18N
    jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    ButtonModifyPatientDataMouseClicked(evt);
    javax.swing.GroupLayout panelPatientLayout = new javax.swing.GroupLayout(panelPatient);
    panelPatient.setLayout(panelPatientLayout);
    panelPatientLayout.setHorizontalGroup(
    panelPatientLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(panelPatientLayout.createSequentialGroup()
    .addGroup(panelPatientLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(panelPatientLayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(panelPatientLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    .addComponent(m_PanelSI, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(m_PanelAI, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(m_PanelPI, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    .addGap(515, 515, 515)
    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(5, 5, 5)
    .addComponent(jSeparator2, javax.swing.Group

Maybe you are looking for