Adding a jPanel to another jPanel help

I have a class NavigationButtonsClass which has the navigationalPanel which in turn has buttons back, next ... etc.
public JPanel navigationalPanel = new JPanel();
I have another class ProjectClass in which I gave the following
NavigationButtonsClass newNavigationButtonsClass = new NavigationButtonsClass();
jPanel1.add(newNavigationButtonsClass.navigationalPanel, new XYConstraints(0, 0, 795, -1));
this.getContentPane().add(jPanel1, new XYConstraints(1, 420, 798, 45));
Is something wrong here. I am not able to see the navigationalPanel.
Thanks.

Modify ur NavigationButtonsClass like,
public class NavigationButtonsClass extends JPanel
   add(backButton);
   add(cancelButton);
}Now in ur ProjectClass
this.getContentPane().add(new  NavigationButtonsClass(),BorderLayout.SOUTH);I have assumed ur Project class extends JFrame...

Similar Messages

  • Set Location of JPanel in another JPanel

    Hello, i want to set the location of a JPanel in another JPanel.
    This is my code:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package nemo;
    * @author Administrator
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    public class BackgroundImage extends JFrame
         JScrollPane scrollPane;
         ImageIcon icon;
            ImageIcon iconDrinken;
         Image image;
         public BackgroundImage() {
              icon = new ImageIcon("startpage.JPG");
                    iconDrinken = new ImageIcon("drankje.JPG");
              JPanel panel = new JPanel() {
                   protected void paintComponent(Graphics g) {
                        //  Dispaly image at at full size
                        g.drawImage(icon.getImage(), 0, 0, null);
                        super.paintComponent(g);
                    JPanel panelDrinks = new JPanel() {
                        protected void paintComponent(Graphics g) {
                            g.drawImage(iconDrinken.getImage(), 0, 0, null);
                            super.paintComponent(g);
                    panelDrinks.setOpaque( false );
              panelDrinks.setPreferredSize( new Dimension(200, 215) );
              panel.setOpaque( false );
              panel.setPreferredSize( new Dimension(400, 400) );
              scrollPane = new JScrollPane( panel );
              getContentPane().add( scrollPane );
                    panel.add(panelDrinks);
         public static void main(String [] args)
              BackgroundImage frame = new BackgroundImage();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(800, 600);
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }When i execute this i get this:
    [http://img208.imageshack.us/img208/738/nowml5.jpg]
    And i want the image in the first white box from the left.
    But how to do it???
    I've tried .setLocation and .setBounds
    Edited by: Sven.nl on Apr 17, 2008 2:42 AM
    Edited by: Sven.nl on Apr 17, 2008 2:43 AM

    I already found it. Thanks anyway.
                    JPanel panelDrinks = new JPanel() {
                        protected void paintComponent(Graphics g) {
                            g.drawImage(iconDrinken.getImage(), 100, 200, 200, 215, null);
                            super.paintComponent(g);
                    panelDrinks.setOpaque( false );
              panelDrinks.setPreferredSize( new Dimension(800, 600) );
                    panelDrinks.setLocation(300, 300);
                      Edited by: Sven.nl on Apr 17, 2008 3:05 AM

  • How can i use an inner Jpanel in another JPanel

    Hi, i need to put an inner panel in a container panel.I have been trying for hours but I couldn't make it work. Please waiting for help...
    public class Gui extends JFrame{
         public Gui() {
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              setEnabled(true);
              setSize(500, 500);
              JPanel mainPanel=new JPanel();
              int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
              int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
              JScrollPane jsp=new JScrollPane(mainPanel,v,h);
              this.add(mainPanel);
              setContentPane(jsp);
                    //this part doesn't works
              JPanel innerPanel=new JPanel();
              innerPanel.setSize(50, 50);
              innerPanel.setLocation(100, 100);
              innerPanel.setBorder(BorderFactory.createLineBorder(Color.black));
              innerPanel.setBackground(Color.red);
                   //this part doesn't works
         public static void main(String[] args) {
              Gui gui= new Gui();
              gui.setVisible(true);
    }

    I'm sorry it's my bad that i have forgotten to add the innerPanel to mainPannel (But of course i tried it in the original code :) ). Now i made the changes you suggested but there are still problems.
    I can see the innerPanel now, but the size and the position of the innerPanel doesn't works.
    public Gui() {
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              setEnabled(true);
              setSize(500, 500);
              JPanel mainPanel=new JPanel();
              int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
              int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
              JScrollPane jsp=new JScrollPane(mainPanel,v,h);
              getContentPane().add(jsp);
              JPanel innerPanel=new JPanel();
              innerPanel.setSize(500, 500);
              innerPanel.setLocation(400, 400);
              innerPanel.setBorder(BorderFactory.createLineBorder(Color.black));
              innerPanel.setBackground(Color.red);
                    mainPanel.add(innerPanel);
                    //also i tried
                    //getContentPane().add(innerPanel);
                    //or
                    //jsp.add(innerPanel);        
    ...

  • How to resize a JPanel within another JPanel

    I have a JApplet that contains contains a JPanel which has several other components on the JPanel.
    The JApplet is an image query front-end which can be used to find images based on a single geographic point, a geographic rectangle or a geographic point and a radius (in meters). I have a JComboBox that the user uses to select which type of query they would like to perform. To enter the query information, I have a separate JPanel that contains the query parameters.
    For the single geographic point, it is just a simple row with JLabels and JTextFields for the latitude and longitude.
    For the rectangle, it is essentially a 3x3 grid to handle the JLabels and JTextFileds for the latitude and longitude of the upper left and lower right corners.
    For the geographic point and radius, I reuse the JPanel for the single geographic point and add a new row for the radius.
    In my ChangeListener for the JComboBox, I first call parentPanel.remove (queryPanel) then call a method to create the specific queryPanel and call parentPanel.add (queryPanel). The only thing that happens when I change the JComboBox to a different query type is the portion of the queryPanel that was covered by the selection of the JComboBox never gets repainted and doesn't change to the new queryPanel.
    I wish I could provide code examples, but the computer that I am developing on is not on the Internet and it is extremely difficult to get anything off of it to put out on the Internet.
    Hopefully, someone can help me figure out what is going on and why my parentPanel is not updating to reflect the new queryPanel.

    GoDonkeys wrote:
    Sorry, but what is the EDT?Please start here: [Concurrency in Swing|http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html]

  • How can I change size rect in JPanel from another JPanel?

    I have code:
    import java.awt.*;
    import javax.swing.*;
    public class ProgramD {
    public static void main(String[] arg) {
    JFrame f=new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(840,440);
    f.setLayout(null);
    PanelLeft p1=new PanelLeft();
    p1.setSize(400,400);
    p1.setLocation(0,0);
    f.add(p1);
    PanelRight p2=new PanelRight();
    p2.setSize(400,400);
    p2.setLocation(400,0);
    f.add(p2);
    f.setVisible(true);
    class PanelLeft extends JPanel {
    Shape shape1;
    PanelLeft() {
    shape1=new Rectangle(30,30,100,50);
    public void paintComponent(Graphics g) {
    Graphics2D g2=(Graphics2D) g;
    g2.setColor(Color.red);
    g2.fill(shape1);
    class PanelRight extends JPanel {
    PanelRight() {
    setBackground(Color.green);
    JTextField field1=new JTextField(4);
    JTextField field2=new JTextField(4);
    JButton b=new JButton("resize");
    add(field1);
    add(field2);
    add(b);
    }I would like to wrote width and height size of rect and click resize button, rect must change its size. I may add ActionListener, but I don't know what I may get size from PanelLeft and set size to PanelLeft. How may I solve this problem?

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ProgramDada{
      public static void main(String[] arg) {
        JFrame f=new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container con = f.getContentPane();
        con.setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        PanelLeft p1 = new PanelLeft();
        p1.setPreferredSize(new Dimension(400, 400));
        gbc.gridx = 0;
        gbc.gridy = 0;
        con.add(p1, gbc);
        PanelRight p2 = new PanelRight(p1);
        p2.setPreferredSize(new Dimension(400,400));
        gbc.gridx = 1;
        con.add(p2, gbc);
        f.pack();
        f.setVisible(true);
    class PanelLeft extends JPanel {
      int x, y, w, h;
      Shape shape1;
      PanelLeft() {
        x = 30;
        y = 30;
        w = 100;
        h = 50;
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2=(Graphics2D) g;
        shape1 = new Rectangle(x, y, w, h);
        g2.setColor(Color.red);
        g2.fill(shape1);
    class PanelRight extends JPanel implements ActionListener{
      PanelLeft pt;
      JTextField field1, field2;
      JButton b;
      PanelRight(PanelLeft p) {
        pt = p;
        setBackground(Color.green);
        field1 = new JTextField(4);
        field2 = new JTextField(4);
        b = new JButton("resize");
        add(field1);
        add(field2);
        add(b);
        b.addActionListener(this);
      public void actionPerformed(ActionEvent e){
        pt.w = Integer.parseInt(field1.getText());
        pt.h = Integer.parseInt(field2.getText());
        pt.repaint();
    }

  • How to place a JPanel at the center of another JPanel?

    Can anyone tell me how to place a JPanel inside another JPanel? The first JPanel consists of three JPanels each consisting of a label&textfield and are placed using BoxLayout. The second JPanel is a big blank screen. So, i would like to put the first JPanel at the center of second JPanel(horizontally & vertically). The problem is that i don't have any other component. So,if i try to use FlowLayout, i am able to put it at the center(horizontally, not vertically) only on the top edge. I tried to use BoxLayout. But, i couldn't(as i don't have any other elements). I tried to create some blank elements. But, they are messing up the elements of my JPanel. Any cluesssssssss??????????

    import java.awt.*;
    import javax.swing.*;
    public class CenteredLayout
        private JPanel getPanel()
            GridBagLayout gridbag = new GridBagLayout();
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(2,2,2,2);
            JPanel p = new JPanel(gridbag);
            addComponents(new JLabel("label 1"), new JTextField(8), p, gbc);
            addComponents(new JLabel("label 2"), new JTextField(8), p, gbc);
            addComponents(new JLabel("label 3"), new JTextField(8), p, gbc);
            JPanel panel = new JPanel(gridbag);
            panel.setBackground(Color.pink);
            gbc.anchor = GridBagConstraints.CENTER;
            gbc.insets = new Insets(0,0,0,0);
            panel.add(p, gbc);
            return panel;
        private void addComponents(Component c1, Component c2, Container c,
                                   GridBagConstraints gbc)
            gbc.anchor = GridBagConstraints.EAST;
            gbc.gridwidth = GridBagConstraints.RELATIVE;
            c.add(c1, gbc);
            gbc.anchor = GridBagConstraints.WEST;
            gbc.gridwidth = GridBagConstraints.REMAINDER;
            c.add(c2, gbc);
        public static void main(String[] args)
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new CenteredLayout().getPanel());
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • Adding and displaying a new JPanel -- not working as expected

    I'm starting my own new thread that is based on a problem discussed in another person's thread that can be found here in the New to Java forum titled "ActionListener:
    http://forum.java.sun.com/thread.jspa?threadID=5207301
    What I want to do: press a button which adds a new panel into another panel (the parentPane), and display the changes. The Actionlistener-derived class (AddPaneAction) for the button is in it's own file (it's not an internal class), and I pass a reference to the parentPane in the AddPaneAction's constructor as a parameter argument.
    What works: After the button is clicked the AddPaneAction's actionPerformed method is called without problem.
    What doesn't work: The new JPanel (called bluePanel) is not displayed as I thought it would be after I call
            parentPane.revalidate();  // this doesn't work
            parentPane.repaint(); 
    What also doesn't work: So I obtained a reference to the main app's JFrame (I called it myFrame) by recursively calling component.getParent( ), no problem there, and then tried (and failed to show the bluePanel with) this:
            myFrame.invalidate();  // I tried this with and without calling this method here
            myFrame.validate();  // I tried this with and without calling this method here
            myFrame.repaint();
    What finally works but confuses me: I got it to work but only after calling this:
            myFrame.pack(); 
            myFrame.repaint();But I didn't think that I needed to call pack to display the panel. So, what am I doing wrong? Why are my expectations not correct? Here's my complete code/SSCCE below. Many thanks in advance.
    Pete
    The ParentPane class:
    import java.awt.BorderLayout;
    import java.awt.Color;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class ParentPane extends JPanel
        private JButton addPaneBtn = new JButton("Add new Pane");
        public ParentPane()
            super();
            setLayout(new BorderLayout());
            setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
            setBackground(Color.yellow);
            JPanel northPane = new JPanel();
            northPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
            northPane.setBackground(Color.yellow);
            northPane.add(addPaneBtn);
            add(northPane, BorderLayout.NORTH);
            // add our actionlistener object and pass it a reference
            // to the main class which happens to be a JPanel (this)
            addPaneBtn.addActionListener(new AddPaneAction(this));
        public static void main(String[] args)
            javax.swing.SwingUtilities.invokeLater(new Runnable()
                public void run()
                    createAndShowGUI();
        private static void createAndShowGUI()
            JFrame frame = new JFrame("test add panel");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(new ParentPane());
            frame.pack();
            frame.setVisible(true);
    } the AddPaneAction class:
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.SwingConstants;
    public class AddPaneAction implements ActionListener
        private JPanel parentPane;
        private JFrame myFrame;
        public AddPaneAction(JPanel parentPane)
            this.parentPane = parentPane;
         * recursively get the JFrame that holds the parentPane panel.
        private JFrame getJFrame(Component comp)
            Component parentComponent = comp.getParent();
            if (parentComponent instanceof JFrame)
                return (JFrame)parentComponent;
            else
                return getJFrame(parentComponent);
        public void actionPerformed(ActionEvent arg0)
            JPanel bluePanel = new JPanel(new BorderLayout());
            bluePanel.setBackground(Color.blue);
            bluePanel.setPreferredSize(new Dimension(400, 300));
            JLabel myLabel = new JLabel("blue panel label");
            myLabel.setForeground(Color.LIGHT_GRAY);
            myLabel.setVerticalAlignment(SwingConstants.CENTER);
            myLabel.setHorizontalAlignment(SwingConstants.CENTER);
            bluePanel.add(myLabel, BorderLayout.CENTER);
            parentPane.add(bluePanel);
            myFrame = getJFrame(parentPane);
            //parentPane.revalidate();  // this doesn't work
            //parentPane.repaint(); 
            //myFrame.invalidate(); // and also this doesn't work
            //myFrame.validate();
            //myFrame.repaint();
            myFrame.pack();  // but this does!?
            myFrame.repaint();
    }

    For me (as it happens I'm using JDK 1.5.0_04) your code appears to work fine.
    It may be that we're seeing the same thing but interpreting it differently.
    1. When I run your application with your "working" code, and press the button then the JFrame resizes and the blue area appears.
    2. When I run your application with your "not working" code and press the button then the JFrame does not resize. If I manually resize it then the blue area is there.
    3. When I run your application with your "not working" code, resize it first and then press the button then the JFrame then the blue area is there.
    I interpret all of this as correct behaviour.
    Is this what you are seeing too?
    Are you expecting revalidate, repaint, invalidate or validate to resize your JFrame? I do not.
    As an aside, I do remember having problems with this kind of thing in earlier JVMs (e.g. various 1.2 and 1.3), but I haven't used it enough recently to know if your code would manifest one of the previous problems or not. Also I don't know if they've fixed any stuff in this area.

  • Initialise a Swing JPanel with Another

    I have a problem initialising a JPanel .Here is my code :`
    JPanel canvas = new JPanel();
    JTextField txt = new JTextField();
    txt.setBounds(50, 50, 200, 30);
    canvas.add(txt);
    JPanel can = canvas;
    System.out.println("COMPONENTS 1 :" + canvas.getComponentCount());
    System.out.println("COMPONENTS 1 :" + can.getComponentCount());
    JTextField txt1 = new JTextField();
    txt1.setBounds(100, 100, 200, 30);
    can.add(txt1);
    System.out.println("COMPONENTS 2 :" + canvas.getComponentCount());
    System.out.println("COMPONENTS 2 :" + can.getComponentCount());
    The output is :
    COMPONENTS 1 :1
    COMPONENTS 1 :1
    COMPONENTS 2 :2
    COMPONENTS 2 :2
    What i want :
    COMPONENTS 1 :1
    COMPONENTS 1 :1
    COMPONENTS 2 :1
    COMPONENTS 2 :2
    Any help will be highly appreciated

    JPanel can = canvas;They're the same JPanel object.
    All you've done is add a text field to it via one of those references.

  • How to generate button action in another JPanel?

    I want to get a line draw in another JPanel 2 when I click the button in JPanel 1.
    Can I acheive it in any way?

    give JPanel 1 a pointer to JPanel 2
    add an actionlistener to the button in JPanel 1
    with some code like
    JPanel2.addLine();

  • Two JPanels inside another panel should be equal in width

    Hi everybody,
    I have two JPanels which both have a titledborder. I want them to have the same with, but I can not get it done. You can see how it looks here: http://jborsje.nl/jpanels.png. As you can see the JPanels are not equal in width. Here is the code I used (please note that p_hopsControl = true).
         * Initialize the sidebar of the graph panel.
         * @param p_hopsControl Indicates whether or not a widget for controlling the
         * hops in the graph should be added to the panel.
        private JPanel getSideBar(boolean p_hopsControl)
            // Create the panel.
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints constraints = new GridBagConstraints();
            constraints.anchor = GridBagConstraints.FIRST_LINE_START;
            // Add the label and the spinner to the panel.
            constraints.gridx = 0;
            if (!p_hopsControl) constraints.weighty = 1;
            constraints.gridy = 0;
            panel.add(getLegend(), constraints);
            if (p_hopsControl)
                constraints.gridy = 1;
                constraints.weighty = 1;
                constraints.weightx = 1;
                panel.add(getHopsWidgets(), constraints);
            // Set the background of the panel.
            panel.setBackground(m_display.getBackground());
            return panel;
        private JEditorPane getLegend()
            String content = "<html><body>" +
                    "<table>" +
                    "<tr><td bgcolor=\"" + Integer.toHexString(Constants.NODE_COLOR_CLASS & 0x00ffffff) + "\" width=\"20px\"></td><td>OWL class</td></tr>" +
                    "<tr><td bgcolor=\"" + Integer.toHexString(Constants.NODE_COLOR_INDIVIDUAL & 0x00ffffff) + "\"></td><td>OWL individual</td></tr>" +
                    "<tr><td bgcolor=\"" + Integer.toHexString(Constants.NODE_COLOR_SELECTED & 0x00ffffff) + "\"></td><td>Node selected</td></tr>" +
                    "<tr><td bgcolor=\"" + Integer.toHexString(Constants.NODE_COLOR_HIGHLIGHTED & 0x00ffffff) + "\"></td><td>Node highlighted</td></tr>" +
                    "<tr><td bgcolor=\"" + Integer.toHexString(Constants.NODE_COLOR_SEARCH & 0x00ffffff) + "\"></td><td>Node in search result set</td></tr>" +
                    "<tr><td bgcolor=\"" + Integer.toHexString(Constants.NODE_DEFAULT_COLOR & 0x00ffffff) + "\"></td><td>Node in search result set</td></tr>" +
                    "</body></html>";
            JEditorPane legend = new JEditorPane("text/html", content);
            legend.setEditable(false);
            legend.setBorder(new TitledBorder("Legend"));
            JPanel panel = new JPanel();
            panel.setBorder(new TitledBorder("Legend"));
            panel.add(legend);
            return legend;
         * Create a panel containing a JSpinner which can be used to set the number
         * of hops, used in the graph distance filter.
         * @return A JPanel containing the hops widgets.
        private JPanel getHopsWidgets()
            // Get the GraphDistanceFilter.
            GraphDistanceFilter filter = m_display.getDistanceFilter();
            // Create the panel.
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints constraints = new GridBagConstraints();
            constraints.anchor = GridBagConstraints.FIRST_LINE_START;
            // Create the label.
            JLabel label = new JLabel("Number of hops: ");
            // Create the spinner and its model.
            SpinnerNumberModel model = new SpinnerNumberModel(filter.getDistance(), 0, null, 1);
            m_spinner = new JSpinner();
            m_spinner.addChangeListener(this);
            m_spinner.setModel(model);
            // Add the label and the spinner to the panel.
            constraints.gridx = 0;
            constraints.gridy = 0;
            panel.add(label, constraints);
            constraints.gridx = 1;
            constraints.weighty = 1;
            panel.add(m_spinner, constraints);
            // Set the background of the panel.
            panel.setBackground(m_display.getBackground());
            // Add a titled border to the panel.
            panel.setBorder(new TitledBorder("Hops control"));
            return panel;
        }Does anybody know how this can be done?

    Thanks, that solved my issue for the width part. Now the content of the "hops control" panel is centered, althoug I explicitely said "constraints.anchor = GridBagConstraints.FIRST_LINE_START;".
    The update image can still be found here: http://www.jborsje.nl/jpanels.png.

  • Calling arraylist from another class - help please!!

    Hey, I need some help calling my arraylist from my GUI class, as the arraylist is in the 'AlbumList' class and not in the 'GUI' class i get the error 'cannot find symbol', which is pretty obvious but i cannot figure how to get around this problem. help would be greatly appreciated.
    i have written ***PROBLEM*** next to the bad line of code!
    Thanks!!
    public class Album
        String artist;
        String title;
        String genre;
        public Album(String a, String t, String g)
            artist = a;
         title = t;
            genre = g;
         public String getArtist()
            return artist;
        public String getTitle()
            return title;
         public String getGenre()
            return genre;
    public class AlbumList
        public ArrayList <Album> theAlbums;
        int pointer = -1;
        public AlbumList()
            theAlbums = new ArrayList <Album>();
        public void addAlbum(Album newAlbum)
         theAlbums.add(newAlbum);
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class GUI extends JFrame
        public int max = 5;
        public int numAlbums = 4;
        public int pointer = -1;
        public GUI ()
            super("Recording System");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel main = new JPanel();
            JPanel panel1 = new JPanel();
            panel1.setLayout(new GridLayout(3,2,0,0));
            JPanel panel2 = new JPanel();
            panel2.setLayout(new GridLayout(1,2,20,0));
            final JLabel artistLBL = new JLabel("Artist: ");
            final JLabel titleLBL = new JLabel("Title: ");
            final JLabel genreLBL = new JLabel("Genre: ");
            final JTextField artistFLD = new JTextField(20);
            final JTextField titleFLD = new JTextField(20);
            final JTextField genreFLD = new JTextField(20);
            final JButton nextBTN = new JButton("Next");
            nextBTN.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    pointer++;
                    artistFLD.setText(theAlbums.get(pointer).getArtist());       ***PROBLEM***
                    titleFLD.setText("NEXT");
                    genreFLD.setText("NEXT");
            final JButton prevBTN = new JButton("Prev");
            prevBTN.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    pointer--;
                    artistFLD.setText("PREVIOUS");
                    titleFLD.setText("PREVIOUS");
                    genreFLD.setText("PREVIOUS");
         panel1.add(artistLBL);
            panel1.add(artistFLD);
            panel1.add(titleLBL);
            panel1.add(titleFLD);
            panel1.add(genreLBL);
            panel1.add(genreFLD);
            panel2.add(prevBTN);
            panel2.add(nextBTN);
            main.add(panel1);
            main.add(panel2);
            setVisible(true);
            this.getContentPane().add(main);
            setSize(500, 500);
    -----------------------------------------------------------------------Thanks!!
    Edited by: phreeck on Nov 3, 2007 8:55 PM

    thanks, it dosnt give me a complication error but when i press the button it says out of bounds error, and i think my arraylist may be empty possibly even though i put this data in.. this is my test file which runs it all.
    any ideas? thanks!!
    public class Test
        public static void main(String []args)
            AlbumList a = new AlbumList();
            String aArtist = "IronMaiden";
            String aTitle = "7thSon";
            String aGenre = "HeavyMetal";
            Album newA = new Album(aArtist, aTitle, aGenre);
            a.addAlbum(newA);
            aArtist = "LambOfGod";
            aTitle = "Sacrament";
            aGenre = "Metal";
            Album newB = new Album(aArtist, aTitle, aGenre);
            a.addAlbum(newB);
            aArtist = "JohnMayer";
            aTitle = "Continuum";
            aGenre = "Guitar";
            Album newC = new Album(aArtist, aTitle, aGenre);
            a.addAlbum(newC);
            aArtist = "StillRemains";
            aTitle = "TheSerpent";
            aGenre = "Metal";
            Album newD = new Album(aArtist, aTitle, aGenre);
            a.addAlbum(newD);
         GUI tester = new GUI();
    }

  • File not found when adding a link to another site collection on the navigation page

    When I am adding a link to another site collection in the navigation page, I got the following error. Is there any limitation for the navigation setting? why can't we add a link to another site collection in the navigation page?
    This is SharePoint 2007

    Hi
    the URL provided is working?  (check it in separate browser window )
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • Hw to split the jpanel to 3 jpanels

    Hello frnds,
    In the below mentioned code I need to split the teller panel to three teller can you give any suggestions.
    thank you
    suraw
    package guis.views;
    import guis.controllers.GeneralController;
    import java.awt.Dimension;
    import java.awt.GridBagLayout;
    import java.awt.GridLayout;
    import java.beans.PropertyChangeEvent;
    import java.util.LinkedList;
    import javax.swing.DefaultListModel;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    * This is a custom view panel that displays a "document" consisting of a single
    * text element. Both the document and the text element respond to changes in
    * the model state.
    * @author Robert Eckstein
    public class TellerPanelView extends View
         private JPanel tellerPanel,tellerSubPanel;
         private JList teller;
         private JLabel tellerInfo;
         private JSplitPane SplitPane;
         private LinkedList<String> customerAtTeller;
         private JScrollPane listScroller;
         private DefaultListModel tellerlist;
         // The controller used by this view
         private GeneralController controller;
         * Creates new form TextElementDisplayPanel
         * @param controller An object implenting the controller interface that
         * this view can use to process GUI actions
         public TellerPanelView(GeneralController controller) {
              this.controller = controller;
              initComponents();
              localInitialization();
         * Initialization method called from the constructor
         public void localInitialization() {
         /** This method is called from within the constructor to
         * initialize the form.
         private void initComponents() {
              tellerPanel = new JPanel(new GridLayout(2,1));          
         tellerInfo = new JLabel("Teller1: Teller2: Teller3:");
              teller = new JList();
              tellerlist = new DefaultListModel();
              teller.setModel(tellerlist);
              SplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);          
              for (int a = 0; a <= 2; a++)
              listScroller = new JScrollPane(teller,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
              customerAtTeller = new LinkedList<String>();
              tellerPanel.add(tellerInfo);
              tellerPanel.add(listScroller);
         public JPanel getTellerPanel() {
              return tellerPanel;
         * Called by the controller when it needs to pass along a property change
         * from a model.
         * @param evt The property change event
         public void modelPropertyChange(PropertyChangeEvent evt) {
              if (evt.getPropertyName().equals(GeneralController.ADD_TRANSACTION)) {
                   String cust = (String) evt.getNewValue();
                   customerAtTeller.addLast(cust);
                   tellerlist.addElement(cust);
              revalidate();
              repaint();
    }

    While it looks like you've split a panel, you really haven't. You've added spcific components to a JPanel that make it look like it's split.
    Ingredients needed: a total of 4 JPanels, and 2 JSplitPanes
    Step 1: Create 2 new JPanels, and then Create a JSplitPane that houses these two JPanels
    JSplitPane jsp1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jPanel2, jPanel3);
    Step 2: Create a 3rd JPanel, and then Create a second JSplit Pane that holds the 3rd JPanel, the JSplitPane created in step 1
    JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jPanel1, jsp1);
    Step 3: Now, add the JSplitPane created in step 2 to your original JPanel
    jsp0.add(jsp2); // modify the add according to the screen manager you're using
    You'll want to set properties on EACH of the JSplitPanes:
    ((JSplitPane) jsp1).setDividerSize(6);
    ((JSplitPane) jsp1).setContinuousLayout(true);
    ((JSplitPane) jsp1).setResizeWeight( (iSliderPos * 0.01) ); // VERY IMPORTANT!!!
    ((JSplitPane) jsp1).setDividerLocation( (iSliderPos * 0.01) );
    where int iSliderPos is 0 - 100
    Gotchas: I may look like there is nothing there (empty screen) because there are no components in jsp1, jsp2, and jsp3.
    You'll either need to put components on these JPanels, or force the JPanels to have some size by setting:
    jpanel1.setMinimumSize(new Dimension(80, 60));
    jpanel1.setPreferredSize(new Dimension(800, 600));
    jpanel1.setMaximumSize(new Dimension(1600, 1200));
    jpanel1.setBounds(0,0,800,600);
    jpanel1.setBorder(blackLineBorder);
    (repeat for jpanel2 and jpanel3)
    and the split panes:
    jsp1.setMinimumSize(new Dimension(80, 60));
    jsp1.setPreferredSize(new Dimension(800, 600));
    jsp1.setMaximumSize(new Dimension(1600, 1200));
    jsp1.setBounds(0, 0, 800, 600);
    (repeat for jsp2)
    This was pretty frustrating for me the first couple (of hundred) times. Maybe try to get it working as 2 panels with one split first.
    bcf

  • I am unable to merge the call after adding in iphone 4 , can anybody help me ?

    Unable to merge call for conference after adding new call . Can anybody help ?

    Conference calls With GSM, you can set up a conference call with up to five people at a time, depending on your carrier.
    Create a conference call: While on a call, tap Add Call, make another call, then tap Merge Calls. Repeat to add more people to the conference.
    Drop one person: Tap Conference, tap next to a person, then tap End Call.
    Talk privately with one person: Tap Conference, then tap Private next to the person. Tap Merge Calls to resume the conference.
    Add an incoming caller: Tap Hold Call + Answer, then tap Merge Calls. Note: You can’t make a FaceTime video call when you’re on a conference call

  • Error while adding a connector for SSL..help!!!

    i'm getting this error when i added a connector for SSL and restarted tomcat
    my connector tag is
    <Connector keystorePass="kalima" scheme="https" port="8443" sslProtocol="TLS" redirectPort="-1" enableLookups="true" keystoreFile="Mykeystore" protocol="TLS" keystore="C:\Documents and Settings\santhoshyma\Mykeystore" clientauth="false" algorithm="SunX509" keypass="changeit" secure="true" keytype="JKS">
          <Factory className="org.apache.coyote.tomcat5.CoyoteServerSocketFactory" keystorePass="kalima" keystoreFile="C:\SSLTest\Mykeystore"/>
        </Connector>
    LifecycleException:  Protocol handler instantiation failed: java.lang.NullPointe
    rException
            at org.apache.coyote.tomcat5.CoyoteConnector.initialize(CoyoteConnector.
    java:1368)
            at org.apache.catalina.core.StandardService.initialize(StandardService.j
    ava:609)
            at org.apache.catalina.core.StandardServer.initialize(StandardServer.jav
    a:2384)
            at org.apache.catalina.startup.Catalina.load(Catalina.java:507)
            at org.apache.catalina.startup.Catalina.load(Catalina.java:528)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:250)
            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:424)

    The question is answered in CRM 7.0 forum:
    Getting error while adding a custom field (with input help) through AET

Maybe you are looking for

  • My power cord isn't charging my powerbook g4

    Okay, so my problems started a couple of weeks ago. I have a Powerbook g4, 15 inch. It's not brand new, I bought it off of ebay, but it worked fine for the first week that I had it, no problems. Then one day when I was using it I heard a "pop", and I

  • BPM - 2 Transformation Steps

    Hi, I have created a BPM which is very similar to the BPMPatternCollectTime design. The only difference is that I have 2 Transformation Steps. Now I gave one step in the Interface Determination Step of the IP->Receiver Config. What should I do with t

  • Favicons not displaying in tabs, but showing fine in the address bar and with bookmarks.

    We had a power outage this evening while I was on the computer, and now, all of a sudden, when I open a site in a tab, the tab itself fails to display the site's favicon when applicable, but the icons display without any issue in both the address bar

  • Choose File button disabled

    I have php code below to upload a photo to a website. It works fine using Safari on my desktop (and other browsers) but not on my iPhone Safari browser. The Choose File button is disabled on the iPhone using its Safari browser. I know there are some

  • Declare rfc destination to receive idoc

    i am trying an example to declare rfc destination to receive idoc.  the directions say to create a new destination of type "L" with the name INTERNAL and desination NONE. When i try to create a new rfc desination with destination NONE is says there i