Drawing in JPanel within JApplet

Hi, having problems drawing in jpanel that is within japplet.
My code follows:
* TestApplet.java
* @author WhooHoo
//<applet code="TestApplet.class" width="400" height="250"></applet>
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Graphics;
import javax.swing.JButton;
public class TestApplet extends javax.swing.JApplet implements ActionListener {
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel1;
private Graphics g;
private javax.swing.JButton btnTest;
/** Creates new form Cafe */
public TestApplet() {
public void init() {
jPanel1 = new javax.swing.JPanel();
btnTest = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
btnTest.setText("test");
jPanel1.add(btnTest);
getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
jPanel2.setBorder(new javax.swing.border.TitledBorder("Draw"));
getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
btnTest.addActionListener(this);
jPanel2.setOpaque(false);
g=jPanel2.getGraphics();
/** Invoked when an action occurs.
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equalsIgnoreCase("test"))
System.out.println("test");
g.setColor(java.awt.Color.BLACK);
     g.drawString("testing",50,50);
     g.drawString("testing",50,100);
     g.drawString("testing",50,150);
     g.drawString("testing",50,200);
     g.drawString("testing",50,250);
public void destroy()
g.dispose();
When this code is run the applet seems to run fine but when the button is pressed, nothing is drawn in jpanel. Can anyone see what the problem is and suggest a fix. I need to be able to pass graphics obj around to other methods to draw in the other methods also. Testing will not dispaly anywhere in applet or frame.
plz email or post any suggestions.

but if I can get this to workYou can get this to work, here is the working code:
import java.awt.event.*;
import java.awt.Graphics;
import javax.swing.*;
import java.awt.*;
public class TestApplet extends JApplet implements ActionListener {
     private JPanel jPanel2,jPanel1;
     private javax.swing.JButton btnTest;
     String string1 = "";
     public TestApplet() {
     public void init() {
          jPanel1 = new JPanel();
          btnTest = new JButton();
          jPanel2 = new JPanel(){
               public void paintComponent(Graphics g) {
                    g.setColor(java.awt.Color.BLACK);
                    g.drawString(string1,50,50);
                    g.drawString(string1,50,100);
                    g.drawString(string1,50,150);
                    g.drawString(string1,50,200);
                    g.drawString(string1,50,250);
          btnTest.setText("test");
          jPanel1.add(btnTest);     
          getContentPane().add(jPanel1, BorderLayout.NORTH);
          jPanel2.setBorder(new javax.swing.border.TitledBorder("Draw"));
          getContentPane().add(jPanel2, BorderLayout.CENTER);
          btnTest.addActionListener(this);
          jPanel2.setOpaque(false);
     public void actionPerformed(ActionEvent e) {
          if (e.getActionCommand().equalsIgnoreCase("test"))
               System.out.println("test");
               string1 = "testing";
               jPanel2.repaint();
     public void destroy(){}
}Unfortunately all painting to a component must happen inside the paint method. I don't know if what you ask is possible. I try to figure it out. Maybe someone else has an answer.
Pandava

Similar Messages

  • Please help with a drawing on JPanel in a background.

    Hello everybody,
    I have already post this question in the main java forum and was adviced to place the question here. Since then, I have refactored the code. I need your opinion and advice.
    My task is to draw some objects on the JPanel or some other components and to place the names to the objects, for example squares, but later, from the thread. Because it can take some time, untill the names will be avaliable.
    So, I refactored the code I post before http://forum.java.sun.com/thread.jspa?threadID=5192586&tstart=15
    And now, it draws on layers and from thread on resize, with some imitating interval.
    Is it a good approach I use, is there a better way, to draw on JPanel, after some objects were already painted.
    Here is my sample, try to resize window:
    package test;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.awt.event.ComponentEvent;
    import java.awt.event.ComponentListener;
    import java.awt.geom.Rectangle2D;
    import javax.swing.JFrame;
    import javax.swing.JLayeredPane;
    import javax.swing.JPanel;
    public class Painter extends JFrame implements ComponentListener{
         private static final long serialVersionUID = 1L;
         private ThreadPainter threadPainter;
         JPanel panel = new JPanel() {
              private static final long serialVersionUID = 1L;
              @Override
              protected void paintComponent(Graphics g) {
                   super.paintComponent(g);
                   System.out.println("repaint");
                   Graphics2D g2d = (Graphics2D) g;
                   g2d.setColor(Color.gray);
                   g2d.fillRect(0, 0, 800, 600);
                   g2d.setColor(Color.white);
                   for (int i = 0; i < 6; i++) {
                        Rectangle2D rec2d = new Rectangle2D.Double(10 + i * 100,
                                  10 + i * 100, 10, 10);
                        g2d.fill(rec2d);
                        g2d.drawString("Square " + i, 10 + i * 100 + 20, 10 + i * 100);
                   // start thread to paint some changes later
                   if (threadPainter == null) {
                        threadPainter = new ThreadPainter();
                        threadPainter.start();
         JPanelTest panel1 = new JPanelTest();
         public class JPanelTest extends JPanel {
              private static final long serialVersionUID = 1L;
              private int times = 0;
              @Override
              protected void paintComponent(Graphics g) {
                   super.paintComponent(g);
                   Graphics2D g2d = (Graphics2D) g;
                   g2d.setColor(Color.red);
                   System.out.println("repaint panel test");
                        System.out.println("repaitn times");
                        g2d.drawString("Square " + times, 10 + times * 100 + 20, 10 + times * 100);
              public void repaintMethod(int times) {
                   this.times = times;
                   this.repaint(times * 100 + 20, times * 100, 300,300);
         public class ThreadPainter extends Thread {
              private boolean stop = false;
              @Override
              public void run() {
                   while (!stop) {
                        int cnt = 0;
                        for (int i = 0; i < 6; i++) {
                             System.out.println("do task");
                             panel1.repaintMethod(i);
                             // load data, do calculations
                             try {
                                  // emulate calcilation
                                  Thread.sleep(1000);
                             } catch (InterruptedException e) {
                                  e.printStackTrace();
                             if (stop) {
                                  break;
                             cnt++;
                        if (cnt == 6) {
                             stopThread();
              public void stopThread() {
                   this.stop = true;
         public Painter() {
              this.setLayout(new BorderLayout());
              JLayeredPane pane = new JLayeredPane();
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              this.setLocation(new Point(100, 100));
              this.setPreferredSize(new Dimension(800, 600));
              this.panel.setOpaque(false);
              this.panel1.setOpaque(false);
              pane.setOpaque(false);
              pane.add(panel, JLayeredPane.DEFAULT_LAYER);
              pane.add(panel1, new Integer(
                        JLayeredPane.DEFAULT_LAYER.intValue() + 1));
              this.add(pane, BorderLayout.CENTER);
              panel.setBounds(new Rectangle(0, 0, 800, 600));
              panel1.setBounds(new Rectangle(0, 0, 800, 600));
              this.addComponentListener(this);
         public static void main(String[] args) {
              Painter painter = new Painter();
              painter.pack();
              painter.setVisible(true);
         @Override
         public void componentHidden(ComponentEvent e) {
              // TODO Auto-generated method stub
         @Override
         public void componentMoved(ComponentEvent e) {
              // TODO Auto-generated method stub
         @Override
         public void componentResized(ComponentEvent e) {
              if (threadPainter != null) {
                   threadPainter.stopThread();
                   threadPainter = new ThreadPainter();
                   threadPainter.start();
         @Override
         public void componentShown(ComponentEvent e) {
              // TODO Auto-generated method stub
    }

    Hello camickr,
    thanks for your answers.
    It sounds like you are trying to add a component and
    descriptive text of this component to a panel. So the
    question is why are you overriding paintComponent()
    method on your main panel and why are you using a
    Thread.JLabel is not a good way I think, because of the performance. Think about 1000 labels on the panel. And the text can have different style, so drawString method is better here.
    Create a component that draws your "shape" and then
    add that component to the main panel that uses a null
    layout. That means you need to specify the bounds of
    the component. Then you can add a JLabel containing
    the releated text of the component. If you don't know
    the text then it can always be updated with the
    setText() method in the future. Also, the foreground
    can be updated as well.If it would be lable, I could update Text as us say and JLabels would be perfect. In this case, JLabels are not what I need.
    You said the names will not be available right away.
    Well then you don't start a thread to schedule the
    repainting of the names since you don't know exactly
    when the name will be available. You wait until you
    have the names and then simple use the setText()
    method.I have decided this way.
    Draw all objects on the panel in different layers, for different type of objects.
    Get names and make some calculations, for example, optimal position of the text on the panel (in Thread) and after it repaint();
    Repaint draw all objects, but now it have the names, which will be added too.
    The requirement is: thousand of objects on the panel
    Different type of ojbects should be drawn in different layers
    Names should be added to the objects and maybe some other drawings (showing state). Name and drawing can be done later, but should be added dynamically, after all calculation are done.

  • Resize of Drawing in JPanel

    Hi,
    I am looking for some ideas on how to resize a drawing in JPanel.
    I wanted to increase its width and height at run time by dragging its end points (any direction).
    One more thing is how do I add text to the drawing at run time? Is this possible?
    My idea is to develop an application similar to MS-Word where we can add few drawings and add text to them.
    Any help would be great.
    Mathew

    The drawing code has to be written in ratios. Don't draw from x1, y1, to x2, y2 -- draw from (left + .3*width, top + .3 * height) to . . . Then the drag gesture should give you new width and height values, and you can just repaint().

  • Preserve aspect ratio of JPanel size within JApplet

    Hi, currently, I have a JPanel component, which will be placed at the center of JApplet (This JApplet is BorderLayout).
    I wish to preserve the aspect ratio of the JPanel to square (width equal to height) even when the JApplet size is changed.
    I overriden the getPreferredSize, getMinimumSize and getMaximumSize of JPanel as follow:
    import java.awt.*;
    * @author  yccheok
    public class NewJPanel extends javax.swing.JPanel {
        /** Creates new form NewJPanel */
        public NewJPanel() {
            initComponents();
            this.setBackground(Color.RED);
        public Dimension getMinimumSize() {
            Dimension dimension;
            dimension = super.getMinimumSize();
            Dimension newDimension;
            if(dimension.getWidth() < dimension.getHeight()) {
                newDimension = new Dimension((int)dimension.getWidth(), (int)dimension.getWidth());
            else {
                newDimension = new Dimension((int)dimension.getHeight(), (int)dimension.getHeight());
            System.out.println("newDimension="+newDimension);
            return newDimension;
        public Dimension getMaximumSize() {
            return getMinimumSize();
        public Dimension getPreferredSize() {
            return getMinimumSize();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            setLayout(new java.awt.BorderLayout());
        // </editor-fold>                       
        // Variables declaration - do not modify                    
        // End of variables declaration                  
    }whereas my JApplet code is as follow:
    import java.awt.*;
    import javax.swing.*;
    * @author yccheok
    public class NewJApplet extends javax.swing.JApplet {
        /** Creates a new instance of NewJApplet */
        public NewJApplet() {
        public void init()
            this.getContentPane().setLayout(new BorderLayout());
            this.getContentPane().add(new NewJPanel(), BorderLayout.CENTER);
    }However, I realize none of the JPanel's getPreferredSize, getMinimumSize or getMaximumSize is called. Am I doing something wrong?
    Thank you very much!

    You probably should create your own layout manager

  • 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]

  • Draw a JPanel in a Image

    Hi,
    I'd like to draw what is in my JPanel into a image to export it. But When I try to do that , I have problems. I put my code to be more clear:
    // comp is the JPanel
    comp.setDoubleBuffered(false);
    JFrame frame = new JFrame();
    frame.setContentPane(comp);
    frame.pack();
    Dimension size = comp.getSize();
    Image image = comp.createImage(size.width,size.height);
    final Graphics g = image.getGraphics();
    g.setClip(0,0,size.width,size.height);
    try
    // Paint the Swing component into the image
    SwingUtilities.invokeAndWait(new Runnable()
    public void run()
    comp.paint(g);
    catch (Exception x) { x.printStackTrace(); }
    finally
    g.dispose();
    frame.dispose();
    The problem is that I export into GIF this image, but if I don't show the frame:
    frame.show(); at least one time, the image is bad: it has a black background. I tried to set the background, but nothing works execpt showing the frame.
    If you could help me, I would be great.
    Vincent

    to diesel22
    http://onesearch.sun.com/search/developers/index.jsp?col=devforums&qp=&qt=%2Bprint+%2Bshow

  • Drawing with sprites within a bounding box

    Hi,
    I'm using Sprites to draw fairly large graphs. To enable me
    to do this interactively, I embed the nodes/edges in the graph
    within a UIComponent defined in the mxml file. I also would like
    the UIComponent to be within a panel, and therefore the contents of
    that compnent should not be visibly outside that panel.
    The problem is that I am unable to define the bounds for this
    UIComponent, and so the graph occupies most of the screen area
    beyond the containing panel. (height/width attributes for the
    UIComponent do not address this).
    What is the appropriate way to have the graph shown in a
    canvas with limited arae (with scrollbars if the contained graph is
    bigger than that area) so that it does not overflow the desired
    display area?
    In the code below, for example, I'd like the UIComponent (to
    which I add Sprite Children) to have bounds so that it does not
    display all over the screen.
    Thanks a lot.

    Set a mask.

  • How do i draw on JPanel?

    Hi all,
    Is it possible to draw inside swing JPanel? If so, how to draw, say, a rectangle inside a JPanel? Thanks a bunch!
    mp

    JPanel, is a generic light weight component. By Default, they dont paint any thing except for the background, you can easily add borders and customise their painting.

  • Web pictures through JPanel in JApplet

    Hi there!
    I want to put my Java game (created in JPanel) online through JApplet.
    I have put the images & sounds for that online. (e.g. "http://bla.bla.com/images/image.gif").
    Now if I run the program in JFrame, it is loading and working fine! But in Applet, I am getting security warnings/errors. Can anyone help please?
    Here's the sample code:
    public class Game extends JPanel {
    URL url = null;
    URLConnection con = null;
    //Constructor{
    try{
    url = new URL("http://....../image.gif");
    conn = url.openConnection();
    }catch(Exception e){/Message}
    ImageIcon img = new ImageIcon(url);
    }

    Hi there!
    One more similar problem... :(
    I want to put my Java game (created in JPanel) online through JApplet.
    I have put the images & sounds for that online. (e.g. "http://bla.bla.com/images/image.gif").
    Now if I run the program in JFrame, it is loading and working fine! But in Applet, I am getting security warnings/errors. Can anyone help please?
    Here's the sample code:
    public class Game extends JPanel {
    URL url = null;
    URLConnection con = null;
    //Constructor{
    try{
    url = new URL("http://....../image.gif");
    conn = url.openConnection();
    }catch(Exception e){/Message}
    ImageIcon img = new ImageIcon(url);
    }

  • Communicating between JPanel and JApplet

    Ok... I have a JApplet that declares a JPanel in it that uses CardLayout. The cards of the CardLayout compose of JPanels. One of them is like a registration form with JTextFields and a JButton to submit. The submit button has to check to make sure all the fields are filled in correctly and then proceed onwards to the next card (JPanel). The problem comes here: How can the JPanel communicate to the CardLayout which was declared in the JApplet to move to the next card?
    I have tried creating the submit button with an actionlistener in the JApplet and passing it to the JPanel, but that doesnt work because of conflicting actionlisteners. Any suggestions?

    Do what you where going to do with the ActionListeners, but with another interface that you create.
    For example:
    public interface FormListener {
         public void formOk();
         public void formWrong();
    /**********  Another file  ***************/
    public class FormPanel extends JPanel{
         FormListener form_list = null;
         public void addFormListener(FormListener l){
              form_list = l;
         public boolean validateForm(){
              /*here you validate your form entires*/
         public void actionListener(ActionEvent e){
              if(e.getSource() == mySubmitButton){
                   if(validateForm())
                        form_list.formOk();
                   else
                        form_list.formWrong();
    /**********  Another file  ***************/
    public class MyApplet extends Applet implements FormListener{
         FormPanel form_panel;
         public void init(){
              form_panel.addFormListener(this);
         public void formOk(){
              /* Do what you want to do when the form entires are OK*/
         public void formWrong(){
              /* Do what you want to do when the form entries are wrong*/
    al912912

  • Ridiculously dumb question about drawing in JPanel

    Howdy everyone,
    I gotta really stupid question that I cant figure out the answer to. How do I draw an image to a JPanel, when my class inherits from JFrame?
    Thanks,
    Rick

    Ok,
    Problem. The image isnt showing up in the Frame I set up for it. Heres my code. Im trying to get this image to show up in a scollable window. Can anyone tell what the problem with this code is??
    JPanel imgPanel= new JPanel(){
    protected void paintComponent(Graphics g){
    super.paintComponent(g);
    g.drawImage(getToolkit().createImage(imstr),imgw,imgh,this);
    imgPanel.setVisible(true);
    this.getContentPane().setLayout(new BorderLayout());
    this.getContentPane().add(new JScrollPane(imgPanel));
    this.setVisible(true);
    Any ideas?
    Thanks
    Rick

  • How to draw a JPanel in an offscreen image

    I am still working on painting a JPanel on an offline image
    I found the following rules :
    - JPanel.setBounds shall be called
    - the JPanel does not redraw an offline image, on should explicitly override paint()
    to paint the children components
    - the Children components do not pain, except if setBounds is called for each of them
    Still with these rules I do not master component placement on the screen. Something important is missing. Does somebody know what is the reason for using setBounds ?
    sample code :
    private static final int width=512;
    private static final int height=512;
    offScreenJPanel p;
    FlowLayout l=new FlowLayout();
    JButton b=new JButton("Click");
    JLabel t=new JLabel("Hello");
    p=new offScreenJPanel();
    p.setLayout(l);
    p.setPreferredSize(new Dimension(width,height));
    p.setMinimumSize(new Dimension(width,height));
    p.setMaximumSize(new Dimension(width,height));
    p.setBounds(0,0,width,height);
    b.setPreferredSize(new Dimension(40,20));
    t.setPreferredSize(new Dimension(60,20));
    p.add(t);
    p.add(b);
    image = new java.awt.image.BufferedImage(width, height,
    java.awt.image.BufferedImage.
    TYPE_INT_RGB);
    Graphics2D g= image.createGraphics();
    // later on
    p.paint(g);
    paint method of offScreenPanel :
    public class offScreenJPanel extends JPanel {
    public void paint(Graphics g) {
    super.paint(g);
    Component[] components = getComponents();
    for (int i = 0; i < components.length; i++) {
    JComponent comp=(JComponent) components;
    comp.setBounds(0,0,512,512);
    components[i].paint(g);

    Unfortunately using pack doesn't work, or I didn't use it the right way.
    I made a test case, eliminated anything not related to the problem (Java3D, applet ...). In the
    test case if you go to the line marked "// CHANGE HERE" and uncomment the jf.show(), you have
    an image generated in c:\tmp under the name image1.png with the window contents okay.
    If you replace show by pack you get a black image. It seems there still something.
    simplified sample code :[b]
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import com.sun.j3d.utils.applet.*;
    import com.sun.j3d.utils.image.*;
    import com.sun.j3d.utils.universe.*;
    import java.io.*;
    import java.awt.image.*;
    import javax.imageio.*;
    public class test {
    private static final int width=512;
    private static final int height=512;
    public test() {
    JPanel p;
    BorderLayout lay=new BorderLayout();
    java.awt.image.BufferedImage image;
    // add a JPanel with a label and a button
    p=new JPanel(lay);
    p.setPreferredSize(new Dimension(width,height));
    JLabel t=new JLabel("Hello");
    t.setPreferredSize(new Dimension(60,20));
    p.add(t,BorderLayout.NORTH);
    p.setDebugGraphicsOptions(DebugGraphics.LOG_OPTION );
    // show the panel for debug
    JFrame jf=new JFrame();
    jf.setSize(new Dimension(width,height));
    jf.getContentPane().add(p);
    [b]
    // CHANGE HERE->
    jf.pack();
    //jf.show();
    // create an off screen image
    image = new java.awt.image.BufferedImage(width, height,
    java.awt.image.BufferedImage.TYPE_INT_RGB);
    // paint JPanel on off screen image
    Graphics2D g= image.createGraphics();
    g.setClip(jf.getBounds());
    System.err.println("BEFORE PAINT");
    jf.paint(g);
    System.err.println("AFTER PAINT");
    // write the offscreen image on disk for debug purposes
    File outputFile = new File("c:\\tmp\\image1.png");
    try {
    ImageIO.write(image, "PNG", outputFile);
    } catch (Exception e) {
    System.err.println(e.getMessage());
    g.dispose();
    jf.dispose();
    public static void main(String[] args) {
    test t=new test();
    }

  • Drawing a picture within JFrame when I've already created a JFrame

    Hi everyone,
    I was wondering if you could help me out with this problem I'm getting. I'm creating a program to simulate an 'elevator.' When first creating the project I created a brand new 'Java GUI Form' : 'JFrame Form'. From here I went on to drag-and-drop various command buttons and labels to create the user interface (the 'inside' of an elevator). Here is where my question comes in. On the very left of my interface I want to have the program draw a simulation of a box (the elevator) moving up and down with the 'floor numbers' the user pushes. However i don't know how to access the coding of the jFrame object that I created through the design editor so i can input the coding.
    First Question: What do i have to 'write' that would force that box to print into the current JFrame?
    Second Question: What Code (and where do i put it) essentially 'locks' the JFrame from being resized?

    Here, maybe by putting this it might help you recognize what i'm trying to say. The code i'm trying to put in is:
    JFrame window = new JFrame ("Drawing");
            window.setBounds(200,200,700,500);
            window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            window.setVisible(true);
            Container contentPane = window.getContentPane();
            contentPane.setBackground(new Color(125, 125, 125));
            Graphics g = contentPane.getGraphics();* This is a portion of the code
    When run, this program creates a NEW JFRAME WINDOWS, i'm trying to make it run inside an already existing JFrame, whose variable Name i dont know how to find.

  • Switch Between Jpanels within a JFrame

    Hi, I am new to this java thing and I need a hand with the following problem
    I have 3 classes
    Invaders
    Game
    OptionsMenu
    Basically, you execute the program which executes Invaders, which then creates a JFrame with a border layout and adds the menu bar to the top, JPanel with either game or OptionsMenu to the center and a further JPanel to the bottom containing buttons and labels
    The specifics of the problem is I can not work out how to change between the panels in the center of the border layout in the frame created by invaders.
    When the program loads its ment to load with the options menu, which is no problem, the problem comes when I need to change the frame from the options menu to the game via a button on the options menu, the options menu passes the variables its gathered to the game constructor and it is then ment to display in the center of the border layout in the JFrame from invaders, any help would be appreciated, I have spent 2 days trying to get it to work and have not been sucessful

    I can not work out how to change between the panels in the center of
    the border layout in the frame created by invaders.Use a [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]Card Layout.

  • User-resizable JPanel within my frame?

    Hi all,
    I've got a JFrame which contains a bunch of content in FlowLayout. One of the components in my frame is a JPanel that has the potential to display a lot of content -- it's reading a webpage obtained from the user. The panel has a scroll-bar, of course, but if there is a lot of content the user would prefer to see a bigger panel.
    Does anyone know of anyway to have an embedded JPanel use draggable borders so that they can re-size the panel at will? Naturally, everything in the panel and out of the panel should respect the new dimensions, and so components surrounding the panel in flowlayout, for example, should react accordingly.
    Is this possible?
    Thanks!
    Tim

    I could do that if I made my entire content pane a series of split panes, but I don't think that wouldn't really be a reusable solution (if I misunderstand what you meant, apologies).
    What I'm hoping for is something that's a property of the JPanel component itself. That way I can insert this expandable JPanel anywhere and everything else ought to respect its resizing. If such a thing is impossible, then some solution that mimics that would be fine.
    Any thoughts?

Maybe you are looking for

  • IMessage and Facetime "waiting for activation" on iPhone4s (Brazil)

    I've had an iPhone 3GS for 3 years, had iMessage working perfectly. On march 16th, i bought an iPhone 4S from my supported carrier, TIM. Since then, I cannot activate my phone number neither in iMessage nor in Facetime. If I log in my Apple ID, both

  • Can't see new new message window

    When trying to send mail, when I attempt to open a new message window, it will not display. If I look under the window tab in the task bar, I can see that a new message window has been opened, but even if I highlight the new message, it will not disp

  • Some Interview doubts......

    Hi Gurus, Please clarify the below mentioned queries:- 1) can we use line item dimension and aggregates on the same InfoObject. 2) can we create direct and flexible update for one InfoObject. 3) How to add text to existing masterdata. 4)  For memory

  • ID-Cache Notification

    Hi All,    When I select Cache Notifications from Environment tab in ID, I am getting errors. Cache updated status is red, also the date/time is 00.00.00 00:00. But the perform Notification status is green and the date/time is set properly.    Advise

  • I need to download a copy of firefox 4.0

    I download Firefox 5.0 and it don't well with some of my computer program, so I need to download Firefox 4.0 version. How do I do that.