Panel adding Components

Hi all,
I have a problem here with Java swing. I tried to create a JPanel and add all the components in to it like Label, JRadioButton,JCheckBox, etc., and finally adding them in to a container which gets the content pane and display it. The problem here is the panel is adding the Label properly but not the other JComponents. I have tested it by adding some more JComponents and non-JComponents and those with nonJs are added properly and displays only those components.
Model Code:
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
JPanel secPanel = new JPanel();
secPanel.setLayout(new BoxLayout(secPanel,BoxLayout.Y_AXIS));
Label lbl = new Label("Heading");
secPanel.add(lbl);
secPanel.add(new JCheckBox("Choice 1");
secPanel.add(new JRadioButton("choice 2");
cp.add(secPanel);Further, I have also tested by creating a new JApplet and same as above, I did the panel and added JComponents in to that and it seems to work fine there.
Completely, bizarre for me!!!
Can anybody shed their views you have here?
Thanks,
Shivaram.

Sure. I now removed all the nonJComponents and pasted down the code
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class TestSwingCheck02 extends JApplet implements ItemListener{
    String order;
    int numSections=0;
    String[] alpha = { "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V",
            "W","X","Y","Z"};
            int score = 0; //default value
            int ansSetID = 0;
            boolean validParams = true;
            Vector panelVector;
            Vector choiceVector;
            Vector labelVector;
            Vector boxGroupVector;
            Vector correctAnswers;
            Vector sectionScores;
            Vector ansSets;
            String itemSelected=""; //for debugging
            String errorMessage="";
            boolean shuffle;
            Container mainPanel;
            /** Initialization method that will be called after the applet is loaded
             *  into the browser.
            public void init() {
                try {
                    javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
                        public void run() {
                            createGUI();
                } catch (Exception e) {
                    System.err.println("createGUI didn't successfully complete");
            private void createGUI() {
                // TODO start asynchronous download of heavy resources
                panelVector = new Vector();
                choiceVector = new Vector();
                labelVector = new Vector();
                boxGroupVector = new Vector();
                correctAnswers = new Vector();
                sectionScores = new Vector();
                shuffle = false;
                mainPanel = getContentPane();
                order = this.getParameter("order_type");
                numSections = Integer.parseInt(this.getParameter("num_sections"));
                if(order.equalsIgnoreCase("C")){
                    mainPanel.setLayout(new FlowLayout());
                }else if(order.equalsIgnoreCase("R")){
                    mainPanel.setLayout(new FlowLayout());
                }else{
                    errorMessage = "Order type '"+order+"' is not recognised. Please specify either 'R' for rowwise layout or 'C' for columnwise layout.";
                if(!(order.equalsIgnoreCase("C") || order.equalsIgnoreCase("R"))){
                    validParams = false;
                    score = -99;
                if(validParams){
                    for(int i=0; i<numSections; i++){
                        Box secPanel = new Box(BoxLayout.Y_AXIS);
                        String sectionPart = "sec"+alpha;
String heading = this.getParameter(sectionPart+"_head");
String secType = this.getParameter(sectionPart+"_type");
int totalChoices = Integer.parseInt(this.getParameter(sectionPart+"_choicenum"));
String choiceList = this.getParameter(sectionPart+"_choices");
String correctAns = this.getParameter(sectionPart+"_correct");
String sShuffle = this.getParameter(sectionPart+"_shuffle");
String secScore = this.getParameter(sectionPart+"_score");
ansSets = new Vector();
boolean hasMultipleAnswers = false;
if(ansSets.size()==0){
if(this.getParameter("answer_set") != null){
ansSets.add(this.getParameter("answer_set"));
}else if(this.getParameter("answer_set1") != null){
for(int q=1;q<=100;q++){
if(this.getParameter("answer_set"+q) != null){
ansSets.add(this.getParameter("answer_set"+q));
}else{
break;
if(sShuffle != null){
shuffle = Boolean.parseBoolean(sShuffle);
if(correctAns != null){
correctAnswers.add(correctAns);
sectionScores.add(secScore);
String[] choices = null;
if(choiceList != null){
if(!choiceList.equals("")){
choices = this.splitChoiceList(choiceList);
if(choices.length != totalChoices){
errorMessage = "Choicenum value doesnot match with the total number of choices in "+sectionPart;
if(order.equalsIgnoreCase("C")){
}else if(order.equalsIgnoreCase("R")){
if(secType.equalsIgnoreCase("chk")){
hasMultipleAnswers = true;
}else if(secType.equalsIgnoreCase("rdo")){
Font fnt = new Font("Monospaced",Font.BOLD,14);
JLabel lbl = new JLabel(heading);
lbl.setFont(fnt);
labelVector.add(lbl);
secPanel.add((JLabel)labelVector.get(i));
secPanel.add(new JLabel("Check label"));
secPanel.add(new JRadioButton("Check1"));
Vector tempChoice = new Vector();
for(int j=0; j<choices.length; j++){
if(hasMultipleAnswers) {
tempChoice.add(new JCheckBox(choices[j]));
}else{
tempChoice.add(new JRadioButton(choices[j]));
secPanel.add(new JRadioButton("Check2"));
if(shuffle){
Vector afterShuffle = this.shuffleChoices(tempChoice);
for(int j=0; j<afterShuffle.size(); j++){
if(hasMultipleAnswers){
JCheckBox chkBox = (JCheckBox)afterShuffle.get(j);
chkBox.setVisible(true);
chkBox.setEnabled(true);
chkBox.addItemListener(this);
secPanel.add(chkBox);
}else{
JRadioButton rdoBtn = (JRadioButton)afterShuffle.get(j);
rdoBtn.setVisible(true);
rdoBtn.setEnabled(true);
rdoBtn.addItemListener(this);
secPanel.add(rdoBtn);
choiceVector.add(tempChoice);
}else{
for(int j=0; j<tempChoice.size();j++){
if(hasMultipleAnswers){
JCheckBox chkBox = (JCheckBox)tempChoice.get(j);
chkBox.setVisible(true);
chkBox.setEnabled(true);
chkBox.addItemListener(this);
secPanel.add(chkBox);
}else{
JRadioButton rdoBtn = (JRadioButton)tempChoice.get(j);
rdoBtn.setVisible(true);
rdoBtn.setEnabled(true);
rdoBtn.addItemListener(this);
secPanel.add(rdoBtn);
choiceVector.add(tempChoice);
//secPanel.setVisible(true);
secPanel.setBackground(Color.YELLOW);
mainPanel.add(secPanel, BorderLayout.NORTH);
mainPanel.setVisible(true);
public void itemStateChanged(ItemEvent ie){
public void paint(Graphics g){
Thanks,
Shivaram.

Similar Messages

  • How to decrease the height of the panel added at north using borderlayout m

    hi!
    i have problem decreasing the height of a panel that i have added in a frame at the north position uising the borderlayout manager
    thanx and regards
    Deepak Saini

    How much do you want to decrease the panel height?
    There are two limiting factors, namely the minimum computed size of its components and the layout-dependent computed size. Window resizing will 'clip' the panel, but its dimensions remain the same once this limit has been reached.
    With respect to the first factor, there are only a few things that can be done: change the font or image sizes of internal components, change the spacing between components, change the borders around and within the components (where applicable).
    With respect to the second factor, there is some flexibility, but it depends on what your app requires. The only way to reduce the height of a BorderLayout.NORTH panel is to force its size down by adding other panels BorderLayout.CENTER and/or BorderLayout.SOUTH in such a way that at least the CENTER panel expands out and causes the NORTH (and possibly SOUTH) panel(s) to compute to their smallest dimensions. Otherwise, the computation will expand the NORTH panel as far as it can or divide between the two or three equally (for example, if each panel only contains buttons with text). Nonetheless, by default, the CENTER panel occupies the largest region, pushing the others to the borders as tightly as possible. Do you have a CENTER panel added?
    Robert Templeton

  • Can't import datePicker/dateDisplayer components into "Added Components"

    I downloaded the source code and the components lib and follow exactly the steps that mentioned in the documentation but i'm still not able to import the datePicker components lib,and when i click import componets the JSC prompt for the runtime jar file,and i dunno where to get that jar file.
    anyone please explain what i need to do???????

    Hi,
    I could add the datepicker complib. Here is what i did
    -- Go to palette -> standard
    --right  below added components ,choose import  component library
    --Select the complib file,click OK
    -- you can see Date Picker and Date displayer are added
    Hope this helps
    MJ

  • Prevent adding components

    Hi All,
    How to prevent adding components while goods issue in a maintenance order.
    Thanks in advance
    Surya

    Hi Gurus
    Still trying to explore on it.
    What is the consequence if I uncheck the box UNPLANNED GOODS ISSUE in the IMG activity for Define Documentation for Goods movements for the Order?
    Path: SPRO>PMCS>Maintenance and Service processing>Maintenance and Service Orders>Functions and settings for Order types>Goods movements for order>Define Documentation for Goods movements for the orders.
    Thanks in advance
    Surya

  • Dynamicaly adding components to panel/grid

    I am trying to add components dynamically in panelgrid but it is displaying nothing.in jsp tag is
    <h:panelGrid id = "ExpenseDetail" binding = "#{expenses.component}" />
    tand his is what i am doing in backing bean.
    public HtmlPanelGrid getComponent()
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Application application = facesContext.getApplication();
    component = new HtmlPanelGrid();
    component.getChildren().clear();
    component.setBorder(1);
    component.setColumns(1);
    component.setStyleClass("browsetabletype2");
    component.setWidth("90%");
    UIOutput outText = (UIOutput)application.createComponent("javax.faces.HtmlOutputText");
              outText.setValue("Name");
              outText.setId("Name");
              component.getChildren().add(outText);
    return component;
    }

    What about setter of your binded component ?
    Try this
            private HtmlPanelGrid dynamicPanel = null;
         public HtmlPanelGrid getDynamicPanel {
              if (this.dynamicPanel == null) {
                   // this will happen the first time the HtmlPanelGrid is retrieved
                   this.dynamicPanel = new HtmlPanelGrid();
              try {
                   generatePanel(this.dynamicPanel);
              } catch (Exception e) {
                   e.printStackTrace();
              return dynamicPanel;
         public void setDynamicPanel(HtmlPanelGrid dynamicPanel) {
              try {
                   generatePanel(dynamicPanel);
              } catch (Exception e) {
                   e.printStackTrace();
              this.dynamicPanel = dynamicPanel;
           private void generatePanel(HtmlPanelGrid dynamicPanel){
                    dynamicPanel.getChildren().clear();
              dynamicPanel.setId("dynamicPanel_1");
                    //adding other attributes and children ...
            } I always use this method, and it works. Maybe there is more sophisticated way, but I didn't managed to find it. Hope it helps.
    Martin

  • Adding Components to a JPanel not working correctly

    I'm trying to build a JFrame that contains a parent JPanel that will hold a JPanel used to display a message view, a vertical strut and a JPanel that holds VCR-like buttons to cycle through the messages.
    My parent JPanel uses a BorderLayout and the Border is a TitledBorder which tells which product you are viewing (i.e., Message 1 of 5). I build the message JPanel, vertical strut and button JPanel and add them all in order to the parent JPanel which then gets added to the rootContentPane of the JFrame. All that appears is the parent JPanel's TitledBorder, the strut and the button JPanel. Using JSwat, I've been able to determine that the message JPanel has 0 for both its height and width after adding the message components to the JPanel.
    I create the message JPanel with a BorderLayout and an OvalBorder as copied from Manning Press's Swing book (which works fine in other JFrames that I have built), then add other components as necessary to the individual messages (mostly items around the edges with a central display for the actual message). What I can't figure out is why the height and width of the message JPanel isn't growing as I add components.
    I had previously used the same code to display a single message (minus the parent JPanel, strut and button JPanel) where I added the border panels (northPanel, eastPanel, southPanel and westPanel) created in createMsgPanel() directly to the contentPane and it worked perfectly, so I know that the code that adds the message works fine. Then, the requirements changed (go figure) and I had to display multiple messages from the same screen.
    Here's what I've got:
    public class Layout
                 extends JFrame
                 implements ActionListener
       private MissionData missionData;
       private JPanel messagePanel = null;
       private int index = 0;
       private int numMsgs = 0;
       private JPanel mainPanel = null;
       private JPanel buttonPanel = null;
       private TitledBorder titledBorder = null;
       Layout ()
       public Layout (MissionData msn)
          super ();
          missionData = msn;
          setSize (640, 640);
          setIconImage (new ImageIcon ("Icon.jpg").getImage());
          setTitle (((Message) (missionData.messages.elementAt(0))).name);
          numMsgs = missionData.messages.size();
          titledBorder = new TitledBorder (
                            new LineBorder (Color.BLACK),
                            "Message " + String.valueOf (index + 1) +
                            " of " + String.valueOf (numMsgs),
                            TitledBorder.LEFT,
                            TitledBorder.TOP);
          mainPanel = new JPanel ();
          mainPanel.setLayout (new BorderLayout());
          mainPanel.setBorder (new CompoundBorder (titledBorder,
                                                   new EmptyBorder (
                                                      new Insets (3, 3, 3, 3))));
          messagePanel = new JPanel();
          messagePanel.setLayout (new BorderLayout ());
          messagePanel.setBorder (new CompoundBorder (
                                     new EmptyBorder (50, 50, 50, 50),
                                     new OvalBorder (20, 20, Color.white)));
          messagePanel.setBackground (Color.black);
          createButtonPanel ();
          createMsgPanel ((Message) missionData.messages.elementAt (0));
          mainPanel.add (messagePanel);
          mainPanel.add (Box.createVerticalStrut (20));
          mainPanel.add (buttonPanel);
          Container mainContentPane = getContentPane();
          mainContentPane.add (mainPanel);
       private void createMsgPanel (Message msg)
          MessageType msgType = null;
          if (msg.getFunctionalAreaDesignator(0) == Message.GENERAL_INFO)
             if (msg.getMessageNumber(0) == 1)
                msgType = FREE_TEXT;
          else if (msg.getFunctionalAreaDesignator(0) == Message.SUPPORT)
             if (msg.getMessageNumber(0) == 33)
                msgType = CAS;
             else if (msg.getMessageNumber(0) == 34)
                msgType = OSR;
          // Setup NORTH Panel of Display
          JPanel northPanel = new JPanel (new GridLayout (2, 6));
          northPanel.setBackground (Color.black);
          northPanel.add (new JTIMLabel ("", false));
          northPanel.add (new JTIMLabel ("<html>RECV</html>", false));
          if (msgType == CAS)
             northPanel.add (new JTIMLabel ("<html>PCLR</html>", false));
             northPanel.add (new JTIMLabel ("<html>MSN</html>", false));
             northPanel.add (new JTIMLabel ("<html>SAVE</html>", false));
          else if (msgType == OSR)
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
          else if (msgType == FREE_TEXT)
             northPanel.add (new JTIMLabel ("<html>ERASE</html>", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("<html>BRDCST</html>", false));
          northPanel.add (new JTIMLabel ("<html>SEND</html>", false));
          northPanel.add (new JTIMLabel ("", false));
          northPanel.add (new JTIMLabel ("", false));
          if (msgType == CAS)
             northPanel.add (new JTIMLabel ("<html>CAS</html>", false));
          else if (msgType == OSR)
             northPanel.add (new JTIMLabel ("<html>OSR</html>", false));
          else if (msgType == FREE_TEXT)
             northPanel.add (new JTIMLabel ("<html>FTXT</html>", false));
          if (msgType == FREE_TEXT)
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
          else
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("<html>CAS</html>", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
          messagePanel.add (northPanel, BorderLayout.NORTH);
          // Setup EAST Box of Display
          Box eastBox = new Box (BoxLayout.Y_AXIS);
          if (msgType == CAS)
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("<html>F<br>T<br>X<br>T</html>", false));
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("<html>O<br>S<br>R</html>", false));
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("<html>D<br>P<br>I<br>P</html>", false));
             eastBox.add (Box.createGlue());
          else if (msgType == FREE_TEXT)
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("", false));
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("", false));
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("", false));
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("", false));
             eastBox.add (Box.createGlue());
          eastBox.add (new JTIMLabel ("<html>W<br>L<br>C<br>O</html>", false));
          eastBox.add (Box.createGlue());
          eastBox.add (new JTIMLabel ("<html>C<br>N<br>T<br>C<br>O</html>",
                                        false));
          eastBox.add (Box.createGlue());
          messagePanel.add (eastBox, BorderLayout.EAST);
          // Setup SOUTH Panel of Display
          JPanel southPanel = new JPanel (new GridLayout (2, 5));
          southPanel.setBackground (Color.black);
          southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("<html>ON</html>", false));
          southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("", false));
          if (msgType == CAS)
             southPanel.add (new JTIMLabel ("<html>USE</html>", false));
             southPanel.add (new JTIMLabel ("<html>RCALL</html>", false));
          else if ((msgType == OSR) || (msgType == FREE_TEXT))
             southPanel.add (new JTIMLabel ("", false));
             southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("<html>MENU</html>", false));
          southPanel.add (new JTIMLabel ("<html>VMF</html>", false));
          if (msgType == CAS)
             southPanel.add (new JTIMLabel ("<html>NETS</html>", false));
          else if ((msgType == OSR) || (msgType == FREE_TEXT))
             southPanel.add (new JTIMLabel ("<html>CAS</html>", false));
          southPanel.add (new JTIMLabel ("", false));
          messagePanel.add (southPanel, BorderLayout.SOUTH);
          // Setup WEST Box of Display
          JTIMLabel incrLabel = null;
          JTIMLabel decrLabel = null;
          Box westBox = new Box (BoxLayout.Y_AXIS);
          if (msgType == FREE_TEXT)
             westBox.add (Box.createGlue());
             westBox.add (new JTIMLabel ("", false));
             westBox.add (Box.createGlue());
             westBox.add (new JTIMLabel ("", false));
             westBox.add (Box.createGlue());
             westBox.add (new JTIMLabel ("", false));
             westBox.add (Box.createGlue());
             westBox.add (new JTIMLabel ("<html>N<br>E<br>X<br>T</html>", false));
             westBox.add (Box.createGlue());
             westBox.add (new JTIMLabel ("<html>P<br>R<br>E<br>V</html>", false));
          else
             westBox.add (Box.createGlue());
             westBox.add (new JTIMLabel ("<html>U<br>F<br>C</html>", false));
             westBox.add (Box.createGlue());
             if (msgType == CAS)
                westBox.add (new JTIMLabel ("<html>/\\</html>", false));
                westBox.add (Box.createGlue());
                westBox.add (new JTIMLabel ("<html>\\/</html>", false));
                westBox.add (Box.createGlue());
                incrLabel = new JTIMLabel ("<html>I<br>N<br>C<br>R</html>", false);
                westBox.add (incrLabel);
                westBox.add (Box.createGlue());
                decrLabel = new JTIMLabel ("<html>D<br>E<br>C<br>R</html>", false);
                westBox.add (decrLabel);
                westBox.add (Box.createGlue());
          messagePanel.add (westBox, BorderLayout.WEST);
          // Create CENTER Box to display message bodies
          GriddedPanel centerBox = new GriddedPanel ();
          centerBox.setBackground (Color.black);
          messagePanel.add (centerBox, BorderLayout.CENTER);
          if (msgType == CAS)
             new CASDisplay (msg, centerBox, incrLabel, decrLabel);
          else if (msgType == OSR)
             new OSRDisplay (msg, centerBox);
          else if (msgType == FREE_TEXT)
             new FreeTextDisplay (msg, centerBox);
       private void createButtonPanel ()
          // build the button panel
          buttonPanel = new JPanel ();
          buttonPanel.setLayout (new BoxLayout (buttonPanel, BoxLayout.X_AXIS));
          buttonPanel.setBorder (new LineBorder (Color.BLACK));
          // Create and add the buttons
          buttonPanel.add (createButton ("FIRST_BUTTON"));
          buttonPanel.add (createButton ("PREV_BUTTON"));
          buttonPanel.add (createButton ("NEXT_BUTTON"));
          buttonPanel.add (createButton ("LAST_BUTTON"));
       private JButton createButton (String buttonName)
          JButton button = new JButton ();
          button.addActionListener (this);
          button.setActionCommand (buttonName);
          Image image = null;
          String tooltip = "Press to go to the ";
          if (buttonName.equals ("FIRST_BUTTON"))
             image = new ImageIcon ("firstArrowIcon.gif").getImage();
             tooltip += "First";
          else if (buttonName.equals ("PREV_BUTTON"))
             image = new ImageIcon ("previousArrowIcon.gif").getImage();
             tooltip += "Previous";
          else if (buttonName.equals ("NEXT_BUTTON"))
             image = new ImageIcon ("nextArrowIcon.gif").getImage();
             tooltip += "Next";
          else if (buttonName.equals ("LAST_BUTTON"))
             image = new ImageIcon ("lastArrowIcon.gif").getImage();
             tooltip += "Last";
          tooltip += " message in the lst";
          button.setToolTipText (tooltip);
          button.setIcon (new ImageIcon (image.getScaledInstance (36, 36, Image.SCALE_FAST)));
          return button;
       public void actionPerformed (ActionEvent e)
          if (e.getActionCommand ().equals ("FIRST_BUTTON"))
             index = 0;
          else if (e.getActionCommand ().equals ("PREV_BUTTON"))
             if (index > 0)
                index--;
          else if (e.getActionCommand ().equals ("NEXT_BUTTON"))
             if (index < numMsgs - 1)
                index++;
          else if (e.getActionCommand ().equals ("LAST_BUTTON"))
             index = numMsgs - 1;
          titledBorder.setTitle ("Message " + String.valueOf (index + 1) +
                                 " of " + String.valueOf (numMsgs));
          createMsgPanel ((Message) missionData.messages.elementAt (index));
       private static class MessageType
                            extends EnumeratedType
                            implements Serializable
          final static long serialVersionUID = 1;
          protected MessageType (int value, String desc)
             super (value, desc);
       private static MessageType FREE_TEXT =
          new MessageType (0, "Free Text");
       private static MessageType CAS =
          new MessageType (1, "Call Accounting System");
       private static MessageType OSR =
          new MessageType (2, "Occupational Survey Report");
    }

    That's all well and good, but I've had more times that not where
    people want the entire program, not bits and pieces.Then you missed the whole point of that link.
    We don't want to see bits and pieces of code. We want to see an executable program, but we want an executable program the demonstrates the incorrect behaviour without all the unnecessary code. 90% of the code you posted was not related to your problem. That is we what you do to some basic debugging and remove the parts of code that are not related to the problem so we can concentrate on the code that is related to the problem.

  • Re-Rendering the entire panel with components based on list value selection

    Hi,
    I am new to swing.Wondering how to refresh the panel with modified data on selection from list.
    Here's the code I am trying .
    the function below is called withdifferent set of value s being passed in based on add,remove conditions.
    public void initGroupPanelComponents(Vector GroupListData,Object[] sourceItemsArray,Object[] sinkItemsArray)
    groupsPanel = new JPanel();
    groupsPanel.setLayout(null);
    botPanel = new JPanel(new BorderLayout());
    botPanel.setSize(500,600);
    if(sourceItemsArray.length!=0){
    sourceLabel = "New Members:";
    sinkLabel = "New Available";
    System.out.print("color change now!");
    groupsPanel.setBackground(Color.YELLOW);
    botPanel.setBackground(Color.GRAY);
    //revalidate();
    else{
    groupsPanel.setBackground(Color.BLUE);
    botPanel.setBackground(Color.WHITE);
    groupsPanel.setSize( 500, 300 );
    groupsList = new JList(groupNameListData);
    groupsList.setBorder(BorderFactory.createLineBorder(Color.gray));
    groupsList.setBounds(10,10,350,230);
    groupsPanel.add(groupsList);
    groupsList.addListSelectionListener(new groupNameListAction());
    groupsList.setListData(groupNameListData);
    addButton = new JButton("Add");
    addButton.setBounds(385,35,80, 20);
    addButton.addActionListener(new addNewGroupAction());
    removeButton = new JButton("Remove");
    removeButton.setBounds(385, 70, 80, 20);
    groupsPanel.add(addButton);
    groupsPanel.add(removeButton);
    duellist= new DualListPanel(sourceItemsArray, sinkItemsArray, sourceLabel,sinkLabel);
    botPanel.add(duellist);
    botPanel.setBounds(0, 270, 500,600);
    botPanel.setOpaque(true);
    getContentPane().add(groupsPanel);
    groupsPanel.add(botPanel,BorderLayout.SOUTH);
    getContentPane().invalidate();
    getContentPane().validate();
    setResizable(false);
    setVisible(true);
    Relevant suggestions are most welcome.
    Thanks in Advance!

    Thanks much our help.
    But,apperars to me that I have added the groupsList to the panel in the method.
    What I am trying to acheive here is, when a value is selected from the groupsList, accrodingly,in the ListActionListener, Iam trying to repaint the whole Panel with the list component above and duellist panel (a panel with 2 list components by side and buttons at the centre)obtained from dualListPanel Class .
    Appears to work fine the first time when DualListPanel is nstantiated with certain data passed in.But when a particular list value on top is selected, i would require this dualListPanel to be instantiated with a new set of data passed in.This,for some reasons fails to come up.
    Would Appreciate if you could suggest accordingly for this.
    Thanks much again!

  • IDOC for Creation of Production order and also adding components

    Hi ,
    I have a requirement like I get the data from a 3rd party system and using that i have to create production orders and also should be able to add more materials in COMPONENTS part of that Production order. I was looking for a BAPI which can handle this process.
    And also can any one help me by letting me know is there any Message type available for handling this process of Production order creation and Adding extyra components to it.
    I have a  message type LOIPRO (for Production Order) and associated function modle CLOI_MASTERIDOC_CREATE_LOIPRO for creation of master IDoc, but not sure can i handle the Components part in this.
    Please do send replies ASAP, its very urgent.
    Or else atleast suggest me the other ways of doing this .
    Also send me any BDC program if anyone has already developed for this.
    Thanks
    Kumar
    Edited by: Phani Kumar Peddagopu on Mar 19, 2008 6:56 PM

    Resolved .

  • Sales order cancelled and new sales order with added components

    Hi all,
    There is a MTO scenario.Lets say a product X was to be made .Now when the production was complete,the sales order got cancelled and a new sales order was generated for same product with 2 new components to be added,lets say A and B.
    So now i have to use the finished good x and new components A and B for the new sales order.How will the costing of new product be done and how do i maintain the BOM?

    Dear,
    You have to create the new material code for your new product as it is having two new components. For that new product say Y you need to add the X, A and B.
    As you have already manufactured the X so system will not create any procurement proposal for it and you can consume the X while manufacturing the Y and it cost also get capture to the Y. This is standard Practice.
    Hope clear to you.
    Regards,
    R.Brahmankar

  • JPanel won't display in BoxLayout when adding components in different order

    For some reason when I run this code, the topPanel (made up of two panels which are all JLabels, JButtons, and JTextFields) does not display on the screen, but the investmentPanel (JTable within a JScrollPane) does. But when I add them in the reverse order, they both show up, but not in the order I want them to. The JPanel I am adding to is maximized so that shouldn't be an issue. Any thoughts of why this is happening?
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS));
    topPanel.add(companyInfoPanel);
    topPanel.add(tradePanel);
    add(topPanel);
    add(investmentPanel);

    Your best bet here is to show us your code. We don't want to see all of it, but rather you should condense your code into the smallest bit that still compiles, has no extra code that's not relevant to your problem, but still demonstrates your problem, in other words, an SSCCE (Short, Self Contained, Correct (Compilable), Example). For more info on SSCCEs please look here:
    http://homepage1.nifty.com/algafield/sscce.html

  • Control panel added to start page

    On Windows 8.1 and Server 2012R2 I can add a link to the control panel and the command prompt to the start page.
    couldn't see that I was able to do that in Windows 10 tech preview

    On Windows 8.1 and Server 2012R2 I can add a link to the control panel and the command prompt to the start page.
    couldn't see that I was able to do that in Windows 10 tech preview
    You do not say which Win 10 TP build you are now using.
    If you are using one of the latest, i.e. 10041 or 10049, you might not need a link to Control Panel or Command Prompts in Start Menu screen.
    Right click at Start button > the popup box gives you a list which, among others, includes Control Panel link and 2 Command Prompt links.
    Adding.....
    Slightly off topic: when you login to your account, it opens to the desktop. Right ?
    So, wouldn't it be more convenient to create shortcuts to desktop ?

  • No provision to provide Tool tip for Default Panel Collection Components

    "View" is a default menu item provided by Panel Collection Component. The "shortDesc" property can set the tool tip for entire panel collection.
    How to set the tool tip specifically for the default components given by panel collection component ?

    Hi,
    panel collection labels and tool tips can be changed through skinning See http://docs.oracle.com/cd/E21764_01/apirefs.1111/e15862/toc.htm and search for af:panelCollection and go to the Resource String section. So far the good news. The bad news is that there is no skin selector to change the tool tip of the "View" menu option (though yo can change the label through af_panelCollection.LABEL_MENU_VIEW). If you need this, please file an enhancement request through customer support.
    Frank
    Ps.: Skinning is documented here: http://docs.oracle.com/cd/E21764_01/web.1111/b31973/af_skin.htm#BAJFEFCJ

  • Adding components using GridBagLayout?

    I am adding different components to a JPanel using GridBagLayout as my layout manager. After the JPanel is displayed I need to add additional components to the JPanel. After the components are added I call validate() to update the JPanel. However, after the new components are added, it seems like it changes the constraints in the previous components because they are not displayed correctly. I was wondering why this occurs after I call validate().
    Thanks,
    Michael

    Remember GBL uses components to calculate column widths/heights, etc. So if you are added wider or taller components after the container is shown and re validating the GBL will take new components into account and you'll see some changes.
    This is just a swag but you might try adding the components and calling setVisible to show or hide them -- no guarantees, but it might be worth a try.
    Cheers
    DB

  • JLayeredPane and added Components

    Hi everybody,
    I have a panel for drawing, what is actually a JLayeredPane. With the add(someComponent, int layer) I am adding severals JPanel, on which I draw Rectangles for example.
    Now I need to change the layer of a certain JPanel in the layeredPane. This is no Problem (with setLayer(...)). But I have one JPanel, its bound by a Rectangle and I added with the add-Method a own Object (it's a line). The line has to be an object, because I added a MouseListener to that line.
    It appears like that:
    |    (1)    |
    |           |
    |           |
    |-----------|
    |           |
    |____________It's the line in the middle I'm talking about. So when I change the Layer of the JPanel (the Rectangle), the line has the correct bounds, but is displayed in the upper middle position in the Panel (no. (1) in the graphic).
    I tried to remove and re-add it, but nothing helps. Does anybody know the problem?
    Thanx for helping!!
    Robert4

    By default JLayeredPane uses null layout manager. So you have to set the bound of the component being added into JLayeredPane.

  • Multithreaded Pacman: only last animated panel added to JFrame is displaye

    Hello,
    I am making a multithreaded pacman game. Pacman and each of the ghosts run in a separate thread.
    However, only the last item (ie. pacman or one of the ghosts) added to the JFrame is displaying in the maze. (pacman and each of the ghosts are subclasses of JPanel). For example, if I do:
    add(pacman);
    add(orangeGhost);
    add(redGhost);
    only the red ghost animation will appear on the maze(which is also a subclass of JPanel).
    I have tried adding the ghosts to pacman and then adding pacman i.e. pacman.add(redGhost); add(pacman); but this still doesn't work - only pacman is showing in the maze.
    Each thread runs fine on its own, but only the last one added is displaying.
    Any help is much appreciated.

    Hi,
    JFrame uses the BoderLayout layout manager, and when you add a JPanel after the other inside your JFrame they will get put one on top of other. None of the layout manager let you overlap components with transparency as far as I know. Also your JPanels are not transparent but opaque.
    I think what you need is to "paint" your game on a JPanel o canvas, take a look at this tutorial:
    http://javaboutique.internet.com/tutorials/Java_Game_Programming/
    Keep asking around, people with more experience can help you on this forum.
    Regards,

Maybe you are looking for

  • Contrast issue (?)

    Hi, I started up my PowerBook today to find the contrast slightly increased somhow, evident in the windows and drop menus. The lists in iTunes are pronounced by alternate grey and white lines. Some fields on certain websites have appeared in a light

  • How to display a StyledDocument? (not in JTextComponent)

    I have read the following tutorials and relevant API's from the Swing Connection: Text overview: http://java.sun.com/products/jfc/tsc/articles/text/overview/index.html Text attributes: http://java.sun.com/products/jfc/tsc/articles/text/attributes/ind

  • Wlc can't communicate with dhcpserver

    Our wlc can't communicate with any host on vlan Z (subnet 192.168.1.0/24). The wlc itself is in a different vlan. All communication to other vlans works just fine. I've temporarly disabled the access-lists for vlan Z, without success. A host in the s

  • My MacBookPro is becoming very slow, help?

    My MacBook Pro has become alot slower recently, it freezes now and again and i'm not sure what to do because i haven't done anything different or installed anything new.

  • Mac wireless keyboard and mouse question

    I have a Mac wireless keyboard and mouse.  Can they be used with any computer other than an Apple product?