Panels in a row in a scroll pane.

Hi,
in my application, i have a UI frame, which contains a scroll pane that has a panel, which contains a few hundreds of panels, lined up vertically.
Each of these panels contais an icon, a label, a text field and a few more label fields and more text fields(sometimes)
When the UI cmes up the parent panel contains only a few(10-15) panels one below another and if we click on the icon, we need to add a few more panels below the panel that contains the label that was clicked.
In the case, when we click on all the icons in the parent panel, then we need to add a lot of panels and we hit the out of memory exception.
does anyone have a good solution here.
The TreeTable UI item would have been perfect here but we can not use them because we dont want to change the look of the UI for backward compatibility reasons.
Also, every time the icon was clicked, creating and ading the panels is very slow.
Any help is greatly appreciated.
regards.

1. You could create a secondary storyline and edit B-roll into it. It will behave more like tracks. The secondary does have magnetic properties, which many people find hinders the free movement of B-roll.
2. Again secondaries. But basically you're trying to make the application behave like a tracked application when its essence is to be trackless.
3. Not seen this.
4. Doesn't work in FCP. Use copy and paste attributes.
5. Yes. The homemade titles and effects created in Motion live in a specific folder structure in your Movies folder. That can be shared and duplicated on any Mac with FCP.
6. There is no one answer to that, events and projects are entirely separate from each other, except that specific events and projects reference each other. You can simplify things so a single event holds all the content for a single project and its versions.
7. You can't change the import function. It's simply a file transfer as FCP edits it natively. You can select the clips in FCP and change the channel configuration.

