Drawing into a nested panel

Hello,
I have an interface consisting of several panels nested together to accept user input on the left and output a shape on the right.
I have the user input widgets set up the way I want. I am about to add the listeners and handlers to each widget. However, before I do, I want to know how to draw the shape in the panel.
My code is below. I would like to accept the user input from the entry panel and output a shape (with code yet to be added) to the displayPanel.
Again, my question is, how do I draw anything into the displayPanel?
//import the necessary java packages
import java.awt.*;   //for the awt widgets
import javax.swing.*;  //for the swing widgets
import java.awt.event.*;  //for the event handler interfaces
public class DemoShape extends JApplet
    //declare private data members of the DemoShape class
    //required control buttons
    private JTextField xShapeText, yShapeText, messageText, fontSizeText;
    private ButtonGroup shapeRadio;
    private JRadioButton rect, oval, roundRect;
    private JComboBox shapeColorDrop, fontTypeDrop, fontColorDrop;
    //declare the entry and display panel containers
    private Container entire;
    private JPanel entryPanel, displayPanel;
    //create a text buffer to house the response messge
    String sText = "";
    //declare public data members of the DemoShape class
    //init method to initialize the applet objects
    public void init()
        //arrays of string to be used later in combo boxes
        //some are used more than once
        String fonts[] = {"Dialog", "Dialog Input", "Monospaced",
                            "Serif", "Sans Serif"};
        String shapes[] = {"Rectangle", "Round Rectangle", "Oval"};   
        String colors[] = {"Black", "Blue", "Cyan", "Dark Gray",
                            "Gray", "Green", "Light Gray", "Magenta", "Orange",
                            "Pink", "Red", "White", "Yellow"};
        //declare variables to assist with the layout
        //these are the left and right justified x coordinates
        int ljX = 10; int rjX = 150;
        //this is the y coordinates for the rows
        int yRow1 = 10;     //the shape
        int yRow2 = 40;
        int yRow3 = 60;
        int yRow4 = 130;
        int yRow5 = 150;
        int yRow6 = 210;    //the message
        int yRow7 = 240;
        int yRow8 = 260;
        int yRow9 = 300;
        int yRow10 = 320;
        int yRow11 = 360;
        int yRow12 = 380;
        //these are the widths for the text boxes, drop downs
        //message entry,  big message entry and radio buttons
        int tWidth = 30; int dWidth = 100;
        int mWidth = 125; int bmWidth = 250;
        int rWidth = 125;
        //the height is universal, even for the messages!
        int height = 25;
        //set a content pane for the entire applet
        //set the size of the entire window and show the entire applet
        entire = getContentPane();
        entire.setLayout(new GridLayout(1, 2));
        entire.setSize(800,600);
        //create the entry panel and add it to the entire pane
        entryPanel = new JPanel();
        entryPanel.setLayout(null);
        entire.add(entryPanel);
        //create the display panel and add it to the entire pane
        //this will display the output
        displayPanel = new JPanel();
        displayPanel.setLayout(null);
        entire.add(displayPanel);       
        //entry panel code
        //add the form elements in the form of rows
        //the first row (label)
        JLabel entryLabel = new JLabel("Enter Shape Parameters:");
        entryPanel.add(entryLabel);
        entryLabel.setBounds(ljX, yRow1, bmWidth, height);
        //second row (labels)
        JLabel shapeTypeLabel = new JLabel("Select Shape:");
        shapeTypeLabel.setBounds(ljX, yRow2, mWidth, height);
        entryPanel.add(shapeTypeLabel);
        JLabel shapeColorLabel = new JLabel("Select Shape Color:");
        shapeColorLabel.setBounds(rjX, yRow2, mWidth, height);
        entryPanel.add(shapeColorLabel);
        //third row (entry)        
        rect = new JRadioButton("Rectangle", true);
        oval = new JRadioButton("Oval", false);
        roundRect = new JRadioButton("Round Rectangle", false);
        rect.setBounds(ljX, yRow3, rWidth, height);
        oval.setBounds(ljX, yRow3 + 20, rWidth, height);
        roundRect.setBounds(ljX, yRow3 + 40, rWidth, height);
        shapeRadio = new ButtonGroup();
        shapeRadio.add(rect);
        shapeRadio.add(oval);
        shapeRadio.add(roundRect);
        entryPanel.add(rect);
        entryPanel.add(oval);
        entryPanel.add(roundRect);       
        shapeColorDrop = new JComboBox(colors);
        shapeColorDrop.setBounds(rjX, yRow3, dWidth, height);
        shapeColorDrop.addActionListener(new testListen());
        entryPanel.add(shapeColorDrop);
        //the fourth row (labels)
        JLabel xShapeLabel = new JLabel("Enter Width:");
        xShapeLabel.setBounds(ljX, yRow4, mWidth, height);
        entryPanel.add(xShapeLabel);
        JLabel yShapeLabel = new JLabel("Enter Height:");
        yShapeLabel.setBounds(rjX, yRow4, mWidth, height);
        entryPanel.add(yShapeLabel);
        //the fifth row (entry)
        xShapeText = new JTextField("200", 3);
        xShapeText.setBounds(ljX, yRow5, tWidth, height);
        entryPanel.add(xShapeText);        
        yShapeText = new JTextField("200", 3);
        yShapeText.setBounds(rjX, yRow5, tWidth, height);
        entryPanel.add(yShapeText);
        //the sixth row (label)
        JLabel messageLabel = new JLabel("Enter Message Parameters:");
        messageLabel.setBounds(ljX, yRow6, bmWidth, height);
        entryPanel.add(messageLabel);
        //the seventh row (labels)   
        JLabel messageEntryLabel= new JLabel("Enter Message:");
        messageEntryLabel.setBounds(ljX, yRow7, mWidth, height);
        entryPanel.add(messageEntryLabel);
        //the eighth row (entry)
        messageText = new JTextField(25);
        messageText.setBounds(ljX, yRow8, mWidth, height);
        entryPanel.add(messageText);
        //the ninth row (label)
        JLabel fontTypeLabel = new JLabel("Select Font:");
        fontTypeLabel.setBounds(ljX, yRow9, mWidth, height);
        entryPanel.add(fontTypeLabel);
        JLabel fontColorLabel = new JLabel("Select Font Color:");
        fontColorLabel.setBounds(rjX, yRow9, mWidth, height);
        entryPanel.add(fontColorLabel);
        //the tenth row (entry)
        fontTypeDrop = new JComboBox(fonts);
        fontTypeDrop.setBounds(ljX, yRow10, dWidth, height);
        entryPanel.add(fontTypeDrop);       
        fontColorDrop = new JComboBox(colors);
        fontColorDrop.setBounds(rjX, yRow10, dWidth, height);
        entryPanel.add(fontColorDrop);
        //the eleventh row (label)
        JLabel fontSizeLabel = new JLabel("Select Font Size:");
        fontSizeLabel.setBounds(ljX, yRow11, mWidth, height);
        entryPanel.add(fontSizeLabel);
        //the final row (entry)
        fontSizeText = new JTextField("12", 2);
        fontSizeText.setBounds(ljX, yRow12, tWidth, height);
        entryPanel.add(fontSizeText);
        //display panel code
        //simple test for the display panel
        JLabel test = new JLabel("Display Output Here");
        test.setBounds(10, 10, 150, 25);
        displayPanel.add(test);   
        //set the applet to visible
        entire.setSize(800, 600);
        entire.setVisible(true);
    }   //end the init method
    //declare an inner class to handle the events
    private class testListen implements ActionListener
        //supply the implementation of the actionPerformed method
        //pass an event variable as the argument
        public void actionPerformed(ActionEvent e)
            //get the source of the event
            if(e.getSource() == shapeColorDrop)
                sText = "shapeColorDrop pushed!";
                JOptionPane.showMessageDialog(null, sText);
        }   //end actionPeformed method
    }   //end testListen class
}   //end DemoShape class

