Stop Painting over JComboBoxes?

I'm programming a game in Java (MasterMind) that uses simple graphics, and JComboBox to get inputs. The problem is that the graphics "paint over" the options in my JComboBoxes. When I mouse hover over the options, the problem fixes itself, but the initial graphics getting in the way is annoying. My code is kind of a mess so far, so it would probably be better to just post a screenshot, since I haven't made any sense so far:
http://home.comcast.net/~falcorthedog/untitled.JPG
As you can see, the colored pegs get in the way of my selections. Any way around this? Any help would be greatly appreciated... my project is due Tuesday! Thanks in advance!

From what I've seen, I supose you altered the paint(Graphics) method of the underlying JPanel which also contains the JComboBox. Probably your code looks like this:
public void paint(Graphics g){
super.paint(g);
//your stuff, painting the circles etc...
}First of all, it would be better to overwrite paintComponent(Graphics) in this case, which should already fix your problem, as this method will only affect those parts of the panel not covered by other components (well, it's not what happens, but the effect is the same). Alternately you could simply change the drawing order by making the call to super.paint(g) at the end of your paint method - telling java to paint all your stuff, then the JComboBox on top of it.
sarcan

Similar Messages

  • Making popup menus stop painting over the current window

    I'm making up a game that relies on a regular menu bar for it's menus. But for some reason the drop-down menus insist on rendering themselves over the current window instead of creating a new object over it like it should. This causes them to vanish right after opening because the game is constantly refreshing the area it paints over, but if I reduce the window drastically in a way there's no room to paint the drop-down menus over the existing area, they appear normally because a new window is created to display them.
    How do I ferce it to always create a new window?

    Jack Mcslay wrote:
    I'm making up a game that relies on a regular menu bar for it's menus. But for some reason the drop-down menus insist on rendering themselves over the current window instead of creating a new object over it like it should.No it shouldn't, and your saying so doesn't change anything.
    This causes them to vanish right after opening because the game is constantly refreshing the area it paints over,... implying that you have a wrong approach to custom painting
    but if I reduce the window drastically in a way there's no room to paint the drop-down menus over the existing area, they appear normally because a new window is created to display them.As expected
    How do I ferce it to always create a new window?Wrong question. Ask how to perform custom painting correctly -- which is answered in the tutorial suggested twice.
    db

  • Content pane painting over JPopupMenu

    I have a rather complex series of overridden components (JMenuBar, JPanels, JMenus, JFrame, etc.) that I aggregate to form a 'theme frame' --- basically a 'lightweight' L&F decorated frame. The main frame is an UNDECORATED JFrame derivation, in which I basically install a derived JMenuBar class that looks and acts like the top portion of the frame's 'border' (i.e. the title bar), as well as accomodating the menu items for the frame. I then launch several of these frames from the main application, each with its own set of menus (a single top-level JMenu with a few menu items on the popup).
    My problem is this... if there are more than 1 of these frames extant after the initial start-up of the application, I can invoke the top-level menu on all of the frames, but only 1 of them actually paints it correctly... the others will show the JPopupMenu, but then the embedded content repaints AFTERWARDS, thus painting over all but the first item on the menu. What's really very bazaar is that it seems to depend totally on location of the frame on the screen (i.e. in relation to the other frames). Initially, only the top-most and/or left-most frame will paint the JPopupMenu correctly, and the rest will exhibit this "show the popup, then paint the content pane over it" behavior.
    With the help of print statements, I've been able to determine that the frame which paints the popup correctly DOES NOT get a repaint() notification on it's content-pane, whereas the others do (hence the 'cover-up' behavior of those).
    It may be useful to note that the 'content' of these frames are actually applets, which themselves have a complex set of specialized components embedded in them.
    None of the menu objects or other components involved are static to the frame class, so nothing's being shared... also, if I move one of the non-functioning windows to a different location on the screen, then the menu works fine... move it back, and the menu gets painted over again.
    I'm using JDK 1.4, JBuilder X, all components are Swing.
    Any help, please??????
    XNHillBilly

    That did the trick! I had a gut feeling it was something simple like that... I still don't fully understand exactly what was going on (why one frame would paint fine, while the others wouldn't), but that's less important than having it work correctly at this point ;-)
    Thanks mucho rykk,
    XNHillBilly

  • Images disappearing / being painted over

    Hi,
    Not especially familiar with images and am having issues with images being painted over when ever I move or adjust the size of my GUI. I built a majority of the GUI using the Form Designer included with Netbeans.
    Would really appreciate any advice, happy to include more detail if required.
    Cheers,
    Tim
    GUIView
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.util.Vector;
    import javax.imageio.ImageIO;
    * GUIView.java
    * Created on 22 April 2007, 21:25
    * The GUIView class is responsible to display a graphical interface.
    * This class interacts with the user and the GUIControl class allowing the user to operate the system.
    * @author  Tim
    public class GUIView extends JFrame implements ActionListener {
    // Declare method variables
        private JTextField prodIDInput0;
        private JLabel prodIDLabel0;
        private JLabel prodIDLabel1;
        private JLabel prodIDLabel2;
        private JLabel prodNameLabel0;
        private JLabel prodNameLabel1;
        private JTextField amtRcvdInput0;
        private JLabel amtRcvdLabel0;
        private JButton cancelButton0;
        private JMenu fileMenu0;
        private JMenuItem exportXMLMenuItem;
        private JMenuItem exitMenuItem;
        private JButton findButton0;
        private JLabel itemPrice0;
        private JScrollPane jScrollPane1;
        private JMenuBar menuBar0;
        private JButton paymentButton0;
        private JLabel prodDescLabel0;
        private JLabel prodDescLabel1;
        private JPanel prodImagePanel0;
        private JPanel prodPanel0;
        private JLabel qtyLabel0;
        private JTextField qtyInput0;
        private JLabel totalPrice0;
        private JLabel totalPrice1;
        private JList transList0;
        private JPanel transPanel0;
        private Vector listData;
        private BufferedImage img;
        private GUIControl guiCtl0;
        /** Creates new form GUIView */
        public GUIView (GUIControl guiCtl0) {
            // reference guiCtl object
            this.guiCtl0 = guiCtl0;
        /** initilise gui object */
        public void initGui () {
            // initialise the GUI
            initComponents ();
            // paint image
            paintImage ("images/transparent.gif");
            // show the GUI
            setVisible (true);
        /** 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.
        private void initComponents () {
            // Instantiate GUI objects
            prodIDLabel0 = new JLabel ();
            prodIDLabel1 = new JLabel ();
            prodNameLabel0 = new JLabel ();
            prodNameLabel1 = new JLabel ();
            prodDescLabel0 = new JLabel ();
            prodDescLabel1 = new JLabel ();
            prodImagePanel0 = new JPanel ();
            itemPrice0 = new JLabel ();
            totalPrice0 = new JLabel ();
            totalPrice1 = new JLabel ();
            prodPanel0 = new JPanel ();
            prodIDLabel2 = new JLabel ();
            prodIDInput0 = new JTextField ();
            qtyInput0 = new JTextField ();
            qtyLabel0 = new JLabel ();
            findButton0 = new JButton ();
            transPanel0 = new JPanel ();
            paymentButton0 = new JButton ();
            cancelButton0 = new JButton ();
            amtRcvdInput0 = new JTextField ();
            amtRcvdLabel0 = new JLabel ();
            jScrollPane1 = new JScrollPane ();
            transList0 = new JList ();
            menuBar0 = new JMenuBar ();
            fileMenu0 = new JMenu ();
            listData = new Vector ();
            // default close operation is to terminate the application
            setDefaultCloseOperation (WindowConstants.EXIT_ON_CLOSE);
            // title of the window
            setTitle ("Supermarket Management System");
            // centre the GUI on the screen
            Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment ().getMaximumWindowBounds ();
            rect.grow (-185,-100);
            setBounds (rect);
            // sets the minimum size the wonw can be shrunk to
            setMinimumSize (new java.awt.Dimension (880, 480));
            // sets the name of the frame
            setName ("mainFrame");
            // setup label to show Product ID:
            prodIDLabel0.setFont (new java.awt.Font ("Tahoma", 1, 14));
            prodIDLabel0.setText ("Product ID:");
            // setup label to show the id of the latest product object
            prodIDLabel1.setFont (new java.awt.Font ("Tahoma", 0, 14));
            prodIDLabel1.setText ("");
            prodIDLabel1.setToolTipText ("Product ID");
            // setup label to show Name:
            prodNameLabel0.setFont (new java.awt.Font ("Tahoma", 1, 14));
            prodNameLabel0.setText ("Name:");
            // setup label to show the name of the latest product object
            prodNameLabel1.setFont (new java.awt.Font ("Tahoma", 0, 14));
            prodNameLabel1.setText ("");
            prodNameLabel1.setToolTipText ("Product Name");
            // setup label to show Description:
            prodDescLabel0.setFont (new java.awt.Font ("Tahoma", 1, 14));
            prodDescLabel0.setText ("Description:");
            // setup label to show the description of the latest product object
            prodDescLabel1.setFont (new java.awt.Font ("Tahoma", 0, 14));
            prodDescLabel1.setText ("");
            prodDescLabel1.setToolTipText ("Product Description");
            // align the prodDescLabel1 to TOP
            prodDescLabel1.setVerticalAlignment (SwingConstants.TOP);
            // setup panel to display image
            prodImagePanel0.setBackground (new java.awt.Color (255, 255, 255));
            prodImagePanel0.setBorder (javax.swing.BorderFactory.createEtchedBorder (javax.swing.border.EtchedBorder.RAISED));
            org.jdesktop.layout.GroupLayout prodImagePanel0Layout = new org.jdesktop.layout.GroupLayout (prodImagePanel0);
            prodImagePanel0.setLayout (prodImagePanel0Layout);
            // specify how much the panel expands on the horizontal axis
            prodImagePanel0Layout.setHorizontalGroup (
                    prodImagePanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (0, 304, Short.MAX_VALUE)
            // specify how much the panel expands on the vertical axis
            prodImagePanel0Layout.setVerticalGroup (
                    prodImagePanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (0, 255, Short.MAX_VALUE)
            // setup item price label
            itemPrice0.setFont (new java.awt.Font ("Tahoma", 1, 14));
            itemPrice0.setText ("");
            itemPrice0.setToolTipText ("Transaction Item Price information");
            // setup label to display Total Price:
            totalPrice0.setFont (new java.awt.Font ("Tahoma", 1, 18));
            totalPrice0.setText ("Total Price:");
            // setup label to display current transaction total price
            totalPrice1.setFont (new java.awt.Font ("Tahoma", 0, 18));
            totalPrice1.setText ("$0.00");
            totalPrice1.setToolTipText ("Total cost of transaction");
            // setup JPanel to contain product look up components
            prodPanel0.setBorder (BorderFactory.createTitledBorder ("Enter Product"));
            // setup label to display Product ID:
            prodIDLabel2.setText ("Product ID:");
            // setup label to display Quantity:
            qtyLabel0.setText ("Quantity:");
            // setup button and display FIND as the text
            findButton0.setFont (new java.awt.Font ("Tahoma", 0, 14));
            findButton0.setText ("FIND");
            findButton0.setToolTipText ("Click to find product");
            findButton0.addActionListener (this);
            // create new GroupLayout for prodPanel0
            org.jdesktop.layout.GroupLayout prodPanel0Layout = new org.jdesktop.layout.GroupLayout (prodPanel0);
            prodPanel0.setLayout (prodPanel0Layout);
            // set horizontal group
            prodPanel0Layout.setHorizontalGroup (
                    prodPanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (prodPanel0Layout.createSequentialGroup ()
                    .add (15, 15, 15)
                    .add (prodIDLabel2)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    // add prodIDInput0 JTextField to form
                    .add (prodIDInput0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 126, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (22, 22, 22)
                    .add (qtyLabel0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    // addd qtyInput0 JTextField to form
                    .add (qtyInput0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 39, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (22, 22, 22)
                    .add (findButton0)
                    .addContainerGap (org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            // set vertical group
            prodPanel0Layout.setVerticalGroup (
                    prodPanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (prodPanel0Layout.createSequentialGroup ()
                    .addContainerGap ()
                    .add (prodPanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.BASELINE)
                    .add (prodIDLabel2)
                    // add prodIDInput0 JTextField to form
                    .add (prodIDInput0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (qtyLabel0)
                    // add qtyInput0 JTextField to form
                    .add (qtyInput0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (findButton0))
                    .addContainerGap (org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            // setup JPanel to contain finialise payment components
            transPanel0.setBorder (BorderFactory.createTitledBorder ("Finalise Transaction"));
            // setup button and display PAYMENT as the text
            paymentButton0.setFont (new java.awt.Font ("Tahoma", 0, 14));
            paymentButton0.setText ("PAYMENT");
            paymentButton0.setToolTipText ("Click to finalise transaction");
            // setup button and display CANCEL as the text
            cancelButton0.setFont (new java.awt.Font ("Tahoma", 0, 14));
            cancelButton0.setText ("CANCEL");
            cancelButton0.setToolTipText ("Cancel the current transaction");
            cancelButton0.addActionListener (this);
            // setup label to display Amount received:
            amtRcvdLabel0.setText ("Amount received:");
            // create new GroupLayout for TransPanel0
            org.jdesktop.layout.GroupLayout transPanel0Layout = new org.jdesktop.layout.GroupLayout (transPanel0);
            transPanel0.setLayout (transPanel0Layout);
            // set horizontal group
            transPanel0Layout.setHorizontalGroup (
                    transPanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (org.jdesktop.layout.GroupLayout.TRAILING, transPanel0Layout.createSequentialGroup ()
                    .addContainerGap (org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add (amtRcvdLabel0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    // add amtRcvdInput0 JTextField to form
                    .add (amtRcvdInput0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 58, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (22, 22, 22)
                    .add (paymentButton0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (cancelButton0)
                    .addContainerGap ())
            // set vertical group
            transPanel0Layout.setVerticalGroup (
                    transPanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (transPanel0Layout.createSequentialGroup ()
                    .addContainerGap ()
                    .add (transPanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.BASELINE)
                    .add (cancelButton0)
                    .add (paymentButton0)
                    // add amtRcvdInput0 JTextField to form
                    .add (amtRcvdInput0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (amtRcvdLabel0))
                    .addContainerGap (org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            // setup JScrollPanel to display transaction items
            transList0.setFont (new java.awt.Font ("Tahoma", 0, 14));
            transList0.setListData (listData);
            transList0.setToolTipText ("Items entered in the current transaction");
            // specify scrollbars
            jScrollPane1.setViewportView (transList0);
            // setup the file menu
            fileMenu0.setText ("File");
            // add Export XML menu item to file menu
            exportXMLMenuItem = new JMenuItem ("Export to XML");
            exportXMLMenuItem.setToolTipText ("Export current product list to product.xml");
            fileMenu0.add (exportXMLMenuItem);
            // add menu seperator
            fileMenu0.addSeparator ();
            // add Exit menu item to file menu
            exitMenuItem = new JMenuItem ("Exit");
            exitMenuItem.setToolTipText ("Exit application");
            fileMenu0.add (exitMenuItem);
            // add the file menu to the menu bar
            menuBar0.add (fileMenu0);
            // set the menu bar to be menuBar0
            setJMenuBar (menuBar0);
            // layout remaining components onto JFrame
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout (getContentPane ());
            getContentPane ().setLayout (layout);
            // set horizontal group
            layout.setHorizontalGroup (
                    layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (layout.createSequentialGroup ()
                    .addContainerGap ()
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (layout.createSequentialGroup ()
                    .add (prodIDLabel0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (prodIDLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 78, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (prodNameLabel0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (prodNameLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 164, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add (layout.createSequentialGroup ()
                    .add (prodDescLabel0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (prodDescLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 725, Short.MAX_VALUE))
                    .add (layout.createSequentialGroup ()
                    .add (prodImagePanel0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 499, Short.MAX_VALUE))
                    .add (layout.createSequentialGroup ()
                    .add (itemPrice0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED, 441, Short.MAX_VALUE)
                    .add (totalPrice0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (totalPrice1))
                    .add (layout.createSequentialGroup ()
                    .add (prodPanel0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (transPanel0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addContainerGap ())
            // set vertical group
            layout.setVerticalGroup (
                    layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (layout.createSequentialGroup ()
                    .addContainerGap ()
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.BASELINE)
                    .add (prodIDLabel1)
                    .add (prodNameLabel1)
                    .add (prodNameLabel0)
                    .add (prodIDLabel0))
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.BASELINE)
                    .add (prodDescLabel0)
                    .add (prodDescLabel1))
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)
                    .add (prodImagePanel0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (itemPrice0)
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.BASELINE)
                    .add (totalPrice1)
                    .add (totalPrice0)))
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (prodPanel0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (transPanel0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap ())
            // resize the frame to the minimum size needed to satisfy the preferred size of each of the components in the layout
            pack ();
        /** actionPerformed()
         *  handles events from components.
        public void actionPerformed (ActionEvent e) {
            if ( e.getSource () == findButton0 )
                guiCtl0.findButtonAction (prodIDInput0.getText (), qtyInput0.getText ());
            if ( e.getSource () == cancelButton0 )
                guiCtl0.cancelButtonAction ();
        /** showWelcomeMsg()
         *  Shows a welcome dialogue message to the user.
        public void showWelcomeMsg (){
            // Create a new dialogue box
            JOptionPane welcomeMsg = new JOptionPane ();
            // Show welcome dialogue box
            welcomeMsg.showMessageDialog (null, "Welcome to the Supermarket Management System.  Click OK to begin.", "Welcome", welcomeMsg.INFORMATION_MESSAGE);
        /** showMsg()
         *  Shows a message to the user.
        public void showErrorMsg (String s){
            // Create a new dialogue box
            JOptionPane errorMsg = new JOptionPane ();
            // Show welcome dialogue box
            errorMsg.showMessageDialog (null, s, "Message", errorMsg.ERROR_MESSAGE);
        /** set prodIDInput0 text field */
        public void setProdIDInput0 (String s){
            prodIDInput0.setText (s);
        /** set qtyInput0 text field */
        public void setQtyInput0 (String s){
            qtyInput0.setText (s);
        /** set ProdDescLabel1 label */
        public void setProdDescLabel1 (String s) {
            prodDescLabel1.setText (s);
        /** set prodIDLabel1 label */
        public void setProdIDLabel1 (String s) {
            prodIDLabel1.setText (s);
        /** set prodNameLabel1 label */
        public void setProdNameLabel1 (String s) {
            prodNameLabel1.setText (s);
        /** set totalPrice1 label */
        public void setTotalPrice1 (String s) {
            totalPrice1.setText (s);
        /** populate transList0 with latest trans info */
        public void setTransList0 (Vector v){
            transList0.setListData (v);
        /** set itemPrice0 label */
        public void setItemPrice0 (String s) {
            itemPrice0.setText (s);
        /** draw prod images onto gui */
        public void paintImage (String imagePath) {
            // get Graphics
            Graphics g = prodImagePanel0.getGraphics ();
            // draw image into prodImagePanel0
            img = null;
            try {
                img = ImageIO.read (new File (imagePath));
            } catch (IOException e) {
                System.err.println ("Caught IOException: "
                        + e.getMessage ());
            // draw the image on screen
            g.drawImage (img, 2, 2, prodImagePanel0);
        /** Change image */
        public void updateImage (String imagePath){
            // draw image into prodImagePanel0
            img = null;
            try {
                img = ImageIO.read (new File (imagePath));
            } catch (IOException e) {
                System.err.println ("Caught IOException: "
                        + e.getMessage ());
    GUIControl
    import javax.swing.*;
    import java.text.*;
    * GUIControl.java
    * The GUIControl class is responsible to perform actions requested from the GUIView class.
    * It also liaises with the TransControl and ProdControl objects to generate output to the
    * gui and handle input from the gui.
    * @author Tim
    public class GUIControl {
        // Declare object variables
        private GUIView gui;
        private ProdControl prodCtl0;
        private TransControl transCtl0;
        /** Creates a new instance of GUIControl */
        public GUIControl (ProdControl prodCtl0, TransControl transCtl0) {
            // make reference to prodCtl0, transCtl0 and gui objects
            this.prodCtl0 = prodCtl0;
            this.transCtl0 = transCtl0;
        /** Set gui view object */
        public void setGui (GUIView gui) {
            this.gui = gui;
        /** show the welcome dialouge */
        public void showWelcome (){
            // Call the showWelcomeMsg() method from gui to dispay welcome dialogue.
            gui.showWelcomeMsg ();
        /** find product */
        public Product findProd (int prodId){
            Product foundProd = prodCtl0.getProdByID (prodId);
            return foundProd;
        /** add product to transaction */
        public String addProdToTrans (int prodId, double transQuantity){
            // declare method variables
            String status = "Product not added";
            Product curProd0;
            // find prodduct by ID
            curProd0 = prodCtl0.getProdByID (prodId);
            //  1. if product exists then add a new transaction item to the transaction list.
            if (curProd0 != null) {
                // 2. check quantity is a whole number for UPC Products
                if (curProd0 instanceof UPCProd) {
                    // check if the result is a whole number
                    boolean isWhole = (Math.rint (transQuantity) == transQuantity);
                    // 3. if isWhole is false change status message.
                    if (isWhole == false) {
                        // return status as Product cannot be found.
                        status = "You must enter the quantity as a whole number for UPC products.";
                        return status;
                    } else {
                        // 4. check there is enough stock in the store
                        if (transQuantity > curProd0.getQuantity ()) {
                            // return status as there is not enough stock.
                            status = "There is currently not enough stock to fulfill this transaction.  Please reduce the quantity." ;
                            return status;
                        } else {
                        }  // end if 4.
                    }  // end if 3.
                } else {
                }  // end if 2.
                // add curProd as new transItem
                transCtl0.addTransItem (curProd0, transQuantity);
                // return status as null to notify that the Product was added.
                status = null;
                return status;
            } else {
                // return status as Product cannot be found.
                status = "Product " + prodId + " cannot be found.";
                return status;
            }  // end if 1.
        }  // end addProdToTrans method
        /** action Find button */
        public void findButtonAction (String prodId0, String quantity0){
            // status msg
            String status;
            // check prodId0 is not null
            if (prodId0.equals ("")) {
                // set status message to error and display error msg
                status = "Please enter a valid Product ID.";
                gui.showErrorMsg (status);
                // check quantity0 is not null
            } else if (quantity0.equals ("")) {
                // set status message to error and display error msg
                status = "Please enter a valid quantity.";
                gui.showErrorMsg (status);
            } else {
                // parse String values into int and double
                int prodId1 = Integer.parseInt (prodId0);
                double quantity1 = Double.parseDouble (quantity0);
                // reset prodIDInput0 and qtyInput0 text fields in the gui
                gui.setProdIDInput0 ("");
                gui.setQtyInput0 ("");
                // add trans item and return result as a string
                status = addProdToTrans (prodId1, quantity1);
                if (status == null) {
                    updateProdTransView ();
                } else {
                    // display msg to the user
                    gui.showErrorMsg (status);
                } // end if
            } // end if
        } // end findButtonAction method
        /** update product and transaction view on gui */
        public void updateProdTransView (){
            // get the last trans item added
            TransItem lastTransItem0 = transCtl0.getLastTransItem ();
            // find the product
            Product p = findProd (lastTransItem0.getId ());
            // update product info displayed in the gui
            gui.setProdIDLabel1 (Integer.toString (p.getId ()));
            gui.setProdNameLabel1 (p.getName ());
            gui.setProdDescLabel1 (p.getDescription ());
            // paint prod image
            gui.paintImage (p.getImage ());
            // update transaction info displayed in the gui
            gui.setTransList0 (transCtl0.getTransItems ());
            gui.setItemPrice0 (transCtl0.transItemPriceInfo (lastTransItem0));
            // update total transaction cost displayed in the gui
            gui.setTotalPrice1 ("$" + transCtl0.transTotal ());
        } // end updateProdTransView method
        /** action Cancel button */
        public void cancelButtonAction (){
            // cleat transaction items from transaction array list
            transCtl0.clearTrans ();
            // reset gui components
            gui.setProdIDLabel1 ("");
            gui.setProdNameLabel1 ("");
            gui.setProdDescLabel1 ("");
            gui.setTransList0 (transCtl0.getTransItems ());
            gui.setItemPrice0 ("");
            gui.setTotalPrice1 ("$0.00");
            gui.paintImage ("images/transparent.gif");
    }

    happy to include more detail if required.You've included too much detail.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.
    And don't post code generated by NetBeans. It uses the GroupLayout which is not a standard layout manager until JDK6 and a lot of people don't use JDK6 yet so we won't be able to execute you code to see whats happening.

  • Graphic keeps disappearing and getting painted over

    I am not quite sure what is going on here, but I think that my background is being repainted after I paint my rectangles on the screen, any help on what is going on here would be greatly appreciated.
    The way the code is currently set up is when I come into the method, I set my state to -1,
    The rectangle will then init itself and then go check my control variables,
    The control variables turn the rectangle the appropriate color
    since I have rip_staus_code = 10 it turns green, although
    The problem is after it turns green;
    the rectangle disappears!!!
    and I cant quite see where in the code I am repainting over the top of it.....
    Thank You
    jsg
    protected int rx1State = -1
    public void paintChildren(Graphics g){  
         super.paintChildren(g);
         Graphics2D g2d = (Graphics2D)g;
       if(rx1State == -1){
               rx1 = new Rectangle2D.Double(29,110,63,57);
               g.setColor(testColor); 
               g2d.fill(rx1);
               g.setColor(Color.black);     
              g2d.setStroke(graphicStroke);
              g.setFont(graphicLabelFont);
              g2d.draw(rx1);     
              g.drawString("rect one",49,142);
    //turn rectangle one green
      if(rx1State != 0 && ss.rtRip1_status_code >= 9){  //rip_staus_code is set to 10, so turns green
            drawChangedRect(g,rx1,Color.green);
            g.drawString("rect one",49,142);
            rx1State = 0;
    //turns rectangle one red          
      if(rx1State != 2 && ss.rtRip1_status_code < 9){
         drawChangedRect(g,rx1,Color.red);
         g.drawString("Rx1",49,142);
         System.out.println("Turned Rx1 red");
         rx1State = 2;
    //turns Rectangle one white
      if(rx1State != 3 && (!ss.ColorRX1RIP1 | !ColorARROWABred )){ //ColorRX1RIP1=true, colorArrowABred=T     
          drawChangedRect(g,rx1,upstreamColor);
          g.drawString("Rx1",49,142);
         rx1State = 3;

    I see a couple things wrong here.
    First, why are you overwriting paintChildren? If you want to do custom drawing, do that in paintComponent.
    Second, never change state inside a painting method. Why? Because you can't control how often repaint is called. Covering or partically covering the window, resizing the window, or programmatic calls to repaint will all cause the method to be called, and sometimes only on a portion of your component (such is the case when only partially covered). This can cause very weird visual effects. In your program, the first call to paint will paint the appropriate rectangle but then set the state flag. There is probably another call to repaint somewhere which will then repaint the component without the rectangle (because the state has now changed), painting over your rectangles. The solution, don't change the state in paint.

  • Painting over patterns-- is this even possible?

    Hi all,
    So basically, here's the situation... I'm trying to paint on an element on a layer (belt for jeans) that has been filled with a pattern to match the pants and tie at the waist. (This is a texture map.) The problem is that PS doesn't seem to want to let me ctrl-click the layer and paint over an element that was overlaid with a pattern. If I turn off the pattern, then it works fine, but I need to be able to add more brush elements ON TOP OF the pattern. I'm not sure how to fix this, but it's going to be a problem if I can't. Any ideas?
    Thanks!

    Select the entire belt, add a layer above the belt, and with the belt selected, add a layer mas to the new layer.  Apply your paint to the new layer, and toggle through the new layer's blend modes.  Darken, Multiply, colorburn or Overlay or softlight.  See what works.

  • My imessage stopped working over the wknd when I went to check if it was on it had switched off on its own. Now I try to turn my imessage back on and its giving me some kind of server error. Any suggestions?

    My imessage stopped working over the wknd when I went to check if it was on it had switched off on its own. Now I try to turn my imessage back on and its giving me some kind of server error. Any suggestions?

    Ok actually my mistake it says "an error occurred during activation. try again" I spoke with apple tech support right now and she mentioned they are having trouble with there servers.  Do you by any chance know what the restrictions area means? Should that be activated or deactivated, does that make a difference?

  • My iPhone has stopped working over wifi. It was working till late night yesterday and in monring it stopped. I thought that it may be problem in my internet. But noticed that it doesn't work with office wifi as well. Have done some of the reset option.

    My iPhone has stopped working over wifi. It was working till late night yesterday and in monring it stopped. I thought that it may be problem in my internet. But noticed that it doesn't work with office wifi as well. Have done some of the reset option.

    Follow the steps here. If nothing works, make an appointment at an Apple store or with whoever handles iPhone warranty where you live:
    http://support.apple.com/kb/TS1398

  • My notes have stopped syncing over the air, why?

    my notes from outlook have stopped "syncing " over the air, as apple describes..how do I correct this
    Thanks

    These are the last two things I can think of to try on the iPad at this point - two very basic troubleshooting tips.
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    If these do not work, my only other suggestion would be that some setting went awry in your Outlook client. That's merely a guess, but I assume that it is possible. I don't use Outlook so I have nothing to offer with regard to what the problem may be if it is within Outlook.

  • HT1695 My i-pad has stopped connecting over wi-fi router, my computer is fine.

    My ipad stopped connecting over the wi-fi but my computer still works.

    Some things to try first:
    1. Turn Off your iPad. Then turn Off (disconnect power cord for 30 seconds or longer) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
    2. Go to Settings>Wi-Fi and turn Off. Then while at Settings>Wi-Fi, turn back On and chose a Network.
    3. Change the channel on your wireless router (Auto or Channel 6 is best). Instructions at http://macintoshhowto.com/advanced/how-to-get-a-good-range-on-your-wireless-netw ork.html
    4. Go into your router security settings and change from WEP to WPA with AES.
    5.  Renew IP Address: (especially if you are droping internet connection)
        •    Launch Settings app
        •    Tap on Wi-Fi
        •    Tap on the blue arrow of the Wi-Fi network that you connect to from the list
        •    In the window that opens, tap on the Renew Lease button
    6. Potential Quick Fixes When Your iPad Won’t Connect to Your Wifi Network
    http://ipadinsight.com/ipad-tips-tricks/potential-quick-fixes-when-your-ipad-won t-connect-to-your-wifi-network/
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    Wi-Fi Fix for iOS 6
    https://discussions.apple.com/thread/4823738?tstart=240
    iOS 6 Wifi Problems/Fixes
    How To: Workaround iPad Wi-Fi Issues
    http://www.theipadfan.com/workaround-ipad-wifi-issues/
    Another Fix For iOS 6 WiFi Problems
    http://tabletcrunch.com/2012/10/27/fix-ios-6-wifi-problems-ssid/
    Wifi Doesn't Connect After Waking From Sleep - Sometimes increasing screen brightness prevents the failure to reconnect after waking from sleep. According to Apple, “If brightness is at lowest level, increase it by moving the slider to the right and set auto brightness to off.”
    Fix For iOS 6 WiFi Problems?
    http://tabletcrunch.com/2012/09/27/fix-ios-6-wifi-problems/
    Did iOS 6 Screw Your Wi-Fi? Here’s How to Fix It
    http://gizmodo.com/5944761/does-ios-6-have-a-wi+fi-bug
    How To Fix Wi-Fi Connectivity Issue After Upgrading To iOS 6
    http://www.iphonehacks.com/2012/09/fix-wi-fi-connectivity-issue-after-upgrading- to-ios-6.html
    iOS 6 iPad 3 wi-fi "connection fix" for netgear router
    http://www.youtube.com/watch?v=XsWS4ha-dn0
    Apple's iOS 6 Wi-Fi problems
    http://www.zdnet.com/apples-ios-6-wi-fi-problems-linger-on-7000004799/
    ~~~~~~~~~~~~~~~~~~~~~~~
    How to Boost Your Wi-Fi Signal
    http://ipad.about.com/od/iPad_Troubleshooting/a/How-To-Boost-Your-Wi-Fi-Signal.h tm
    Troubleshooting a Weak Wi-Fi Signal
    http://ipad.about.com/od/iPad_Troubleshooting/a/Troubleshooting-A-Weak-Wi-Fi-Sig nal.htm
    How to Fix a Poor Wi-Fi Signal on Your iPad
    http://ipad.about.com/od/iPad_Troubleshooting/a/How-To-Fix-A-Poor-Wi-Fi-Signal-O n-Your-iPad.htm
    iOS Troubleshooting Wi-Fi networks and connections  http://support.apple.com/kb/TS1398
    iPad: Issues connecting to Wi-Fi networks  http://support.apple.com/kb/ts3304
    WiFi Connecting/Troubleshooting http://www.apple.com/support/ipad/wifi/
    How to Fix: My iPad Won't Connect to WiFi
    http://ipad.about.com/od/iPad_Troubleshooting/ss/How-To-Fix-My-Ipad-Wont-Connect -To-Wi-Fi.htm
    iOS: Connecting to the Internet http://support.apple.com/kb/HT1695
    iOS: Recommended settings for Wi-Fi routers and access points  http://support.apple.com/kb/HT4199
    How to Quickly Fix iPad 3 Wi-Fi Reception Problems
    http://osxdaily.com/2012/03/21/fix-new-ipad-3-wi-fi-reception-problems/
    iPad Wi-Fi Problems: Comprehensive List of Fixes
    http://appletoolbox.com/2010/04/ipad-wi-fi-problems-comprehensive-list-of-fixes/
    Connect iPad to Wi-Fi (with troubleshooting info)
    http://thehowto.wikidot.com/wifi-connect-ipad
    Fix iPad Wifi Connection and Signal Issues  http://www.youtube.com/watch?v=uwWtIG5jUxE
    Fix Slow WiFi Issue https://discussions.apple.com/thread/2398063?start=60&tstart=0
    How To Fix iPhone, iPad, iPod Touch Wi-Fi Connectivity Issue http://tinyurl.com/7nvxbmz
    Unable to Connect After iOS Update - saw this solution on another post.
    https://discussions.apple.com/thread/4010130
    Note - When troubleshooting wifi connection problems, don't hold your iPad by hand. There have been a few reports that holding the iPad by hand, seems to attenuate the wifi signal.
    Wi-Fi or Bluetooth settings grayed out or dim
    http://support.apple.com/kb/TS1559
    ~~~~~~~~~~~~~~~
    If any of the above solutions work, please post back what solved your problem. It will help others with the same problem.
     Cheers, Tom

  • Painting over an applet

    Here is my problem
    I am simply trying to make something paint over an applet. My search brought me to just putting a Canvas over the applet, and then using that to paint, but that didn't work the graphics just return null, and I don't understand why.
    I will try to explain this again
    I am trying to create a component that will paint over another component, which is a client but that shouldn't matter. And I just can't get anything that to paint over it. I know the canvas is in the right spot, but it just doesn't work (grahpics return null when I do getGraphics() in the canvas). Any ideas?
    THANKS

    Austin187 wrote:
    what do I use when I use paint(Graphics g)?Swing is the preferred choice and the Sun tutorials show how to use it (for example in Swing you override "paintComponent" instead of "paint"). Just in case you use AWT, you might want to have a look at this short sample code:
    import java.applet.*;
    import java.awt.*;
    public class AppletDemo extends Applet {
        private Panel content;
        private MainPanel mainPanel;
        @Override
        public void init() {
            try {
                EventQueue.invokeAndWait(new Runnable() {
                    public void run() {
                        content = new Panel();
                        content.setLayout(null);
                        content.add(new PaintOver());
                        mainPanel = new MainPanel();
                        mainPanel.setSize(getSize());
                        content.add(mainPanel);
                        setLayout(new BorderLayout());
                        add(content);
            } catch (Exception ex) {
                ex.printStackTrace();
    class PaintOver extends Panel {
        public PaintOver() {
            setBounds(30, 15, 50, 50);
        @Override
        public void paint(final Graphics g) {
            g.setColor(Color.YELLOW);
            g.fillRect(0, 0, getWidth(), getHeight());
            g.setColor(Color.RED);
            g.drawString("Painting", 5, 20);
            g.drawString("Over", 5, 40);
    class MainPanel extends Panel {
        public MainPanel() {
            setLayout(new BorderLayout());
            add(new Button("Test 1"), BorderLayout.NORTH);
            add(new Button("Test 2"), BorderLayout.WEST);
            add(new Button("Test 3"), BorderLayout.CENTER);
    }

  • Cannot paint over a jpeg suddenly, paint shows up behind on same layer

    When i place an image (jpeg) into photoshop and try to paint over it it will not let me. instead it paints behind the jpeg on that layer. Also, if I create a layer mask on the jpeg it will not paint over it to paint out areas.
    It always worked fine, this issue has come up within the last couple weeks.
    Help would be greatly appreciated, thank you.

    Hi artvector99,
    The first thing that comes to mind is that the mode of the Brush Tool is set to something other than Normal in the tool options bar.

  • Want to paint over unwanted object using background colors

    I have this picture of a nice animated scenery, but there is this huge white square on one side of the image.  The square is covering some trees, grass, and part of the river.  What is the best way to get rid of the square?  Is there some way to take parts of the image and paint it over this square?
    Thanks,
    Blair

    Blair,
    I am now working with PEv.8. If you have this version, the recompose tool is excellent for this. Perhaps this tool is available in an earlier version as well.
    If you don't have the tool, you may want to crop away the white square. Painting over it will do just that.

  • How to stop voice over utility from running

    Accidentally activated voice over utility and now I can get it to stop running, despite uninstalling it.

    Hello Stixs424,
    Thanks for using Apple Support Communities.
    To turn off VoiceOver please follow the directions below.
    You can turn VoiceOver on and off at any time; you don’t have to restart your Mac or log in again.
    Press Command-F5. If VoiceOver is on, pressing Command-F5 turns it off.
    VoiceOver Utility (Mountain Lion): Turn VoiceOver on and off
    Cheers,
    Alex H.

  • USB stop working over my eyes!

    Hi!
    Bad news! One of the USB port on my ibook G4 (2004) stop working juste over my eye. I've put a memory stik in it and the computer was not able to mount it. I pull it out and When I try it again, no light. I've try my mouse in the port: notting!
    The other one works fine.
    What can I do ?????
    Thanks!
    Jef
    IbookG4   Mac OS X (10.3.9)  

    Problem "solved"!
    I've shut down, remove the battery and wait for 5 minutes to "reset" the USB port, and now it is all fine.
    Neverless, I'd really like to understant why that append and what dos it mean to "reset" a USB port...

Maybe you are looking for

  • LED, Chime, Fan... and that's it!  Mini will not boot.

    Greetings, My Mini (stats below) will not boot. The LED lights, the chime sounds, and the fan turns on. However, the HD does not spin and it won't take a DVD. I have reset PRAM/VRAM through the keyboard sequence and through Open Firmware. I have also

  • Bug - VPN Connection Status Doesn't Show

    I added my corporate VPN connection and connected just fine. However, the charms bar nor the Network Connections window reflects the status of the connection. I can view the ip address from a command prompt, but the charms bar only shows "Connect" wh

  • Refreshing Device List

    Hi All, Subsequent to AD discovery with CM I have cleaned up the AD, removing some computers that are no longer used. To-date CM is still showing them in the device listing. I think there is a timeout that can be set so CM will remove machines that a

  • How do I set an alert to let me know when someone comes online in Messages?

    I was pretty sure that in iChat there was a feature to alert me when someone comes online. I can't seem to find this in Messages in Mountain Lion. Does anyone know where that went? Sniffles

  • Need help with raw fine tuning version

    I am a new user of the aperture 2. I just activated my copy of aperture by the trial key provided by apple. Everything looked nice except when I imported some raw images of Fujifilm S5PRO, the raw decoder available are only 1.0 and 1.1. There are no