Similar Messages

  • IS IT POSSIBLE TO ADD A SCROLL PANE TO A PANEL??

    Hi, Im trying to add a scroll pane to a panel but when I compile the code and try to open the form - a 'Illegal Argument Exception' is produced. Can anyone tell me whether it is possible to add a scroll pane the actual panel itself and also the code to do this.     
    Many Thanks, Karl.
    I have added some sample code I have created -
    public RequestForm(RequestList inC)throws SQLException{
              inRequestList = inC;
              displayForm();
              displayFields();
              displayButtons();
              getContentPane().add(panel);
              setVisible(true);
         public void displayForm() throws SQLException{
              setTitle("Request Form");
              setSize(600,740);
              // Center the frame
              Dimension dim = getToolkit().getScreenSize();
              setLocation(dim.width/2-getWidth()/2, dim.height/2-getHeight()/2);
              getContentPane().setLayout(new BorderLayout());
              Border etched = BorderFactory.createEtchedBorder();
              panel = new JPanel();
              panel.setLayout( null );
              //panel.setBackground(new Color(1,90,50));
              Border paneltitled = BorderFactory.createTitledBorder(etched,"");
              panel.setBorder(paneltitled);
              scrollPane1 = new JScrollPane(panel);
              scrollPane1.setBounds(0, 0, 600, 740);
              panel.add(scrollPane1);
    }

    Hi all,
    I am still having trouble here. would it be posible to add a scrollpanel to this form? Can anyone provide me with a working piece of code so I see how it actually works.
    Any help would be greatly appreciated.
    Many Thanks, Karl.
    Code as Follows:
    /* ADMIN HELP Manual*/
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.util.*;
    public class AdminHelp extends JFrame implements ActionListener{
         private JButton exit;
         private JLabel heading1, help;
         private JPanel panel;
         Font f = new Font("Times New Roman", Font.BOLD, 30);
         private JScrollPane scroll;
         public AdminHelp(){
              setTitle("ADMIN Help Manual");
              setSize(400,325);
              // Center the frame
              Dimension dim = getToolkit().getScreenSize();
              setLocation(dim.width/2-getWidth()/2, dim.height/2-getHeight()/2);
              panel = new JPanel();
              panel.setLayout(null);
              exit = new JButton("Close");
              exit.setBounds(280,260,100,20);
              exit.addActionListener(this);
              panel.add(exit);
              exit.setToolTipText("Click here to close and return to the main menu");
              getContentPane().add(panel);
              show();
              public void actionPerformed(ActionEvent event){
              Object source = event.getSource();
                   if (source == exit){
                        dispose();
              public static void main(String[] args){
                   AdminHelp frame = new AdminHelp();
                   frame.addWindowListener(new WindowAdapter(){
                   public void windowClosing(WindowEvent e){
                   System.exit(0);

  • How to add a scroll pane for a panel.

    Hi
    i have a panel with some images drawn . i want a scroll pane added to this panel.
    I tried adding it but failed.
    Any suggestions please (
    here is my code.
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.Panel;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    class frame extends JFrame
         public frame()
              JScrollPane pane=new JScrollPane();
              setContentPane(new  DrawClass());
              setSize(500,300);
              setBounds(200,300, 100, 500);
              setVisible(true);
    public class DrawClass extends JPanel implements ActionListener {
         public DrawClass(){
               public void paintComponent(Graphics g){
                          super.paintComponent(g);
                    String [] Filenames={"im3","im4","im5","im6"};
                   int imgX = 0;
                   int imgY = 10;
                   Toolkit toolkit = Toolkit.getDefaultToolkit();
                   Integer[] intArray = new Integer[Filenames.length];
                   for (int i = 0; i < Filenames.length; i++)
                        intArray[i] = new Integer(i);
                       if (Filenames[i] != "" )
                            //XMLFileParser r=new XMLFileParser();
                             Image img =toolkit.getImage( "/home/swathi/Desktop/Images/"+ Filenames[i]+ ".jpg" );
                           g.drawImage (img, imgX, imgY, this);                                       
                           imgY=imgY+100;                  
                       else
                            System.out.println("NO file Found");
               public static void main(String[] args){
               frame f =new frame();
              public void actionPerformed(ActionEvent e) {
                   // TODO Auto-generated method stub
         

    can you please help me in this code .....
    DrawClass.
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.Panel;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    class frame extends JFrame
         public frame()
              setContentPane(new  DrawClass());
              setSize(500,300);
              setBounds(200,300, 100, 500);
              setVisible(true);
    public class DrawClass extends JPanel implements ActionListener {
         public DrawClass(){
               public void paintComponent(Graphics g){
                          super.paintComponent(g);
                    String [] Filenames={"im3","im4","im5","im6"};
                   int imgX = 0;
                   int imgY = 10;
                   Toolkit toolkit = Toolkit.getDefaultToolkit();
                   Integer[] intArray = new Integer[Filenames.length];
                   for (int i = 0; i < Filenames.length; i++)
                        intArray[i] = new Integer(i);
                       if (Filenames[i] != "" )
                            //XMLFileParser r=new XMLFileParser();
                             Image img =toolkit.getImage( "/home/swathi/Desktop/Images/"+ Filenames[i]+ ".jpg" );
                           g.drawImage (img, imgX, imgY, this);                                       
                           imgY=imgY+100;                  
                       else
                            System.out.println("NO file Found");
               public static void main(String[] args){
               frame f =new frame();
              public void actionPerformed(ActionEvent e) {
                   // TODO Auto-generated method stub
         ListClass
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Vector;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.dnd.*;
    import javax.swing.*;
    import java.awt.Component;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.ImageObserver;
    import java.awt.Toolkit;
    import javax.swing.*;
    import org.w3c.dom.Node;
         public class ListClass extends JPanel{
              ListClass(){
                   DrawClass d=new DrawClass();
              My question is how i can call a method of DrawClass which contains the drawn images ; in the List Class.
    its very urgent please.....

  • Remove/Hide scroll bars in scroll panes.

    Hi all,
    I am pretty new to action script. I am building a photo gallery and I am loading the thumbnails from an XML file into a scroll pane dynamically. As the scroll pane fills up, it gets wider to accomodate the thumbnails. There is one row, and eventually, I want to have the user be able to mouse left or right and have the scroll pane scroll, versus clicking on the bar or the left/right arrows. However, in order to accomplish this, I need the scroll bars to disappear!
    Is there anyway to either remove or hide both the x and y scroll bars on a scroll pane? My scroll pane is called: thumbPane.
    Thanks in advance!
    -Rob

    Hello friend,
                       first select scrollpane.Then open parameters panel (if dont know go to window > properties > paramiters ) turn to OFF HorizontalScrollPolicy  and verticalScrollPoliy then left and right scroll Bar will not display.
    THANKS.

  • Need help with a scroll pane

    Hello all. I am trying to get a scroll pane to work in an application that I have built for school. I am trying to get an amortization table to scroll through for a mortgage calculator. It isn't recognizing my scrollpane and I am not sure why. Could someone give me a push in the right direction.
    import javax.swing.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.text.*;
    public class MortCalcWeek3 extends JFrame implements ActionListener
         DecimalFormat twoPlaces = new DecimalFormat("#,###.00");//number format
         int L[] = {7, 15, 30};
         double I[] = {5.35, 5.5, 5.75};
         double P, M, J, H, C, Q;
         JPanel panel = new JPanel ();//creates the panel for the GUI
         JLabel title = new JLabel("Mortgage Calculator");
         JLabel PLabel = new JLabel("Enter the mortgage amount: ");
         JTextField PField = new JTextField(10);//field for obtaining user input for mortgage amount
         JLabel choices = new JLabel ("Choose the APR and Term in Years");
         JTextField choicestxt = new JTextField (0);
         JButton calcButton = new JButton("Calculate");
         JTextField payment = new JTextField(10);
         JLabel ILabel = new JLabel("Annual Percentage Rate: choose one");
         String [] IChoice = {I[0] + "", I[1] + "", I[2] + ""};
         JComboBox IBox = new JComboBox(IChoice);
         JLabel LLabel = new JLabel("Term (in years): choose one");
         String [] LChoice = {L[0] + "", L[1] + "", L[2] + ""};
         JComboBox LBox = new JComboBox(LChoice);
         JLabel amortBox = new JLabel("Amortiaztion Table");
         JScrollPane amortScroll = new JScrollPane(amortBox);
         public MortCalcWeek3 () //creates the GUI window
                        super("Mortgage Calculator");
                        setSize(300, 400);
                        setBackground (Color.white);
                        setForeground(Color.blue);
                        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        //Creates the container
                        Container contentPane = getContentPane();
                        FlowLayout fresh = new FlowLayout(FlowLayout.LEFT);
                        panel.setLayout(fresh);
                        //identifies trigger events
                        calcButton.addActionListener(this);
                        PField.addActionListener(this);
                        IBox.addActionListener(this);
                        LBox.addActionListener(this);
                        panel.add(PLabel);
                        panel.add(PField);
                        panel.add(choices);
                        panel.add(choicestxt);
                        panel.add(ILabel);
                        panel.add(IBox);
                        panel.add(LLabel);
                        panel.add(LBox);
                        panel.add(calcButton);
                        panel.add(payment);
                        panel.add(amortBox);
                        payment.setEditable(false);
                        panel.add(amortScroll);
                        setContentPane(panel);
                        setVisible(true);
         }// end of GUI info
              public void actionPerformed(ActionEvent e) {
                   MortCalcWeek3();     //calls the calculations
              public void MortCalcWeek3() {     //performs the calculations from user input
                   double P = Double.parseDouble(PField.getText());
                   double I = Double.parseDouble((String) IBox.getSelectedItem());
                   double L = Double.parseDouble((String) LBox.getSelectedItem());
                   double J = (I  / (12 * 100));//monthly interest rate
                   double N = (L * 12);//term in months
                   double M = (P * J) / (1 - Math.pow(1 + J, - N));//Monthly Payment
                 String showPayment = twoPlaces.format(M);
                 payment.setText(showPayment);
         //public void amort() {
                   //int N = (L * 12);
                   int month = 1;
                             while (month <= N)
                                  //performs the calculations for the amortization
                                  double H = P * J;//current monthly interest
                                  double C = M - H;//monthly payment minus monthly interest
                                  double Q = P - C;//new balance
                                  P = Q;//sets loop
                                  month++;
                                  String showAmort = twoPlaces.format(H + C + Q);
                                amortScroll(showAmort);
              public static void main(String[] args) {
              MortCalcWeek3 app = new MortCalcWeek3();
    }//end main
    }//end the programI appreciate any help you may provide.

         JLabel amortBox = new JLabel("Amortiaztion Table");
         JScrollPane amortScroll = new JScrollPane(amortBox);The argument passed to a JScrollPane constructor specifies what's inside the scroll pane. Here, it seems like you're trying to create a scroll pane that displays a JLabel.
    Also, I'm not sure what you're trying to do here:
    amortScroll(showAmort);I don't see a method named "amortScroll".
    You need to make a JTextArea, pass that into the JScrollPane's constructor, and add the JScrollPane to your frame.

  • Moving around in a  j scroll pane.

    I have a JTextArea inside a JScrollPane and I'm trying to get the scroll pane to goto a certain line number that I want by using:
    TA.setCaretPosition(10*linenumber);the linenumber is the line number the user enters and then the 10 is just the pixel it will go down because the interval I counted between each line is about 10. But it doesn't seem to move at all, what am I doing wrong?

    I guess it doesn't work like that.
    What you are doing is moving the caret to a certain position in the document. The setCaretPosition method expects the CHARACTER position in the document to which to move, and has nothing to do with pixels...
    But this won't be moving the scroll pane at all. I think what you are looking for is the TA.scrollRectToVisible(Rectangle) method. You pass a Rectangle on the textarea that you want to be made visible, and the call is repassed to the parents until a JViewPort is found, which is then scrolled.
    To calculate this rectangle you could use TA.getRows() and TA.getSize().height, for example, to determine how much space each row is really occupying.
    Best regards,
    Marcos.

  • Turn off scroll pane component pt2

    hello kglad
    sorry, responded by email and it left off message. i guess my answer would be by code, but dragged from component panel. one unprofessional, uneducated workaround was putting a black box behind the text/graphics in other frames so it would cover up the scroll pane that doesn't go away.
    on previous thread you asked...
    are you adding your scrollpane with code?  if yes, remove it (removeChild, remove listeners and null it) with code.  if no, add an empty keyframe in the scollpane's layer after the keyframe where it's added.
    below is the code followed by what's resulting after clicking the "next" button

    attached to your next listener use:
    removeChild(sp);
    sp=null;

  • Keeping focus in the viewable window of a scroll pane

    I have many text fields and text areas inside a scroll pane. When I use tab to cycle through these boxes the focus goes out of the viewable window rather then the scroll pane moving to follow the focus. Is it possible for the scroll pane to follow the focus? I would think it is. But I haven't been able to figure out how. Any ideas?
    Thanks,
    Mark

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class test extends JFrame {
      FieldListener fieldListener = new FieldListener();
      final static int fieldNumber = 15;
      JPanel panel;
      public test() {
        super("Focused Scrolling");
        panel = new JPanel();
        panel.setLayout(new GridLayout(0,1));
        JTextField textField;
        for(int i = 0; i < fieldNumber; i++) {
          textField  = new JTextField("TextField # " + i);
          textField.addFocusListener(fieldListener);
          panel.add(textField);
        JScrollPane scrollPane = new JScrollPane(panel);
        getContentPane().add(scrollPane, "Center");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(300,200);
        setLocation(350,200);
        setVisible(true);
      class FieldListener extends FocusAdapter {
        public void focusGained(FocusEvent e) {
          JComponent field = (JComponent)e.getSource();
          Rectangle r = field.getBounds();
          //System.out.println("r = " + r);
          // JComponent method sends message to component's
          // parent who implements scrollable interface
          panel.scrollRectToVisible(r);
      public static void main(String[] args) {
        new test();
    }

  • Putting an image in a scroll pane

    This is probably a simple question for most of you, but I need a little bit of help. How do I put a picture in a scroll pane?
    The problem I have is that I can load an image and display it, that works fine. However, let's say I am making a new frame (I generally use JFrames), and I want to have a scroll pane in it. Let's also say I have numerous buttons around the edges (using a BorderLayout, or something). How do I load an image, draw the image on-screen and have it so that it only shows up in the scroll pane without the scrollbars disappearing?
    I try to do it now, but for some reason the scroll bars of the scroll pane never show up. I can make the entire image be displayed by dragging the window edges bigger (the normal way you make windows bigger), and then I can see the entire picture. Unfortunately, the scroll bars on the scroll pane never show up if the window is too small to display the entire image. This is very puzzling, because I really don't know what I'm doing wrong. I have tried putting a panel in the scroll pane, and drawing on the panel, but still no scroll bars show up on the scroll pane if it is not big enough to show the entire picture / panel.
    I am sure that the solution is very simple, but right now that solution eludes me.

    There's an example in the swing tutorials that seems to me to do exactly what you want.
    See if http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html does the job, (less the border layout and buttons of course, but that shouldn't be too hard once you get the scroll bars working).
    I believe the default scrollbar policy will let the scroll bars appear only when needed based on the bounds and the preferred size.
    I used the example to set up a scrolling map (still just a gif image) and it works fine. If you still have trouble, you probably need to post the relevant section of code.

  • New to Applets: Problems wiht writing to files and with scroll panes.

    Hi, I've recently graduated from university and so I have limited experience in java programming and I'm having some trouble with JApplets (this is the first time I've made one). I'm trying to make a simple program that will allow users to pick one of a few background images from a list (a list of jpanels within a scroll pane) then at the click of a button will output a CSS with the background tag set to the image location. This is for use on a microsoft sharepoint site where each user has a My-Sit area which I want to be customizable.
    So far I've been creating this program as an application rather than a JApplet and just having another class that extends the JApplet Class which then displays the JFrame from the GUI Class. This initially didnt work because I was trying to add a window to a container so I kept programming it as an application until I got it working before trying to convert it to a JApplet. I solved the previous problem by changing my GUI class to extend JPanel instead of JFrame and it now displays correctly but with a coupe of issues.
    Firstly the applet will not create/write to the CSS file. I read that applets couldnt read/write to the users file system but they could to their own. The file I wish to write to is kept on the same machine as the applet so I'm not sure why this isn't working.
    Secondly the scroll panel is no longer working properly. This worked fine when I was still running the program as an application when the GUI still extended JFrame instead of JPanel (incidentally the program no longer runs as an application in this state) but now the scroll bar does not appear. This is a problem since I want the applet to remain the same size on the page even if I decide to add more backgrounds to the list. I tried setting the applet height/width to smaller values in the html file to see if the scroll bar would appear if the area was smaller than the GUI should be, but this just meant the bottom off the applet was cut off.
    Could anyone offer any suggestion as to why these thigns arnt working and how to fix them? If necessary I can post my source code here. Thanks in advance.

    Ok, well my program is made up of 4 classes, I hope this isnt too much to be posting. If any explaination is needed then I'll post that next. Theres lots of print lines scattered aroudn due to me trying to fix this and theres some stuff commented out from when the program used to be an application isntead of an applet.
    GUI Class, this was the main class until I made a JApplet Class
    public class AppletGUI extends JPanel{
        *GUI Components*
        //JFrames
        JFrame mainGUIFrame = new JFrame();
        JFrame changeBackgroundFrame = new JFrame();
        //JPanels (Sub-panels are indented)
        JPanel changeBackgroundJP = new JPanel(new BorderLayout());
            JPanel changeBackgroundBottomJP = new JPanel(new GridLayout(1,2));
        JPanel backgroundJP = new JPanel(new GridLayout(1,2));
        JPanel selectBackground = new JPanel(new GridLayout(1,2));
        //Jbuttons
        JButton changeBackgroundJB = new JButton("Change Background");
        JButton defaultStyleJB = new JButton("Reset Style");
        //JLabels
        JLabel changeBackgroundJL = new JLabel("Choose a Background from the Menu");
        JLabel backgroundJL = new JLabel();
        //JScrollPane
        JScrollPane backgroundList = new JScrollPane();
            JPanel backgroundListPanel = new JPanel(new GridLayout());
        //Action Listeners
        ButtonListener bttnLstnr = new ButtonListener();
        //Controllers
        CSSGenerator cssGenerator = new CSSGenerator();
        Backgrounds backgroundsController = new Backgrounds();
        backgroundMouseListener bgMouseListener = new backgroundMouseListener();
        //Flags
        Component selectedComponent = null;
        *Colour Changer*
        //this method is used to change the colour of a selected JP
        //selected JPs have their background darkered and when a
        //different JP is selected the previously seleced JP has its
        //colour changed back to it's original.
        public void changeColour(JPanel theJPanel, boolean isDarker){
        //set selected JP to a different colour
        Color tempColor = theJPanel.getBackground();
            if(isDarker){
                tempColor = tempColor.darker();
            else{
                tempColor = tempColor.brighter();
            theJPanel.setBackground(tempColor);
         //also find any sub-JPs and change their colour to match
         int j = theJPanel.getComponents().length;
         for(int i = 0; i < j; i++){
                String componentType = theJPanel.getComponent(i).getClass().getSimpleName();
                if(componentType.equals("JPanel")){
                    theJPanel.getComponent(i).setBackground(tempColor);
        *Populating the GUI*
        //backgroundList.add();
        //Populating the Backgrounds List
        *Set Component Size Method*
        public void setComponentSize(Component component, int width, int height){
        Dimension tempSize = new Dimension(width, height);
        component.setSize(tempSize);
        component.setMinimumSize(tempSize);
        component.setPreferredSize(tempSize);
        component.setMaximumSize(tempSize);     
        *Constructor*
        public AppletGUI() {
            //REMOVED CODE
            //AppletGUI.setDefaultLookAndFeelDecorated(true);
            //Component Sizes
            //setComponentSize
            //Adding Action Listeners to Components
            System.out.println("adding actions listeners to components");
            changeBackgroundJB.addActionListener(bttnLstnr);
            defaultStyleJB.addActionListener(bttnLstnr);
            //Populating the Change Background Menu
            System.out.println("Populating the window");
            backgroundsController.populateBackgroundsData();
            backgroundsController.populateBackgroundsList();
            //loops to add background panels to the JSP
            ArrayList<JPanel> tempBackgroundsList = new ArrayList<JPanel>();
            JPanel tempBGJP = new JPanel();
            tempBackgroundsList = backgroundsController.getBackgroundsList();
            int j = tempBackgroundsList.size();
            JPanel backgroundListPanel = new JPanel(new GridLayout(j,1));
            for(int i = 0; i < j; i++){
                tempBGJP = tempBackgroundsList.get(i);
                System.out.println("Adding to the JSP: " + tempBGJP.getName());
                //Add Mouse Listener
                tempBGJP.addMouseListener(bgMouseListener);
                backgroundListPanel.add(tempBGJP, i);
            //set viewpoing
            backgroundList.setViewportView(backgroundListPanel);
            /*TESTING
            System.out.println("\n\n TESTING!\n Printing Content of SCROLL PANE \n");
            j = tempBackgroundsList.size();
            for(int i = 0; i < j; i++){
                System.out.println(backgroundList.getComponent(i).getName());
            changeBackgroundJP.add(changeBackgroundJL, BorderLayout.NORTH);
            changeBackgroundJP.add(backgroundList, BorderLayout.CENTER);
            //changeBackgroundJP.add(tempBGJP, BorderLayout.CENTER);
            changeBackgroundJP.add(changeBackgroundBottomJP, BorderLayout.SOUTH);
            changeBackgroundBottomJP.add(changeBackgroundJB);
            changeBackgroundBottomJP.add(defaultStyleJB);
            System.out.println("Finsihed populating");
            //REMOVED CODE
            //adding the Background Menu to the GUI and settign the GUI options
            //AppletGUI.setDefaultLookAndFeelDecorated(true);
            //this.setResizable(true);
            //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setLocation(500,500);
            this.setSize(400,300);
            this.add(changeBackgroundJP);
        //REMOVED CODE
         *Main Method*
        public static void main(String[] args){
           System.out.println("Creating GUI");
           AppletGUI theGUI = new AppletGUI();
           theGUI.setVisible(true);
           System.out.println("GUI Displayed");
         *Button Listener Inner Class*
        public class ButtonListener implements ActionListener{
            //check which button is clicked
            public void actionPerformed(ActionEvent event) {
                AbstractButton theButton = (AbstractButton)event.getSource();
                //Default Style Button
                if(theButton == defaultStyleJB){
                    System.out.println("Default Style Button Clicked!");
                //Change Background Button
                if(theButton == changeBackgroundJB){
                    System.out.println("Change Background Button Clicked!");
                    String backgroundURL = cssGenerator.getBackground();
                    if(backgroundURL != ""){
                        cssGenerator.setBackgroundChanged(true);
                        cssGenerator.setBackground(backgroundURL);
                        cssGenerator.outputCSSFile();
                        System.out.println("Backgroudn Changed, CSS File Written");
                    else{
                        System.out.println("No Background Selected");
         *Mouse Listener Inner Class*
        public class backgroundMouseListener implements MouseListener{
            public void mouseClicked(MouseEvent e){
                //get component
                JPanel tempBackgroundJP = new JPanel();
                tempBackgroundJP = (JPanel)e.getComponent();
                System.out.println("Background Panel Clicked");
                //change component colour
                if(selectedComponent == null){
                    selectedComponent = tempBackgroundJP;
                else{
                    changeColour((JPanel)selectedComponent, false);
                    selectedComponent = tempBackgroundJP;
                changeColour((JPanel)selectedComponent, true);
                //set background URL
                cssGenerator.setBackground(tempBackgroundJP.getName());
            public void mousePressed(MouseEvent e){
            public void mouseReleased(MouseEvent e){
            public void mouseEntered(MouseEvent e){
            public void mouseExited(MouseEvent e){
    }JApplet Class, this is what I plugged the GUI into after I made the change from Application to JApplet.
    public class AppletTest extends JApplet{
        public void init() { 
            System.out.println("Creating GUI");
            AppletGUI theGUI = new AppletGUI();
            theGUI.setVisible(true);
            Container content = getContentPane();
            content.setBackground(Color.white);
            content.setLayout(new FlowLayout());
            content.add(theGUI);
            AppletGUI theGUI = new AppletGUI();
            theGUI.setVisible(true);
            setContentPane(theGUI);
            System.out.println("GUI Displayed");
        public static void main(String[] args){
            AppletTest at = new AppletTest();
            at.init();
            at.start();
    }The CSS Generator Class. This exists because once I have the basic program working I intend to expand upon it and add multiple tabs to the GUI, each one allowing the user to change different style options. Each style option to be changed will be changed wit ha different method in this class.
    public class CSSGenerator {
        //Variables
        String background = "";
        ArrayList<String> backgroundCSS;
        //Flags
        boolean backgroundChanged = false;
        //Sets and Gets
        //For Variables
        public void setBackground(String theBackground){
            background = theBackground;
        public String getBackground(){
            return background;
        //For Flags
        public void setBackgroundChanged(boolean isBackgroundChanged){
            backgroundChanged = isBackgroundChanged;
        public boolean getBackgroundChanged(){
            return backgroundChanged;
        //background generator
        public ArrayList<String> backgroundGenerator(String backgroundURL){
            //get the URL for the background
            backgroundURL = background;
            //creat a new array list of strings
            ArrayList<String> backgroundCSS = new ArrayList<String>();
            //add the strings for the background options to the array list
            backgroundCSS.add("body");
            backgroundCSS.add("{");
            backgroundCSS.add("background-image: url(" + backgroundURL + ");");
            backgroundCSS.add("background-color: #ff0000");
            backgroundCSS.add("}");
            return backgroundCSS;
        //Write CSS to File
        public void outputCSSFile(){
            try{
                //Create CSS file
                System.out.print("creating file");
                FileWriter cssWriter = new FileWriter("C:/Documents and Settings/Gwilym/My Documents/Applet Data/CustomStyle.css");
                System.out.print("file created");
                System.out.print("creating buffered writer");
                BufferedWriter out = new BufferedWriter(cssWriter);
                System.out.print("buffered writer created");
                //check which settings have been changed
                //check background flag
                if(getBackgroundChanged() == true){
                    System.out.print("retrieving arraylist");
                    ArrayList<String> tempBGOptions = backgroundGenerator(getBackground());
                    System.out.print("arraylist retrieved");
                    int j = tempBGOptions.size();
                    for(int i = 0; i < j ; i++){
                        System.out.print("writing to the file");
                        out.write(tempBGOptions.get(i));
                        out.newLine();
                        System.out.print("written to the file");
                out.close();
            }catch (Exception e){//Catch exception if any
                System.out.println("Error: Failed to write CSS file");
        /** Creates a new instance of CSSGenerator */
        public CSSGenerator() {
    }The Backgrounds Class. This class exists because I didnt want there to just be a hardcoded lsit of backgrounds, I wanted it to be possible to add new ones to the list without simply lettign users upload their own images (since the intended users are kids and this sharepoint site is used for educational purposes, I dont want them uplaoded inapropraite backgrounds) but I do want the site admin to be able to add more images to the list. for this reason the backgrounds are taken from a list in a text file that will be stored in the same location as the applet, the file specifies the background name, where it is stored, and where a thumbnail image is stored.
    public class Backgrounds {
        //Array Lists
        private ArrayList<JPanel> backgroundsList;
        private ArrayList<String> backgroundsData;
        //Set And Get Methods
        public ArrayList getBackgroundsList(){
            return backgroundsList;
        //ArrayList Population Methods
        public void populateBackgroundsData(){
            //decalre the input streams and create a new fiel hat points to the BackgroundsData file
            File backgroundsDataFile = new File("C:/Documents and Settings/Gwilym/My Documents/Applet Data/BackgroundsData.txt");
            FileInputStream backgroundsFIS = null;
            BufferedInputStream backgroundsBIS = null;
            DataInputStream backgroundsDIS = null;
            try {
                backgroundsFIS = new FileInputStream(backgroundsDataFile);
                backgroundsBIS = new BufferedInputStream(backgroundsFIS);
                backgroundsDIS = new DataInputStream(backgroundsBIS);
                backgroundsData = new ArrayList<String>();
                String inputtedData = null;
                //loops until it reaches the end of the file
                while (backgroundsDIS.available() != 0) {
                    //reads in the data to be stored in an array list
                    inputtedData = backgroundsDIS.readLine();
                    backgroundsData.add(inputtedData);
            //TESTING
            System.out.println("\n\nTESTING: populateBackgroundsData()");
            int j = backgroundsData.size();
            for(int i = 0; i < j; i++){
                System.out.println("Index " + i + " = " + backgroundsData.get(i));
            System.out.println("\n\n");
            //close all stremas
            backgroundsFIS.close();
            backgroundsBIS.close();
            backgroundsDIS.close();
            } catch (FileNotFoundException e) {
                System.out.println("Error: File Not Found");
            } catch (IOException e) {
                System.out.println("Error: IO Exception Thrown");
        public void populateBackgroundsList(){
            backgroundsList = new ArrayList<JPanel>();
            int j = backgroundsData.size();
            System.out.println("number of backgrounds = " + j);
            backgroundsList = new ArrayList<JPanel>();
            for(int i = 0; i < j; i++){
                String tempBackgroundData = backgroundsData.get(i);
                JPanel backgroundJP = new JPanel(new GridLayout(1,2));
                JLabel backgroundNameJL = new JLabel();               
                JLabel backgroundIconJL = new JLabel();
                //split the string string and egt the background name and URL
                String[] splitBGData = tempBackgroundData.split(",");
                String backgroundName = splitBGData[0];
                String backgroundURL = splitBGData[1];
                String backgroundIcon = splitBGData[2];
                System.out.println("\nbackgroundName = " + backgroundName);
                System.out.println("\nbackgroundURL = " + backgroundURL);
                System.out.println("\nbackgroundIcon = " + backgroundIcon + "\n");
                backgroundNameJL.setText(backgroundName);
                backgroundIconJL.setIcon(new javax.swing.ImageIcon(backgroundIcon));
                backgroundJP.add(backgroundNameJL);
                backgroundJP.add(backgroundIconJL);
                backgroundJP.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
                //Name the JP as the background URL so it can be found
                //May be useful sicne the data file may need to contain 3 fields in future
                //this is incase the preview image (icon) is different from the acctual background
                //most liekly in the case of more complex ppictures rather then repeating patterns
                backgroundJP.setName(backgroundURL);
                //Add the JP to the Array List
                backgroundsList.add(backgroundJP);
            //TESTING
            System.out.println("\n\nTESTING: populateBackgroundsList()");
            j = backgroundsList.size();
            for(int i = 0; i < j; i++){
                System.out.println("Index " + i + " = " + backgroundsList.get(i));
            System.out.println("\n\n");
    }So thats my program so far, if theres anythign that needs clarifying then please jsut ask. Thank you very much for the help!

  • Can't get scroll panes to scroll

    Hi,
    I have tabbed pane which have scroll panes which have (for each) a pane that has a known number of JLabels. The size of the tabbed pane and scroll panes are fixed, but the size of panes that are contained in them changes. I expected that when the size of panes become bigger then the size of the scroll pane a scroll bar would occur and do its job. But that does not happen. I use setSize method to set the size of the panes(not the scroll panes), which works fine.( I displayed the pane in a seperate window to check if it works.)
    Have any ideas what I am missing?

    My apologies.
    I am using NetBeans, and didn't change the code it created for GUI. I am inclined to beleive that it does not make errors when creating GUI components.
    Here is the method I use to populate one pane.
        public void listOffline() {
            // Clear the panel and set its size.
               // offlinePanel is the pane inside the scrollpane.
               offlinePanel.removeAll();
            offlinePanel.setSize(200, 20*offlineList.size());
            //offlinePane.setSize(200, 20*offlineList.size());
            // I need a list of strings to display.
            String[] ListString= arrayToStr(offlineList);
            int au=0;
            JLabel tempLabel;
            // Populate the list.
            for(int ii=0; ii < ListString.length; ii++) {
                // Add item number.
                if (ii%2 == 0){
                      tempLabel = new JLabel((ii/2 + 1) + ". " + ListString[ii]);
                 else {
                      tempLabel=new JLabel(ListString[ii]);
                offlinePanel.add(tempLabel);
                tempLabel.setLocation(20,20*ii);
                tempLabel.setSize(200,20);
                // Name is in blue.
                if(au%2==0) {
                    tempLabel.setForeground(java.awt.Color.BLUE);
                // Address is in green.
                else {
                    tempLabel.setForeground(new java.awt.Color(0,140,0));
                    tempLabel.setText("ftp://" + tempLabel.getText());
                    final String temp = tempLabel.getText();
                    // Open address in default browser if clicked.
                    tempLabel.setCursor(java.awt.Cursor.getPredefinedCursor(12));
                    tempLabel.addMouseListener(new java.awt.event.MouseAdapter() {
                        @Override
                        public void mouseClicked(java.awt.event.MouseEvent evt) {
                            try {
                                Runtime.getRuntime().exec(new String[]{"cmd", "/c", "start " + temp});
                            catch (Exception e) {
                                JOptionPane.showMessageDialog(null, "Error opening browser.");
                au++;
            ListString = null;
        }Edited by: acsabir on Oct 23, 2008 1:50 AM

  • Updating a Scroll Pane

    Hi!
    Im a newbie to swing so hopefully theres a simple solution to this.
    Im beginning with a JScrollPane that has no data in it and is presented as such. However, when the relevant data has been selected i want to populate the scrollpane with the extracted data.
    I ve started off with an empty JList that i ve instantiated in the constructor and placed in the JScrollPane. When the relevant button is pressed the list is updated with the new data, but im not sure how i can get also update scrollpane with the new list, with the results shown on screen.
    Any help or code on how to do this would be much appreciated. Thanks in advance for any help.
    Zidane

    For this situation Frist u take a JScrollPane
    and take a JList in the JScrollPane when the
    element is added in the list it will atomaticaly
    give the effect
    this code help for list and Scroll Pane
    Hope this will help you
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class ListDemo extends JFrame
                          implements ListSelectionListener {
        private JList list;
        private DefaultListModel listModel;
        private static final String hireString = "Hire";
        private static final String fireString = "Fire";
        private JButton fireButton;
        private JTextField employeeName;
        public ListDemo() {
            super("ListDemo");
            listModel = new DefaultListModel();
            listModel.addElement("Alison Huml");
            listModel.addElement("Kathy Walrath");
            listModel.addElement("Lisa Friendly");
            listModel.addElement("Mary Campione");
            //Create the list and put it in a scroll pane
            list = new JList(listModel);
            list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            list.setSelectedIndex(0);
            list.addListSelectionListener(this);
            JScrollPane listScrollPane = new JScrollPane(list);
            JButton hireButton = new JButton(hireString);
            hireButton.setActionCommand(hireString);
            hireButton.addActionListener(new HireListener());
            fireButton = new JButton(fireString);
            fireButton.setActionCommand(fireString);
            fireButton.addActionListener(new FireListener());
            employeeName = new JTextField(10);
            employeeName.addActionListener(new HireListener());
            String name = listModel.getElementAt(
                                  list.getSelectedIndex()).toString();
            employeeName.setText(name);     
            //Create a panel that uses FlowLayout (the default).
            JPanel buttonPane = new JPanel();
            buttonPane.add(employeeName);
            buttonPane.add(hireButton);
            buttonPane.add(fireButton);
            Container contentPane = getContentPane();
            contentPane.add(listScrollPane, BorderLayout.CENTER);
            contentPane.add(buttonPane, BorderLayout.SOUTH);
        class FireListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                //This method can be called only if
                //there's a valid selection
                //so go ahead and remove whatever's selected.
                int index = list.getSelectedIndex();
                listModel.remove(index);
                int size = listModel.getSize();
                if (size == 0) {
                //Nobody's left, disable firing.
                    fireButton.setEnabled(false);
                } else {
                //Adjust the selection.
                    if (index == listModel.getSize())//removed item in last position
                        index--;
                    list.setSelectedIndex(index);   //otherwise select same index
        //This listener is shared by the text field and the hire button
        class HireListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                //User didn't type in a name...
                if (employeeName.getText().equals("")) {
                    Toolkit.getDefaultToolkit().beep();
                    return;
                int index = list.getSelectedIndex();
                int size = listModel.getSize();
                //If no selection or if item in last position is selected,
                //add the new hire to end of list, and select new hire.
                if (index == -1 || (index+1 == size)) {
                    listModel.addElement(employeeName.getText());
                    list.setSelectedIndex(size);
                //Otherwise insert the new hire after the current selection,
                //and select new hire.
                } else {
                    listModel.insertElementAt(employeeName.getText(), index+1);
                    list.setSelectedIndex(index+1);
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                if (list.getSelectedIndex() == -1) {
                //No selection, disable fire button.
                    fireButton.setEnabled(false);
                    employeeName.setText("");
                } else {
                //Selection, update text field.
                    fireButton.setEnabled(true);
                    String name = list.getSelectedValue().toString();
                    employeeName.setText(name);
        public static void main(String s[]) {
            JFrame frame = new ListDemo();
            frame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
            frame.pack();
            frame.setVisible(true);
    }

  • Dynamic content in scroll pane component

    As far as I can see, the contentPath for a scroll pane
    component can only point to a movie clip in the library, not to an
    instance on stage. Does this mean that the content can only be
    something created during authoring with no possibility of modifying
    it in Actionscript?

    No, I had no reply and eventually wrote my own scroll pane
    solution which allows me to directly modify the pane's content with
    ActionScript and update the scroll bar to reflect any change in the
    content's size. I'm puzzled by the help file's example in
    ScrollPane.refreshPane() because it describes a senario where:
    "for example, you've loaded a form into a scroll pane and an
    input property (for example, a text field) has been changed by
    ActionScript. In this case, you would call refreshPane() to reload
    the same form with the new values for the input properties."
    Which implies that you can use ActionScript to change the
    content then reload it. The help file on ScrollPane.contentPath is
    not very clear about what content can be used but appears to say
    that the only content types allowed are: a SWF or JPEG loaded via
    its URL or a symbol in the current library. I don't see how you
    could use ActionScript to change any of these. I've tried
    specifying an on-stage instance as the content but that
    fails.

  • Specifying text font in a scroll pane

    Below is a fragment of code that attempts to display text in a scroll pane. Basically this works OK, except for the following:
    1. Changing the font doesn't seem to make any difference. I tried "Arial", as shown, and "Curier", the display looks identical in both cases.
    2. Multiple blank spaces are replaced by a single blank space. So that "Baa baa" is displayed as "Baa baa".
    I would like to be able to display messages with many lines of text in a scroll pane preserving the format if possible, which relies on the blank spaces. I hope you can suggest how to do this better.
    Thans for you help.
    Miguel
        JLabel label = new JLabel(text);
        Font font = new Font("Arial",Font.PLAIN,12);
        label.setFont(font);
        JScrollPane scrollPane = new JScrollPane(label);

    try using a textArea instead of a label and include tabs for your multiple spaces.
    import java.awt.Font;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    public class FontTest extends JFrame {
         public FontTest() {
              super("Font Testing");
              String text = "This is \t a \t test";
              JTextArea text3 = new JTextArea();
              text3.setText(text);
              Font font = new Font("Courier",Font.PLAIN,12);   
              text3.setFont(font);   
              JScrollPane scrollPane = new JScrollPane(text3);
              getContentPane().add(scrollPane);
              setSize(400, 200);
              setVisible(true);
         public static void main(String[] args) {
              FontTest app = new FontTest();
    }

  • Scroll pane not working in Internet Explorer

    hi all,
    I have used 'scroll pane' component in flash8 to load
    external swf files into the website. Its working fine in firefox
    but completely fails in Internet Explorer ! Could anyone help me to
    solve this please?
    here is the link
    http://www.talkingpebbles.com/development/virgincomics/index.html
    click
    here to see the website under construction
    thanks
    TP

    I see in a lot of forums from 2004 that this is an issue !
    and Macromedia hasnt done anything about it till now is surprising
    and frustrating! and no help to solve it either! that is ridiculous
    now!
    TP

Maybe you are looking for

  • Error while running OA Framework (HelloWorld.jpr) in Jdeveloper 10g

    Hi all, I have a created sample HelloWorld Page thru Jdeveloper 10g with OA Extension on R12 Instance. I am running to following error when I run the page from Jdeveloper 10g. Can you please help me out in resolving this issue? I would really appreci

  • HT201335 how to use it in macbook pro please?

    I want to connect the airplay mirroring in my macbook pro but its not working i chicked the wifi and everythig but i cant find the airplay mirroring option in the display setting what to do please???

  • HT4623 How can I deactivate Voicemail (Etisalat, United Arab Emirates).

    Can someone please let me know how I can deactivate Voicemail? I am residing in Dubai, United Arab Emirates. Several times I have unknowingly pressed the voice mail and it gets billed even though I have not subscribed for this service. Thanks

  • IPhoto quits unexpectedly and won't let me access photos

    My iPhoto program has just started acting oddly; when I hook up a camera or my iPhone, it won't start up; just quits. And if I start it up from the computer, as soon as I click on a photo or album title or caption, it quits. I am using the latest ver

  • Changing Description of field globally

    If we need to rename one field for e.g: Project Code, it has to be done in each and every form and user wise where as the requirement is of changing the description of field globally for all the users.