Ok, I realize you need a canvas to draw into. Now how to I draw into this canvas.
//import the necessary java packages
import java.awt.*;   //for the awt widgets
import javax.swing.*;  //for the swing widgets
import java.awt.event.*;  //for the event handler interfaces
public class DemoShape extends JApplet
    //declare private data members of the DemoShape class
    //declare the entry and display panel containers
    private Container entire;       //houses the entryPanel and displayCanvas
    private JPanel entryPanel;      //accepts the user entries into widgets
    private Canvas displayCanvas;   //displays the response of the user entries
    //required control buttons for the entryPanel
    private JTextField xShapeText, yShapeText, messageText, fontSizeText;
    private ButtonGroup shapeRadio;
    private JRadioButton rect, oval, roundRect;
    private JComboBox shapeColorDrop, fontTypeDrop, fontColorDrop;
    //declare public data members of the DemoShape class
    //init method to initialize the applet objects
    public void init()
        //arrays of string to be used later in combo boxes
        //some are used more than once
        String fonts[] = {"Dialog", "Dialog Input", "Monospaced",
                            "Serif", "Sans Serif"};
        String shapes[] = {"Rectangle", "Round Rectangle", "Oval"};   
        String colors[] = {"Black", "Blue", "Cyan", "Dark Gray",
                            "Gray", "Green", "Light Gray", "Magenta", "Orange",
                            "Pink", "Red", "White", "Yellow"};
        //declare variables to assist with the layout
        //these are the left and right justified x coordinates
        int ljX = 10; int rjX = 150;
        //this is the y coordinates for the rows
        int yRow1 = 10;     //the shape rows
        int yRow2 = 40;
        int yRow3 = 60;
        int yRow4 = 130;
        int yRow5 = 150;
        int yRow6 = 210;    //the message rows
        int yRow7 = 240;
        int yRow8 = 260;
        int yRow9 = 300;
        int yRow10 = 320;
        int yRow11 = 360;
        int yRow12 = 380;
        //these are the widths for the text boxes, drop downs
        //message entry,  big message entry and radio buttons
        int tWidth = 30; int dWidth = 100;
        int mWidth = 125; int bmWidth = 250;
        int rWidth = 125;
        //the height is universal, even for the messages!
        int height = 25;
        //set a content pane for the entire applet
        //set the size of the entire window and show the entire applet
        entire = this.getContentPane();
        entire.setLayout(new GridLayout(1, 2));
        entire.setSize(800,600);
        //create the entry panel and add it to the entire pane
        entryPanel = new JPanel();
        entryPanel.setLayout(null);
        entire.add(entryPanel);
        //create the display canvas and add it to the entire pane
        //this will display the output
        displayCanvas = new Canvas();
        entire.add(displayCanvas);       
        //entry panel code
        //add the form elements in the form of rows
        //the first row (label)
        JLabel entryLabel = new JLabel("Enter Shape Parameters:");
        entryPanel.add(entryLabel);
        entryLabel.setBounds(ljX, yRow1, bmWidth, height);
        //second row (labels)
        JLabel shapeTypeLabel = new JLabel("Select Shape:");
        shapeTypeLabel.setBounds(ljX, yRow2, mWidth, height);
        entryPanel.add(shapeTypeLabel);
        JLabel shapeColorLabel = new JLabel("Select Shape Color:");
        shapeColorLabel.setBounds(rjX, yRow2, mWidth, height);
        entryPanel.add(shapeColorLabel);
        //third row (entry)        
        rect = new JRadioButton("Rectangle", true);
        oval = new JRadioButton("Oval", false);
        roundRect = new JRadioButton("Round Rectangle", false);
        rect.setBounds(ljX, yRow3, rWidth, height);
        oval.setBounds(ljX, yRow3 + 20, rWidth, height);
        roundRect.setBounds(ljX, yRow3 + 40, rWidth, height);
        shapeRadio = new ButtonGroup();
        shapeRadio.add(rect);
        shapeRadio.add(oval);
        shapeRadio.add(roundRect);
        entryPanel.add(rect);
        entryPanel.add(oval);
        entryPanel.add(roundRect);       
        shapeColorDrop = new JComboBox(colors);
        shapeColorDrop.setBounds(rjX, yRow3, dWidth, height);
        shapeColorDrop.addActionListener(new testListen());
        entryPanel.add(shapeColorDrop);
        //the fourth row (labels)
        JLabel xShapeLabel = new JLabel("Enter Width:");
        xShapeLabel.setBounds(ljX, yRow4, mWidth, height);
        entryPanel.add(xShapeLabel);
        JLabel yShapeLabel = new JLabel("Enter Height:");
        yShapeLabel.setBounds(rjX, yRow4, mWidth, height);
        entryPanel.add(yShapeLabel);
        //the fifth row (entry)
        xShapeText = new JTextField("200", 3);
        xShapeText.setBounds(ljX, yRow5, tWidth, height);
        entryPanel.add(xShapeText);        
        yShapeText = new JTextField("200", 3);
        yShapeText.setBounds(rjX, yRow5, tWidth, height);
        entryPanel.add(yShapeText);
        //the sixth row (label)
        JLabel messageLabel = new JLabel("Enter Message Parameters:");
        messageLabel.setBounds(ljX, yRow6, bmWidth, height);
        entryPanel.add(messageLabel);
        //the seventh row (labels)   
        JLabel messageEntryLabel= new JLabel("Enter Message:");
        messageEntryLabel.setBounds(ljX, yRow7, mWidth, height);
        entryPanel.add(messageEntryLabel);
        //the eighth row (entry)
        messageText = new JTextField(25);
        messageText.setBounds(ljX, yRow8, mWidth, height);
        entryPanel.add(messageText);
        //the ninth row (label)
        JLabel fontTypeLabel = new JLabel("Select Font:");
        fontTypeLabel.setBounds(ljX, yRow9, mWidth, height);
        entryPanel.add(fontTypeLabel);
        JLabel fontColorLabel = new JLabel("Select Font Color:");
        fontColorLabel.setBounds(rjX, yRow9, mWidth, height);
        entryPanel.add(fontColorLabel);
        //the tenth row (entry)
        fontTypeDrop = new JComboBox(fonts);
        fontTypeDrop.setBounds(ljX, yRow10, dWidth, height);
        entryPanel.add(fontTypeDrop);       
        fontColorDrop = new JComboBox(colors);
        fontColorDrop.setBounds(rjX, yRow10, dWidth, height);
        entryPanel.add(fontColorDrop);
        //the eleventh row (label)
        JLabel fontSizeLabel = new JLabel("Select Font Size:");
        fontSizeLabel.setBounds(ljX, yRow11, mWidth, height);
        entryPanel.add(fontSizeLabel);
        //the final row (entry)
        fontSizeText = new JTextField("12", 2);
        fontSizeText.setBounds(ljX, yRow12, tWidth, height);
        entryPanel.add(fontSizeText);
        //display panel code
        //set the applet to visible
        entire.setSize(800, 600);
        entire.setVisible(true);
    }   //end the init method
    //begin the paint method to the canvas
    public void paint(Graphics g)
        //how do I draw into the displayCanvas?????
    }   //end the paint method
}   //end DemoShape class

Similar Messages

  • Draw an Indesign Template Icon into a generic panel widget

    Hello friends
    I want to draw an  image preview of perticular indesign template file into a generic panel widget.
    I refer bascic panel treeview ,but thing is that it will support  jgp,pdf file format not indt or indd format.
    My Requirement is  As follows
    i have root folder and this root folder contains the template file ,when user select the template from this folder preview of that file is drwan into the generic panel.
    if anybody knows the solution for  the same please help me.
    Thanks
    Tahir

    Hi Hans
    If you want to use PNG image, that is embedded in plugins binary you can simply use PlatformIconClass in your GenericPanelWidget Draw method.
    "How can I draw an icon form the fr resource into this widget?"
    PlatformIconClass thePIC;
    thPIC.LoadIcon(kYOURPluginID, kPicIcoTopOutsidePictureRsrcID);
    thPIC.Draw(inYOURViewPort, iconSysRect, kFalse);
    other way is to use PNGArt class which gives a pointer to AGMImageRecord
    PNGArt pngArt;
    pngArt.SetRsrc(kYOURPluginID, kPicIcoTopOutsidePictureRsrcID, false);
    AGMImageRecord* theImageRecord2 = pngArt.GetBitmap();
    "Instead of PNG, can I use BMP (Bitmap)?"
    InDesign resources are based on PNG image format. Don't think you can work with other formats.
    Regards
    Bartek

  • Nested panels in Swing

    Hi, everyone
    i want to know about nested panels in detail. If we make heirarchy of panels at third level then how we can perform drawing in uppermost(last child). please suggest me ideas and give links that gives sufficient matter about it.
    Thanks in advance.
    Rakesh Ojha

    Hello DB sir
    thanks for gentle reply
    i m not getting the website address from your message on which layout managers are discussed in tutorial. If you mean sun.com then please tell me.
    Thanks
    Rakesh Ojha

  • How to draw a shape to Panel instead of draw to Frame

    I have a Frame and add a Panel into this Frame. I want to draw a shape to Panel instead of draw to Frame. how do i do?

    You can do two different things:
    1) For temporary drawings that will disappear when the component is repainted, you can use getGraphics() on the Panel, draw on the Graphics, then dispose the Graphics.
    2) For persistant drawings, subclass Panel and override the paint(Graphics g) method. Anything in there will be painted along with the panel. Start with super.paint(g); when you override for good coding practice.

  • When I call an external program from Labview, how can I embed the interface into the front panel?

    I'm running Labiew 6i for Linux. I'm using a system exec.vi to call an external program to do image manipulation (since there is no IMAQ for linux). How can I embed the user interface of the external program into the front panel of Labview?

    As far as I know, the only way to embed other GUIs in LabView is an ActiveX in a container.
    As long as you are using Linux, try to place (moving them on the desktop ) the two windows linked (like those 3 of WinAmp).

  • I tried to import a PDF of a line drawing into Photoshop Elements. The thumbnail looks fine, but when imported the file is empty. This used to work in the past. What is wrong and how do I solve this?

    I tried to import a PDF of a line drawing into Photoshop Elements. The thumbnail looks fine, but when imported the file is empty. This used to work in the past. What is wrong and how do I solve this?

    Hi
    The value of the Channel Strip volume etc is not stored within the C Strip setting, as you have discovered.
    If you really wanted, you could add a Gain plug to the strip, with it set to give the correct output level with the Fader set to 0
    (Or just set the fader manually in MS)
    CCT

  • How do you convert an Autocad drawing into a pdf with Acrobat X Standard?

    How do you convert an Autocad drawing into a pdf with Acrobat X Standard?

    Something to try -
    Having installed Acrobat Standard you have the Adobe PDF virtual printer installed.
    From your authoring application do a "file-print" and select the Adobe PDF printer rather than the attached local or network printer / plotter.
    Be well...

  • Will I get an alert/notification on my iphone when i first log into icloud control panel on my PC

    Will I get an alert/notification on my iphone when i first log into icloud control panel on my PC

    You can only create the account on a Mac or an IOS device. Then you can use it on your PC.

  • Load HTML into a Tabbed Panel?

    Can I load another URL Into a tabbed panel's main div? In
    other words, I click on a tab and then the Tabbed Panels' Content
    area loads up an HTML page into it's div. I know of similar
    frameworks that can do it but I haven't seen it done in Spry
    yet.

    Hi Data,
    Check out UpdateContent and see if that will do what you
    need:
    http://labs.adobe.com/technologies/spry/samples/utils/update_content.html
    Thanks,
    Don

  • How to merge top level navigation into detail navigation panel.

    Hi All,
    I want to add all the contents of top level navigation into detail navigation panel and  remove top level navigation.I am looking for the code with which i can shift the top level navigation to detail level navigation.

    You could edit the top-level navigation iview and set the <b>Number of Display levels</b> property's value to 0.
    you can reach the Top-level navigation iview by going through the following path
    1) <b>Content Administration --> Portal Content --> Content Provided by SAP --> Admin Interfaces --> Top-level navigation</b>
    However, note that once you do this the whatever menus that are available in the top level will not be available anymore.
    Maybe, you could copy the standard Top-level navigation into a framework page that you have created and then make the change. After doing so, you can assign it to groups/roles you want. This will ensure that the CONTENT/SYSTEM/USER administrators see the normal portal framework and specific user groups alone dont see the Top level navigation..
    Pradeep.

  • Getting a sliding panel loaded into an html panel to work.

    Hi. This is my first post on the forum.
    I've been using Spry a little here and there. Today I ran
    into a situation where I want to load an external page, that has a
    sliding panel in it, into an html panel. So far I have not had luck
    and I suppose it has to do with loading the js file. At the moment
    I have a right column that already has a sliding panel (working).
    But it would appear that the loaded external html file (in the left
    "main" column) is not picking that up. Any suggestions for a noob
    as to what to do next? Viewing the external page by itself allows
    the sliding panel to work (that is when I add the js file import to
    the head of the external html file... but that head section does no
    good when loaded into an html panel)
    Anyway, any help at all is greatly appreciated.
    Thanks,
    Eric

    Thank you very much! I found the topic
    here.
    It will require a bit of a small learning curve for me as html
    panel and sliding panels are my first interaction with js... even
    my rollovers are css driven. Thanks!

  • How do I restore folders into the folders panel

    I am new to LR and I am using LR3. I appear to be digging a massive hole for myself trying to sort out the catalog.
    When I first got LR, I had initially added just a small number of files just to see how LR worked. At this time I was still completing sorting out my full photo collection in 'my pictures' which were also copied to two external hard drives. Once that work was completed, I imported a complete folder (some 4000 images) into LR. The folder/subfolders appeared in the folders panel but the sub folders I had initially imported were displayed with a ? and a message 'file is missing or offline' Going down the road of 'find missing folder' eventually led to my problems.
    About 6 sub folders are involved so I eventually took the decision that it could be easier just to remove them so I could then re-import them from 'my pictures'. That hasn't worked out as planned.  
    When I go into 'file' to import photos from 'my pictures' the missing sub folders are there but the images are 'greyed' as well as the import button. When I put the cursor onto one of the greyed-out images the message 'appears to be a duplicate of another photo already in catalog' appears.
    Can anyone advise me how I can restore the 'missing' sub folders into the folders panel.
    Thanks
    Howard

    If you've really removed them, then they shouldn't be showing up as duplicates.
    If you have a mess and haven't done any real work inside Lightroom, I'd suggest starting a new catalog and importing fresh.

  • How to draw rectanlge in the panel, clear, repaint?

    when i was taking my coding, i found a problem which i could not solve.So, i hope someone can help. Thank you.
    the question :
    1. how to draw Rectangle in the Panel?
    2. how to clear?
    3. how to repaint?
    The following is my coding.
    import javax.swing.*;
    import java.awt.*;
    public class DrawScreen extends JFrame {
    Color rectColor=Color.white;
    int hight=100;
    Panel Button_panel = new Panel();
    Button button1 = new Button();
    Button button2 = new Button();
    Button button3 = new Button();
    Panel Draw_Panel = new Panel();
    public DrawScreen(String title) {
         super(title);
         try {
         Init();
         catch(Exception e) {
         e.printStackTrace();
    private void Init() throws Exception {
    setResizable(false);
    setFont(new Font("Serif",Font.ITALIC,12));
         this.getContentPane().setLayout(null);
         Button_panel.setBackground(SystemColor.control);
         Button_panel.setLocale(java.util.Locale.getDefault());
         Button_panel.setBounds(new Rectangle(14, 17, 118, 259));
         Button_panel.setLayout(null);
         button1.setLabel("Draw Square");
         button1.setBounds(new Rectangle(0, 69, 115, 22));
         button2.setLabel("Colour Red");
         button2.setBounds(new Rectangle(0, 111, 115, 22));
         button3.setLabel("Clear Screen");
         button3.setBounds(new Rectangle(2, 152, 115, 22));
         Draw_Panel.setBackground(Color.white);
         Draw_Panel.setBounds(new Rectangle(138, 15, 254, 266));
    //     System.out.println(Draw_Panel.getBounds());
         this.getContentPane().setBackground(Color.white);
         this.getContentPane().add(Button_panel, "East");
         Button_panel.add(button3, null);
         Button_panel.add(button2, null);
         Button_panel.add(button1, null);
         this.getContentPane().add(Draw_Panel, "West");
         addWindowListener(new java.awt.event.WindowAdapter(){
              public void windowClosing(java.awt.event.WindowEvent e){
                   System.exit(0);
    button1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    button1ActionPerformed(evt);
    button2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    button2ActionPerformed(evt);
    button3.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    button3ActionPerformed(evt);
    pack();
    private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
         hight=(int)(Math.random()*100);
         rectColor=Color.black;
    repaint();
    private void button2ActionPerformed(java.awt.event.ActionEvent evt) {
         rectColor=Color.red;
    repaint();
    private void button3ActionPerformed(java.awt.event.ActionEvent evt) {
    rectColor=Color.white;
    repaint();
    public void paint(Graphics g){
         g.setColor(rectColor);
         g.drawRect(50, 50,hight,hight);
    public static void main(String[] args) {
    DrawScreen ds=new DrawScreen("Square Plotter");
         ds.setSize(600,350);
         ds.setVisible(true);

    Few changes and it works:
    import javax.swing.*;
    import java.awt.*;
    public class DrawScreen extends JFrame
         Color  rectColor    = Color.white;
         int    hight        = 100;
         Panel  Button_panel = new Panel();
         Button button1      = new Button();
         Button button2      = new Button();
         Button button3      = new Button();
         DPanel Draw_Panel   = new DPanel();
    public DrawScreen(String title)
         super(title);
         setResizable(false);
    //     setFont(new Font("Serif",Font.ITALIC,12));
    //     this.getContentPane().setLayout(null);
         Button_panel.setBackground(SystemColor.control);
         Button_panel.setLocale(java.util.Locale.getDefault());
         Button_panel.setBounds(new Rectangle(14, 17, 118, 259));
         Button_panel.setLayout(null);
         button1.setLabel("Draw Square");
         button1.setBounds(new Rectangle(0, 69, 115, 22));
         button2.setLabel("Colour Red");
         button2.setBounds(new Rectangle(0, 111, 115, 22));
         button3.setLabel("Clear Screen");
         button3.setBounds(new Rectangle(2, 152, 115, 22));
         Draw_Panel.setBackground(Color.white);
         Draw_Panel.setBounds(new Rectangle(138, 15, 254, 266));
    //  System.out.println(Draw_Panel.getBounds());
    //     this.getContentPane().setBackground(Color.white);
         this.getContentPane().add(Button_panel, "East");
         Button_panel.add(button3);
         Button_panel.add(button2);
         Button_panel.add(button1);
         this.getContentPane().add(Draw_Panel, "Center");
         addWindowListener(new java.awt.event.WindowAdapter()
              public void windowClosing(java.awt.event.WindowEvent e)
                   System.exit(0);
         button1.addActionListener(new java.awt.event.ActionListener()
              public void actionPerformed(java.awt.event.ActionEvent evt)
                   button1ActionPerformed(evt);
         button2.addActionListener(new java.awt.event.ActionListener()
              public void actionPerformed(java.awt.event.ActionEvent evt)
              button2ActionPerformed(evt);
         button3.addActionListener(new java.awt.event.ActionListener()
              public void actionPerformed(java.awt.event.ActionEvent evt)
                   button3ActionPerformed(evt);
    //     pack();
    private void button1ActionPerformed(java.awt.event.ActionEvent evt)
         hight=(int)(Math.random()*100);
         rectColor=Color.black;
         repaint();
    private void button2ActionPerformed(java.awt.event.ActionEvent evt)
         rectColor=Color.red;
         repaint();
    private void button3ActionPerformed(java.awt.event.ActionEvent evt)
         rectColor=Color.white;
         repaint();
    public class DPanel extends JPanel
    public DPanel()
    public void paintComponent(Graphics g)
         super.paintComponent(g);
         g.setColor(rectColor);
         g.drawRect(50, 50,hight,hight);
    public static void main(String[] args)
         DrawScreen ds=new DrawScreen("Square Plotter");
         ds.setSize(600,350);
         ds.setVisible(true);
    }Noah

  • Mouseclick issue on nested panel

    Hi all,
    I'm redesigning my portfolio website with Spry sliding panel
    tech. and I've encountered a behaviour issue that I was wondering
    if anybody else has seen before.
    So I've got one set of sliding panels that controls the
    sections of the website you visit (ie graphic design, web design
    etc) and then a repeating panel inside each one that displays the
    different examples in each genre. This nested panel is controlled
    by the simple nextFrame(), prevFrame() functionality (as well as
    listing the number of panels that are also clickable for more
    direct navigation) - to see it all in action, visit
    http://www.pixelz.co.uk/newhome.html
    My problem is that the FIRST time you click on a navigation
    link in the nested panel, nothing happens. After that it all works
    fine, but it almost seems that the panel needs to be focused on
    first by a click and then will run as normal. Anybody else come
    across this issue? Is there a fix for it?
    Cheers
    Pix

    Hi all, anybody found a workaround for this problem?
    still searching...

  • ADF/Swing probles with nested panels layout.

    When panel is placed in other panel, changing of nested panel layout by changing panel properties, results in adding in jbInit() metod code for setting choosen layout at the end of jbInit and not (as in top panel) at the begining of jbInit(). Many times (for instance when layout is BorderLayout) because of this nested panel is displayd empty. It is necessary of course to manually move lines setting layout before lines which adds components to nested panel. Thou it is possible to do it manually it would be nice not to have remember about it.

    Remi,
    how do I reproduce this? Can you give me a step-by-step instruction? Its not clear from your posting which JDeveloper release you are using (though I assume JDeveloper 10.1.3), nor if the panels are created in external Java file or within the parent panel.
    Frank

Maybe you are looking for

  • HH5 & Infinity 2 Issue - Please Help

    Hi, Ok i've had a morning of being passed from one department to the other online and on the phone, and nobody seems to be able to help. Have seen various posts on here suggesting there is an issue of people being stuck on the wrong IP profile when u

  • Web Template Migration Error in Chart

    Hi All,   I have a 3x web template 'TEST_3X'   It is derived from the SAP default 3x template 0QUERY_TEMPLATE with no   major changes/customizing. Only a picture and a data provider has been   assigned. It works fine.   Now I tried to migrate 'TEST_3

  • MacBook Air display in MacBook Pro

    nvm

  • CRM IDES Exports data into existing Non IDES System?

    Hello, Is it possible to import SAP CRM IDES data using IDES Exports into any existing non IDES SAP CRM System without re-installation? The thing is that we already have some data in two clients (client 100 and 200) and we don't want to loose it and

  • How to Create an Account on Whatsapp - Nokia C3-00

    Plz help frndz..... I have using C3-00 when i was sign up for whatsapp the connecting is only coming how can i create account on whatsapp from C3-00 Moderator's Note: The subject was amended as the post was moved to the more appropriate board.