Custom Border painting over scrollpane and toolbar

I found a LineNumberBorder class in these here forums (I'll post this same question there too) and adapted it to add line numbers to a JTextPane derived class.
When the border is added to the textpane it paints line numbers to the left of each line in the editor.
When this composite (textpane and border) is added to a tabbedpane, all is well, unless I switch to another window. When I come back to the editor, the line numbers are being painted beyond the top and/or bottom of the jscrollpane.
package com.marklawford.editor.textpane;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.text.*;
* LineNumberBorder.java
* Created: Wed Aug 25 22:15:12 1999
* @author Sandip Chitale ([email protected])
* Copyright 1999. All rights reserved.
* originally handled text area components
* adapted by Mark Lawford to accept SyntaxedEditor components which extend JTextPane
* the getLineStartOffset(int i) method had to be implemented in SyntaxedEditor
* the int getLineCount() method had to be implemented in SyntaxedEditor
public class LineNumberBorder extends AbstractBorder {
private Color numberColor;
     public LineNumberBorder() {
     public LineNumberBorder(Color lineNumberColor) {
          numberColor = lineNumberColor;
     * Paints the border for the specified component with the specified
     * position and size.
     * @param c the component for which this border is being painted
     * @param g the paint graphics
     * @param x the x position of the painted border
     * @param y the y position of the painted border
     * @param width the width of the painted border
     * @param height the height of the painted border
     public void paintBorder(Component c, Graphics g, int x, int y, int width, int height){
          if (!(c instanceof SyntaxedEditor)) {
               return;
          Insets insets = getBorderInsets(c);
          Color oldColor = g.getColor();
          if (numberColor == null) numberColor = c.getForeground();
          g.setColor(numberColor);
          g.translate(x, y);
          SyntaxedEditor ta = (SyntaxedEditor) c;
     // Mask the left margin area
          Graphics cg = g.create();
          cg.setClip(0, insets.top, insets.left, height - insets.top);
          Font f = ta.getFont();
          FontMetrics fm = cg.getFontMetrics(f);
          int lines = ta.getLineCount();
          for (int i = 0; i < lines; i++) {
               try {
                    Rectangle r = ta.modelToView(ta.getLineStartOffset(i));
                    int lx = insets.left - fm.stringWidth("W" + (i+1));
                    int ly = r.y + fm.getLeading() + fm.getMaxAscent();
                    //draw the line number (as a string) at the coordinates provided
//how can I tell whether ly is outside of the viewable area?
                    cg.drawString("" + (i+1), lx, ly);
               } catch (BadLocationException ble) {
          cg.dispose();
          g.setColor(oldColor);
     * Returns the insets of the border.
     * @param c the component for which this border insets value applies
     public Insets getBorderInsets(Component c){
          if (!(c instanceof SyntaxedEditor)) {
               return new Insets(0,0,0,0);
          FontMetrics fm = c.getFontMetrics(c.getFont());
          //int margin = fm.stringWidth("WWWW");
          int margin = fm.stringWidth( new String("W"+((SyntaxedEditor)c).getLineCount()) );
          return new Insets(0,margin,0,0);
     * Returns whether or not the border is opaque. If the border
     * is opaque, it is responsible for filling in it's own
     * background when painting.
     public boolean isBorderOpaque(){
          return false;
     public static void main(String args[]){
          JFrame jf = new JFrame();
          Container cp = jf.getContentPane();
          cp.setLayout(new BorderLayout());
          SyntaxedEditor ta = new SyntaxedEditor();
          //all we need to do is this...
          ta.setBorder( new LineNumberBorder(Color.red) );
          //ta.setLineWrap(true);
          cp.add(new JScrollPane(ta), BorderLayout.CENTER);
          jf.setSize(300, 400);
          jf.setVisible(true);
          jf.addWindowListener(new WindowAdapter() {
          public void windowActivated(WindowEvent e) {}
          public void windowClosed(WindowEvent e) {}
          public void windowClosing(WindowEvent e) {System.exit(0);}
          public void windowDeactivated(WindowEvent e) {}
          public void windowDeiconified(WindowEvent e) {}
          public void windowIconified(WindowEvent e) {}
          public void windowOpened(WindowEvent e) {}});
} // LineNumberBorder

The LineNumberBorder just extends AbstractBorder which extends Object, so there can't be any issues about mixing heavy weight and light weight components... can there?
I'm stumped. The border is painting all the line numbers, as I would expect from the code, but the Scrollpane isn't hiding them. The numbers paint right on top of surrounding components until some action on my part causes those comps to explicitly repaint themselves.
Any ideas? Anyone?

Similar Messages

  • Wine-WoW is not maximizing over dock and toolbar anymore

    Hi, today I ran a pacman -Syu and it updated both wine and nvidia (among the kernel and other packages). But now when I start World of Warcraft (I run it with wine) it doesn't maximize over the dock and toolbar anymore.
    I'm running fluxbox (1.1.1-1) and the following updates were installed:
    wine (1.1.5-1 -> 1.1.6-1)
    nvidia (177.80-1 -> 177.80-2)
    kernel26 (2.6.26.5-1 -> 2.6.27-2)
    FEAR runs fine through wine (it still maximizes over dock and toolbar), I have no clue what might cause this weird WoW behaviour.
    edit: seems that 1.1.6 is causing some other trouble with WoW to other users as well, so this might be wine's fault and be fixed at some point (or it might have some other reason).
    Last edited by hybrid (2008-10-14 18:33:35)

    Hi,
    I had similar problems when trying to record OpenGL games with FFMpeg CLI. I use the catalyst-test drivers for my AMD HD 6870.
    You could try downloading SimpleScreenRecorder via yaourt; get both, including the lib32-simplescreenrecorder.
    There will be some conflicts, but choosing to replace some files hasn't caused any problems.
    Make sure you have both  lib32-libpulse and lib32-alsa-plugins installed (pacman).
    Once everything is in set, open SSR (SimpleScreenRecorder); set audio input to:
    - Record Microphone
    - Backend: PulseAudio
    - Source: Monitor of Built-in Audio Analog Stereo
    I chose to output as MKV ; H.264 ; MP3 @128
    Select Start Recording and fire up WoW. I was able to playback the game-play video (full screen 1920x1080) with audio.
    You may need different settings from what I have, notably the audio, but it should record in full screen mode.
    Good luck !

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

  • I am making a graduation video for my cousin using Final Cut Pro. I have photos layered over videos, and I was wanted to find out how you can add a border around the photos so they stand off of the video. Anyone know what I could do?

    I am making a graduation video for my cousin using Final Cut Pro. I have photos layered over videos, and I was wanted to find out how you can add a border around the photos so they stand off of the video. Anyone know what I could do?

    You would need an image editor to edit the images and add a border to the image first before importing them into Final Cut.
    Cheapest and very good image editor?
    PIxelmator.
    Located in the Mac App Store. $14.99 USD.
    Here is the Pixelmator website to give you an overview of the app.
    http://www.pixelmator.com/
    Good Luck!

  • Issues regarding customizing Menus and toolbars

    First i would like to know how i can move the tabs back to below the navigation bar yet still above the bookmarks toolbar.
    Secondly i cannot return the search bar back to the position it was originally before the latest update and if i try to move it anywhere else it become way too large, also the search bar does not have the small blue google symbol on the right side and it no longer says google search.
    If there is no way to change these setting can you please give e directions on how to uninstall the latest update so i can return to my original format as i find it very annoying that every time i update firefox it changer everything and each time has removed customization ability which is supposed to be a prominent feature of firefox.

    Hi Samuel,
    TABS
    There are probbly addons that will achieve this.
    * [[Find and install add-ons to add features to Firefox]]
    This search lists some, but a search from your own machine may give better results
    * https://addons.mozilla.org/firefox/search/?q=tabs&appver=34.0
    * One of the top results is [https://addons.mozilla.org/firefox/addon/tabs-on-bottom/ Tabs On Bottom]
    *Also possibly of interest
    ** [[Customize Firefox controls, buttons and toolbars]]
    **[[Learn more about the design of the new Firefox]]
    SEARCH BAR
    In fact the searchbar is getting to be rather redundant, as there re other searchbars on Firefox: the default homepage,and on newtabs page for instance. Also search terms may be entered direct in to the location bar.
    * [[How to search IMDB, Wikipedia and more from the address bar]]
    * [[Awesome Bar - Find your bookmarks, history and tabs when you type in the address bar]]
    By default there is nothing between the location bar and the searchbar, other than a flexible space, this allows them to be dragged to change their lengths, without even needing to open the customisations ( customisZations ) option. The mouse pointer becomes a double-headed arrow once between the two. You may need to move some fixed icon obstructing the unseen flexible space.
    The change to Yahoo will have caught some by surprise. I wish Firefox had directly advise users of this change, but it is easy to change back.
    After reading this and the linked articles, please post back. Say what you have tried and whether you need me to explain anything in more detail, Thanks John
    '''What has changed?'''<br>
    In the US and Canada, the default search engine has been changed from ''Google'' to ''Yahoo''. In Russia, ''Yandex Search'' will become the default search and in China, ''Baidu'' will continue to be the default search. However, all other search engines will still be available in these regions. You will notice this change in Firefox 34.
    '''Would you like to know more about the change?'''<br>
    See the blog post written by Chris Beard, [https://blog.mozilla.org/blog/2014/11/19/promoting-choice-and-innovation-on-the-web/ New Search Strategy for Firefox: Promoting Choice & Innovation] and the News Release, [https://blog.mozilla.org/press/2014/11/yahoo-and-mozilla-form-strategic-partnership/ Yahoo and Mozilla Form Strategic Partnership].
    '''Do you want to change your default search engine?'''<br>
    In Firefox 33 or below, you would change your default search engine from the Search bar, as shown in [/gallery/image/19894 this animation]. Starting in Firefox 34, you can use one of these methods:<br>
    ''Note: The following may not apply to localized versions of Firefox.''
    * Click the menu button [[Image:New Fx Menu]] and choose '''Options''' on Windows or '''Preferences''' on Mac or Linux, then select the '''Search''' settings panel.
    * Click on the magnifying glass icon in the Search bar, then click on Change Search Settings, as shown here:
    :[[Image:search prefs 34]]
    In the Search settings panel that opens, select a different search engine from the drop-down menu (see [/en-US/gallery/image/20002 this screenshot]).
    For more information, see the article [[Search bar - add, change and manage search engines on Firefox]].

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

  • Why the painted content flash and disappear?

    I try to run a simple code example from java almanac site but the painted content just flash and disappear. Can any people help to find the reason? Thanks in advance.
    Below are the code:
    package font;
    import java.text.AttributedString;
    import java.awt.*;
    import java.awt.font.LineBreakMeasurer;
    import java.awt.font.TextLayout;
    import javax.swing.*;
    public class DrawParagraphDemo extends JPanel {
        public DrawParagraphDemo() {
            this.setPreferredSize(new Dimension(500,500));
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("Demo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            DrawParagraphDemo demo = new DrawParagraphDemo();
            frame.setContentPane(demo);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
            demo.drawParagraph((Graphics2D) demo.getGraphics(), "One line of test string", 400);
        public void drawParagraph(Graphics2D g, String paragraph, float width) {
            LineBreakMeasurer linebreaker = new LineBreakMeasurer(
                new AttributedString(paragraph).getIterator(), g.getFontRenderContext());
            float y = 0.0f;
            while (linebreaker.getPosition() < paragraph.length()) {
                TextLayout tl = linebreaker.nextLayout(width);
                System.out.println(tl);
                y += tl.getAscent();
                tl.draw(g, 0, y);
                y += tl.getDescent() + tl.getLeading();
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

    Hi i have similar problem and i have followed Camickr's suggestion but it looks like my image was still being painted over here's my code
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    * FileChooserDemo2.java is a 1.4 application that requires these files:
    *   ImageFileView.java
    *   ImageFilter.java
    *   ImagePreview.java
    *   Utils.java
    *   images/jpgIcon.gif (required by ImageFileView.java)
    *   images/gifIcon.gif (required by ImageFileView.java)
    *   images/tiffIcon.gif (required by ImageFileView.java)
    *   images/pngIcon.png (required by ImageFileView.java)
    public class Asst4 extends JPanel
                                  implements ActionListener {
        static private String newline = "\n";
        private JTextArea log;
        private JFileChooser fc;
         private JPanel display,button;
         JButton load,grey,color;
         private Image image;
         static JComponent newContentPane;
        public Asst4() {
            super(new BorderLayout());
            //Create the log first, because the action listener
            //needs to refer to it.
              display=new JPanel();
              display.setOpaque(true);
              button=new JPanel();
              load=new JButton("Load Image");
              grey=new JButton("Greyscale Image");
              color=new JButton("Color Image");
              load.addActionListener(this);
              //display.setBackground(Color.BLACK);
              //System.out.println("displayable: "+isDisplayable()+" visible: "+isVisible()+" valid: "+isValid());
              //System.out.println("displayable: "+display.isDisplayable()+" visible: "+display.isVisible()+" valid: "+display.isValid());
              display.setSize(500,500);
              button.add(load, BorderLayout.WEST);
              button.add(grey, BorderLayout.CENTER);
              button.add(color, BorderLayout.EAST);
              add(button,BorderLayout.NORTH);
              add(display,BorderLayout.CENTER);
              setVisible(true);
        public void actionPerformed(ActionEvent e) {
                   //Set up the file chooser.
                   if (fc == null) {
                        fc = new JFileChooser();
                        //Add a custom file filter and disable the default
                        //(Accept All) file filter.
                        fc.addChoosableFileFilter(new ImageFilter());
                        fc.setAcceptAllFileFilterUsed(false);
                        //Add custom icons for file types.
                        fc.setFileView(new ImageFileView());
                        //Add the preview pane.
                        fc.setAccessory(new ImagePreview(fc));
                        //Show it.
                   int returnVal = fc.showDialog(Asst4.this,"Load Image");
                   //Process the results.
                   if (returnVal == JFileChooser.APPROVE_OPTION) {
                        File file = fc.getSelectedFile();
                        Toolkit toolkit = Toolkit.getDefaultToolkit();
                        image = toolkit.getImage(file.getAbsolutePath());
                        MediaTracker mediaTracker = new MediaTracker(this);
                        mediaTracker.addImage(image,0);
                        try {
                           mediaTracker.waitForID(0);
                        } catch (InterruptedException ie) {
                           System.err.println(ie);
                           System.exit(1);
                   } else {
                        System.out.println("Loading cancelled by user." );
                   fc.setSelectedFile(null);
        protected void paintComponent(Graphics g)
              super.paintComponent(g); // this paints the background
              if(image!=null)
              drawImage(image);
        private void drawImage(Image image){
              Graphics2D g=(Graphics2D)display.getGraphics();
              g.drawImage(image,0,0,null);
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("Compsci_375_Assignment_4");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            newContentPane = new Asst4();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.setBounds(50,50,500,500);
               //frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }Can anyone tell me what's going on and also why if i pack the frame my display panel is disappear?
    Thanks a lot

  • 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

  • Who can I talk to that can help me decide Edge over Contracts and new phones?

    My phone is due for an upgrade. I have two other phones on my contract but their phones aren't eligible until July 14 and June 15. I want a breakdown of both the contract more everything plan and the edge more everything plan. I would like to try and sync all three phones together with the same date for renewal. I spoke to a customer service rep last night who told me it would e 180 for three new phones and monthly total charges for what I wanted. She did not email as she indicated she would with all the breakdowns for what I asked for. Is there anyone at verizon that knows what they are doing? You keep saying you don't want to lose customers but if this is the way you do business, it isn't any wonder people are leaving. I am very frustrated and have been a customer for well over 15 years.
    Help please.

    What breakdown do you want. If you look on the website, the monthly Edge price is listed next to each phone. The one time contract price is listed next to each phone. Information on the More Everything plan is listed HERE. If entering into a new contract, there is a $30 upgrade fee for each line upgrading on contract.
    If you purchase a phone on the Edge plan and have less than 10 GB monthly allowance, you will get a $10/month discount on your phone access fee. If you have 10 GB or more monthly allowance, you will get a $25/month discount on your phone access fee.
    If you want to sync all three phones together with the same date for renewal, it sounds as if you want to enter into a contract. To do so, you would have to wait until your other 2 phones have completed their contracts and then purchase 3 new phones at the same time. Then you would be able to get a discounted upgrade again on all 3 lines in 2 years.
    If you want to sync on the Edge plan, you could currently upgrade all 3 lines. With the 2 lines still under contract, you would have to return them to Verizon in good working order to upgrade onto the Edge plan. With the line out of contract, you would not have to return the phone to Verizon. You would then be able to upgrade again on all 3 lines in as little as 30 days, once you have paid off 50% of your phones cost. If upgrading before 12 months, you would have a baloon payment on each of the phones to bring the total of your payments up to 50% of the phone's cost. Once you reach the 12 month point in your payments, you will have already paid 50% of the phone's cost and would therefore not have the balloon payment. When upgrading on Edge, you will have to return the phones in good working order to upgrade. Once you have completed your Edge payments, though, you would be able to keep the phone.

  • Can't Change Custom Border Custom Styles

    I created a custom border class to create a dashed line
    border, and I added two custom style properties "dashlen" and
    "gaplen", but I can't set them.
    In the attached code, the default dashlen and gaplen are 5. I
    create three VBox using the DashBorder, and although I have created
    a type selector style for DashBorder and a class selector style
    tightDashBorder, neither one is applied.
    Also, I get errors when I try to access the style properties
    dashlen and gaplen in the <mx:VBox> tag. I can access the
    borderColor style property though.
    What more must I do to fix this? Thanks in advance!!!

    I didn't have time to analyze your code in depth. Where was
    the issue?
    "Greg Lafrance" <[email protected]> wrote in
    message
    news:[email protected]...
    > Solved it. Turns out it was much simpler than I had
    thought.
    >
    > ------------------ DashBorder.as
    > package
    > {
    > import mx.core.UIComponent;
    >
    > public class DashBorder extends UIComponent{
    > private var dashlen:Number = 5;
    > private var gaplen:Number = 5;
    >
    > public function DashBorder(){
    > super();
    > }
    >
    > override protected function updateDisplayList
    > (unscaledWidth:Number, unscaledHeight:Number):void{
    >
    > super.updateDisplayList(unscaledWidth, unscaledHeight);
    >
    > var borderThickness:int = getStyle("borderThickness");
    > var borderColor:int = getStyle("borderColor");
    >
    > graphics.clear();
    > graphics.lineStyle(borderThickness, borderColor, 1)
    >
    > if (getStyle("dashlen")) {
    > this.dashlen = getStyle("dashlen");
    > }
    > if (getStyle("gaplen")) {
    > this.gaplen = getStyle("gaplen");
    > }
    >
    > drawBorder(this.x, this.y, unscaledWidth,
    unscaledHeight,
    > this.dashlen, this.gaplen);
    > }
    >
    > public function drawLine(x1:Number, y1:Number,
    x2:Number, y2:Number,
    > dashlen:Number, gaplen:Number): void {
    > if((x1 != x2) || (y1 != y2)){
    > var incrlen:Number = dashlen + gaplen;
    >
    > var len:Number = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 -
    y2) *
    > (y1 -
    > y2));
    > var angle:Number = Math.atan((y2 - y1) / (x2 - x1));
    > var steps:uint = len / (dashlen + gaplen);
    >
    > var dashstepx:Number = dashlen * Math.cos(angle);
    > if (x2 < x1) dashstepx *= -1;
    >
    > var dashstepy:Number = dashlen * Math.sin(angle);
    >
    > var gapstepx:Number = gaplen * Math.cos(angle);
    > if (x2 < x1) gapstepx *= -1;
    >
    > var gapstepy:Number = gaplen * Math.sin(angle);
    > var stepcount:uint = 0;
    >
    > while ((stepcount++) < steps) {
    >
    > var dashstartx:Number;
    > var dashstarty:Number;
    > var dashendx:Number;
    > var dashendy:Number;
    >
    > if(x1 == x2 && y1 != y2){
    > dashstartx = dashendx = x1;
    > if(y2 > y1){
    > dashstarty = y1 + ((stepcount-1) * (dashlen + gaplen));
    >
    > dashendy = dashstarty + dashlen;
    > }else{
    > dashstarty = y1 - ((stepcount-1) * (dashlen + gaplen));
    >
    > dashendy = dashstarty - dashlen;
    > }
    > }else if(y1 == y2 && x1 != x2){
    > dashstarty = dashendy = y1;
    > if(x2 > x1){
    > dashstartx = x1 + ((stepcount-1) * (dashlen + gaplen));
    > dashendx = dashstartx + dashlen;
    > }else{
    > dashstartx = x1 - ((stepcount-1) * (dashlen + gaplen));
    > dashendx = dashstartx - dashlen;
    > }
    > }
    > graphics.moveTo(dashstartx, dashstarty);
    > graphics.lineTo(dashendx, dashendy);
    > }
    > }
    > }
    >
    > private function drawBorder(x1:Number, y1:Number,
    width:Number,
    > height:Number,
    > dashlen:Number, gaplen:Number) : void {
    > drawLine(x1, y1, x1 + width, y1, dashlen, gaplen);
    > drawLine(x1 + width, y1, x1 + width, y1 + height,
    dashlen, gaplen);
    > drawLine(x1 + width, y1 + height, x1, y1 + height,
    dashlen, gaplen);
    > drawLine(x1, y1 + height, x1, y1, dashlen, gaplen);
    > }
    > }
    > }
    > ---------------------- DashBorderExample.mxml
    > <?xml version="1.0" encoding="utf-8"?>
    > <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    > verticalGap="20">
    > <mx:Style>
    > DashBorder {
    > dashlen: 20;
    > gaplen: 20;
    > }
    > .tightDashBorder {
    > dashlen: 2;
    > gaplen: 2;
    > }
    > .tightDashWideGapBorder {
    > dashlen: 2;
    > gaplen: 20;
    > }
    > .wideDashTightGapBorder {
    > dashlen: 20;
    > gaplen: 2;
    > }
    > </mx:Style>
    > <mx:HBox horizontalGap="30">
    > <mx:VBox borderSkin="DashBorder"
    > borderThickness="1" borderColor="0xFF0000"
    > width="200" height="200">
    > </mx:VBox>
    > <mx:VBox borderSkin="DashBorder"
    > borderThickness="1" borderColor="0xFF0000"
    > width="200" height="200" styleName="tightDashBorder">
    > </mx:VBox>
    > </mx:HBox>
    > <mx:HBox horizontalGap="30">
    > <mx:VBox borderSkin="DashBorder"
    > borderThickness="1" borderColor="0xFF0000"
    > width="200" height="200"
    styleName="tightDashWideGapBorder">
    > </mx:VBox>
    > <mx:VBox borderSkin="DashBorder"
    > borderThickness="1" borderColor="0xFF0000"
    > width="200" height="200"
    styleName="wideDashTightGapBorder">
    > </mx:VBox>
    > </mx:HBox>
    > </mx:Application>
    >

  • Receiving Custom XML Document over AS2 (HTTPS) - Inbound Processing

    Hi All,
    Need help in Receiving Custom XML Document over AS2 (HTTPS) - Inbound Processing
    External Trading Partner will be able to post the XML Documents to https://<b2bconsolehost>:<b2bconsoleport>/b2b/httpReceiver.
    Here is the process flow:
    1. External Trading Partner will be posting the XML Documents to https://<b2bconsolehost>:<b2bconsoleport>/b2b/httpReceiver
    2. B2B, consumes the Custom XML validates as per the XSD and process it.
    3. How to send the ACK back to External Trading Partner if it validates successfully and sent it to 'IP_IN_QUEUE'
    4. How to send the ACK back to External Trading Partner if the validation fails after receiving the XML document.
    5. Does the External Trading Partner require any certificates to post the XML Documents to https://<b2bconsolehost>:<b2bconsoleport>/b2b/httpReceiver (no need of encryption/decryption)?
    6. How to enable the B2B server to accept the HTTPS messages from the Trading Partner (no need of encryption/decryption).
    Please let me know. Thanks In Advance.
    Regards,
    Amirineni

    Hi Nandu, Ramesh,
    We have done the set-ups for transmitting a Custom XML Document over HTTP1.1 in B2B.
    Our Business Case is as follows:
    1. Read the Flat File using BPEL File Adapter
    2. Transform the Message in BPEL and send it to B2B
    2. Based on the set-ups in B2B, we need to post the XML message to the folliwng URL:-
    http://databridge.buy.datastream.net:5555/invoke/dsImport/receiveXML
    In the B2B Set-Ups, I have done the following:
    Business Protocol name: Custom Document over Internet
    Exchange Protocol: AS
    Document Protocol: Custom
    Transport Protocol: HTTP-1.1
    Host name : http://databridge.buy.datastream.net
    Port: 5555
    I have also deployed the agreement as well as the configuration. The issue that I am currently facing is when I select the configuration in WSIL browser in JDeveloper, I am getting the following error:
    "Unable to get schema information for target".
    Hence I am not able to map the message in BPEL and send it to B2B.
    Could you please let me know the possible causes and if I am missing anything in the set-ups in B2B.
    As always, your help and guidance is highly appreciated.
    Thanks,
    Dibya

  • Custom XML Document over AS2

    Hi All,
    We are planning to send Custom XML Document over HTTP(AS2) to the Remote Trading Partner. The XML Document needs to be posted to a particular URL in the Remote Trading Partner Site.Here is the process flow:
    1. The input application format file having the messages will be transformed to an XML message in BPEL.
    2. Then as per the set-ups done in B2B, this particular XML message needs to be posted to a URL.
    I went through the B2B User's Guide but could not find any documentation on how to set up Custom XML Document over HTTP(AS2).
    Could you please share the documents/technical notes or link which I can refer to do the set-ups in B2B.
    Please let me know. Thanks In Advance.
    Regards,
    DIbya

    Hi Nandu, Ramesh,
    We have done the set-ups for transmitting a Custom XML Document over HTTP1.1 in B2B.
    Our Business Case is as follows:
    1. Read the Flat File using BPEL File Adapter
    2. Transform the Message in BPEL and send it to B2B
    2. Based on the set-ups in B2B, we need to post the XML message to the folliwng URL:-
    http://databridge.buy.datastream.net:5555/invoke/dsImport/receiveXML
    In the B2B Set-Ups, I have done the following:
    Business Protocol name: Custom Document over Internet
    Exchange Protocol: AS
    Document Protocol: Custom
    Transport Protocol: HTTP-1.1
    Host name : http://databridge.buy.datastream.net
    Port: 5555
    I have also deployed the agreement as well as the configuration. The issue that I am currently facing is when I select the configuration in WSIL browser in JDeveloper, I am getting the following error:
    "Unable to get schema information for target".
    Hence I am not able to map the message in BPEL and send it to B2B.
    Could you please let me know the possible causes and if I am missing anything in the set-ups in B2B.
    As always, your help and guidance is highly appreciated.
    Thanks,
    Dibya

  • Resizing ScrollPane and Dimension dynamically

    I am currently making a scrollbar program using ScrollPane and Dimension. I have to use those classes.
    When I click "ok" button, that calls dc.enlarge(500,800) method. But it doesn't work.
    When it is clicked, Dimension object should be changed and the panel has to show Horizotal
    and Vertical scrollbar according to the width and height parameters.
    Of course, the size will be calculated by the String contents object's rows and width. But it does not work.
    How to resize the Dimension and How to display the Horizontal, Vertical scrollbar accoring to dc.enlarge's parameters?
    Plz... help me...
    -------------- ScrollerTest.java -----------------------------------------------
    import java.awt.*;
    import java.applet.Applet;
    public class ScrollerTest extends Applet {
       public Scroller sc = null;
        public void init() {
            sc = new Scroller(700,250);
            sc.setVisible(true);
         add(sc);         
    }-------------- Scroller.java -----------------------------------------------
    import java.awt.*;
    import java.awt.Window;
    import java.applet.Applet;
    import java.awt.event.*;
    public class Scroller extends Panel implements  ActionListener {
        private Button btOk;   
        private int width = 0;
        private int height = 0;   
        private DrawCanvas dc;   
        public Scroller(int width, int height){   
            this.width = width;
            this.height = height;   
            dc = new DrawCanvas(width, height);
            setNewsContents();                           
        private void setNewsContents() {
            setLayout(new BorderLayout());
            ScrollPane scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);       
            scroller.add(dc);
            Adjustable vadjust = scroller.getVAdjustable();
            Adjustable hadjust = scroller.getHAdjustable();
            hadjust.setUnitIncrement(10);
            vadjust.setUnitIncrement(10);
            scroller.setSize(615     , 272);
            btOk = new Button("ok");
            btOk.addActionListener(this);
            add("Center", scroller);
            add("South", btOk);       
        public void actionPerformed(ActionEvent event) {
            if(event.getSource()==btOk) {
                dc.enlarge(500,800);
                dc.validate();
    }    -------------- DrawCanvas.java -----------------------------------------------
    import java.awt.*;
    class DrawCanvas extends Component {
        private int width = 0;
        private int height = 0;
        private Dimension d;
        public DrawCanvas(int width, int height) {
            this.width = width;
            this.height = height;
       Dimension theSize = new Dimension(300, 200);   
       public Dimension getPreferredSize() {
            return new Dimension(width,height);               
       public void enlarge(int width, int height) {       
            theSize.width =  width;
            theSize.height = height;
            setSize(theSize);       
        public void update(Graphics g) {
            paint(g);
        public void paint(Graphics g) {       
            Rectangle r = getBounds();       
            String contents[] = {
            "addition to its usual stable of Clydesdale horses, the company will also enlist help this year ",
            "from racing star Dale Earnhardt Jr., some beer-thieving crabs and a scary hitchhiker.",       
            "The Super Bowl represents an enormous commitment for Budweiser. Bob Lachky, chief creative" ,
            "officer of Anheuser-Busch, said the St. Louis-based brewer has been advertising on the game since 1976 and has been the exclusive alcoholic beverage sponsor since 1989",
            "since 1976 and has been the exclusive alcoholic beverage sponsor since 1989, an arrangement that runs through 2012.",
            "It's important to us because it kicks off our selling season, it's the best platform",
            "possible to launch new ideas or to sustain existing campaigns, and it's absolutely the most efficient way to reach the most  it's absolutely the most efficient way to reach the most",
            "adult consumers in one sitting,",
            "Despite the rise of cable, the Internet other media to compete with broadcast television iewers and enticing a huge array of marketers ",
            ", the Super Bowl remains the most-viewed media event all year, drawing in some 90 million ",
            "viewers and enticing a huge array of marketers to pony up the big bucks for an ad",
            ", the price of which is running as high as $2.6 million for this year's broadcast",
            "on CBS Corp.'s CBS network, up slightly from about a top price of about $2.5 million last year.",
            "Comedian Carlos Mencia, of the Comedy Central show  gets ",
            "a big break with a spot set in a classroom. Lachky predicts that Mencia will get an enormous boost Lachky predicts that Mencia will get an enormous boost ",
            "following the appearance, which similarly did wonders for Cedric the Entertainer.",
            "And what would Budweiser Super Bowl ads be without some animated critters? This year, a ga",
            "ng of mischievous red crabs turn up on a beach to carry off a cooler full of beers. As in past years, Bud is keeping many ",
            g.setColor(new Color(226,250,255));
            g.fillRect(0, 0, r.width, r.height);
            g.setColor(new Color(233,231,224));            
            int line = 35;
            int line_1 = 39;
            for (int i = 0; i < contents.length; i++) {       
                 g.setColor(Color.BLACK);
                 g.drawString(contents, 5,line);
         g.setColor(new Color(233,231,224));
         g.drawLine(0,line_1,605,line_1);
         line += 20;
         line_1 += 20;

    I am currently making a scrollbar program using ScrollPane and Dimension. I have to use those classes.
    When I click "ok" button, that calls dc.enlarge(500,800) method. But it doesn't work.
    When it is clicked, Dimension object should be changed and the panel has to show Horizotal
    and Vertical scrollbar according to the width and height parameters.
    Of course, the size will be calculated by the String contents object's rows and width. But it does not work.
    How to resize the Dimension and How to display the Horizontal, Vertical scrollbar accoring to dc.enlarge's parameters?
    Plz... help me...
    -------------- ScrollerTest.java -----------------------------------------------
    import java.awt.*;
    import java.applet.Applet;
    public class ScrollerTest extends Applet {
       public Scroller sc = null;
        public void init() {
            sc = new Scroller(700,250);
            sc.setVisible(true);
         add(sc);         
    }-------------- Scroller.java -----------------------------------------------
    import java.awt.*;
    import java.awt.Window;
    import java.applet.Applet;
    import java.awt.event.*;
    public class Scroller extends Panel implements  ActionListener {
        private Button btOk;   
        private int width = 0;
        private int height = 0;   
        private DrawCanvas dc;   
        public Scroller(int width, int height){   
            this.width = width;
            this.height = height;   
            dc = new DrawCanvas(width, height);
            setNewsContents();                           
        private void setNewsContents() {
            setLayout(new BorderLayout());
            ScrollPane scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);       
            scroller.add(dc);
            Adjustable vadjust = scroller.getVAdjustable();
            Adjustable hadjust = scroller.getHAdjustable();
            hadjust.setUnitIncrement(10);
            vadjust.setUnitIncrement(10);
            scroller.setSize(615     , 272);
            btOk = new Button("ok");
            btOk.addActionListener(this);
            add("Center", scroller);
            add("South", btOk);       
        public void actionPerformed(ActionEvent event) {
            if(event.getSource()==btOk) {
                dc.enlarge(500,800);
                dc.validate();
    }    -------------- DrawCanvas.java -----------------------------------------------
    import java.awt.*;
    class DrawCanvas extends Component {
        private int width = 0;
        private int height = 0;
        private Dimension d;
        public DrawCanvas(int width, int height) {
            this.width = width;
            this.height = height;
       Dimension theSize = new Dimension(300, 200);   
       public Dimension getPreferredSize() {
            return new Dimension(width,height);               
       public void enlarge(int width, int height) {       
            theSize.width =  width;
            theSize.height = height;
            setSize(theSize);       
        public void update(Graphics g) {
            paint(g);
        public void paint(Graphics g) {       
            Rectangle r = getBounds();       
            String contents[] = {
            "addition to its usual stable of Clydesdale horses, the company will also enlist help this year ",
            "from racing star Dale Earnhardt Jr., some beer-thieving crabs and a scary hitchhiker.",       
            "The Super Bowl represents an enormous commitment for Budweiser. Bob Lachky, chief creative" ,
            "officer of Anheuser-Busch, said the St. Louis-based brewer has been advertising on the game since 1976 and has been the exclusive alcoholic beverage sponsor since 1989",
            "since 1976 and has been the exclusive alcoholic beverage sponsor since 1989, an arrangement that runs through 2012.",
            "It's important to us because it kicks off our selling season, it's the best platform",
            "possible to launch new ideas or to sustain existing campaigns, and it's absolutely the most efficient way to reach the most  it's absolutely the most efficient way to reach the most",
            "adult consumers in one sitting,",
            "Despite the rise of cable, the Internet other media to compete with broadcast television iewers and enticing a huge array of marketers ",
            ", the Super Bowl remains the most-viewed media event all year, drawing in some 90 million ",
            "viewers and enticing a huge array of marketers to pony up the big bucks for an ad",
            ", the price of which is running as high as $2.6 million for this year's broadcast",
            "on CBS Corp.'s CBS network, up slightly from about a top price of about $2.5 million last year.",
            "Comedian Carlos Mencia, of the Comedy Central show  gets ",
            "a big break with a spot set in a classroom. Lachky predicts that Mencia will get an enormous boost Lachky predicts that Mencia will get an enormous boost ",
            "following the appearance, which similarly did wonders for Cedric the Entertainer.",
            "And what would Budweiser Super Bowl ads be without some animated critters? This year, a ga",
            "ng of mischievous red crabs turn up on a beach to carry off a cooler full of beers. As in past years, Bud is keeping many ",
            g.setColor(new Color(226,250,255));
            g.fillRect(0, 0, r.width, r.height);
            g.setColor(new Color(233,231,224));            
            int line = 35;
            int line_1 = 39;
            for (int i = 0; i < contents.length; i++) {       
                 g.setColor(Color.BLACK);
                 g.drawString(contents, 5,line);
         g.setColor(new Color(233,231,224));
         g.drawLine(0,line_1,605,line_1);
         line += 20;
         line_1 += 20;

  • Resizing ScrollPane and Dimension

    I am currently making a scrollbar program using ScrollPane and Dimension. I have to use those classes.
    When I click "ok" button, that calls dc.enlarge(500,800) method. But it doesn't work.
    When it is clicked, Dimension object should be changed and the panel has to show Horizotal
    and Vertical scrollbar according to the width and height parameters.
    Of course, the size will be calculated by the String contents object's rows and width. But it does not work.
    How to resize the Dimension and How to display the Horizontal, Vertical scrollbar accoring to dc.enlarge's parameters?
    Plz... help me...
    -------------- ScrollerTest.java -----------------------------------------------
    import java.awt.*;
    import java.applet.Applet;
    public class ScrollerTest extends Applet {
       public Scroller sc = null;
        public void init() {
            sc = new Scroller(700,250);
            sc.setVisible(true);
         add(sc);         
    }-------------- Scroller.java -----------------------------------------------
    import java.awt.*;
    import java.awt.Window;
    import java.applet.Applet;
    import java.awt.event.*;
    public class Scroller extends Panel implements  ActionListener {
        private Button btOk;   
        private int width = 0;
        private int height = 0;   
        private DrawCanvas dc;   
        public Scroller(int width, int height){   
            this.width = width;
            this.height = height;   
            dc = new DrawCanvas(width, height);
            setNewsContents();                           
        private void setNewsContents() {
            setLayout(new BorderLayout());
            ScrollPane scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);       
            scroller.add(dc);
            Adjustable vadjust = scroller.getVAdjustable();
            Adjustable hadjust = scroller.getHAdjustable();
            hadjust.setUnitIncrement(10);
            vadjust.setUnitIncrement(10);
            scroller.setSize(615     , 272);
            btOk = new Button("ok");
            btOk.addActionListener(this);
            add("Center", scroller);
            add("South", btOk);       
        public void actionPerformed(ActionEvent event) {
            if(event.getSource()==btOk) {
                dc.enlarge(500,800);
                dc.validate();
    }    -------------- DrawCanvas.java -----------------------------------------------
    import java.awt.*;
    class DrawCanvas extends Component {
        private int width = 0;
        private int height = 0;
        private Dimension d;
        public DrawCanvas(int width, int height) {
            this.width = width;
            this.height = height;
       Dimension theSize = new Dimension(300, 200);   
       public Dimension getPreferredSize() {
            return new Dimension(width,height);               
       public void enlarge(int width, int height) {       
            theSize.width =  width;
            theSize.height = height;
            setSize(theSize);       
        public void update(Graphics g) {
            paint(g);
        public void paint(Graphics g) {       
            Rectangle r = getBounds();       
            String contents[] = {
            "addition to its usual stable of Clydesdale horses, the company will also enlist help this year ",
            "from racing star Dale Earnhardt Jr., some beer-thieving crabs and a scary hitchhiker.",       
            "The Super Bowl represents an enormous commitment for Budweiser. Bob Lachky, chief creative" ,
            "officer of Anheuser-Busch, said the St. Louis-based brewer has been advertising on the game since 1976 and has been the exclusive alcoholic beverage sponsor since 1989",
            "since 1976 and has been the exclusive alcoholic beverage sponsor since 1989, an arrangement that runs through 2012.",
            "It's important to us because it kicks off our selling season, it's the best platform",
            "possible to launch new ideas or to sustain existing campaigns, and it's absolutely the most efficient way to reach the most  it's absolutely the most efficient way to reach the most",
            "adult consumers in one sitting,",
            "Despite the rise of cable, the Internet other media to compete with broadcast television iewers and enticing a huge array of marketers ",
            ", the Super Bowl remains the most-viewed media event all year, drawing in some 90 million ",
            "viewers and enticing a huge array of marketers to pony up the big bucks for an ad",
            ", the price of which is running as high as $2.6 million for this year's broadcast",
            "on CBS Corp.'s CBS network, up slightly from about a top price of about $2.5 million last year.",
            "Comedian Carlos Mencia, of the Comedy Central show  gets ",
            "a big break with a spot set in a classroom. Lachky predicts that Mencia will get an enormous boost Lachky predicts that Mencia will get an enormous boost ",
            "following the appearance, which similarly did wonders for Cedric the Entertainer.",
            "And what would Budweiser Super Bowl ads be without some animated critters? This year, a ga",
            "ng of mischievous red crabs turn up on a beach to carry off a cooler full of beers. As in past years, Bud is keeping many ",
            g.setColor(new Color(226,250,255));
            g.fillRect(0, 0, r.width, r.height);
            g.setColor(new Color(233,231,224));            
            int line = 35;
            int line_1 = 39;
            for (int i = 0; i < contents.length; i++) {       
                 g.setColor(Color.BLACK);
                 g.drawString(contents, 5,line);
         g.setColor(new Color(233,231,224));
         g.drawLine(0,line_1,605,line_1);
         line += 20;
         line_1 += 20;

    The class names have been changed so you can run this as-is without name-clashing.
    //  <applet code="ST" width="720" height="300"></applet>
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
    public class ST extends Applet {
        public ScrollerRx sc;
        public void init() {
            sc = new ScrollerRx(700,250);
            add(sc);
    class ScrollerRx extends Panel implements ActionListener {
        private Button btOk;
        private DrawCanvasRx dc;
        public ScrollerRx(int width, int height) {
            dc = new DrawCanvasRx(width, height);
            setNewsContents();
        private void setNewsContents() {
            setLayout(new BorderLayout());
            ScrollPane scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
            scroller.add(dc);
            Adjustable vadjust = scroller.getVAdjustable();
            Adjustable hadjust = scroller.getHAdjustable();
            hadjust.setUnitIncrement(10);
            vadjust.setUnitIncrement(10);
            scroller.setSize(615, 272);
            btOk = new Button("ok");
            btOk.addActionListener(this);
            add("Center", scroller);
            add("South", btOk);
        public void actionPerformed(ActionEvent event) {
            if(event.getSource()==btOk) {
                dc.enlarge(500,800);
                // validate is a Container method.
                validate();
    class DrawCanvasRx extends Component {
        Dimension theSize = new Dimension(300, 200);
        String[] contents = {
            "addition to its usual stable of Clydesdale horses, the company will " +
            "also enlist help this year ",
            "from racing star Dale Earnhardt Jr., some beer-thieving crabs and a " +
            "scary hitchhiker.",       
            "The Super Bowl represents an enormous commitment for Budweiser. Bob " +
            "Lachky, chief creative" ,
            "officer of Anheuser-Busch, said the St. Louis-based brewer has been " +
            "advertising on the game since 1976 and has been the exclusive alcoholic " +
            "beverage sponsor since 1989",
            "since 1976 and has been the exclusive alcoholic beverage sponsor since " +
            "1989, an arrangement that runs through 2012.",
            "It's important to us because it kicks off our selling season, it's the " +
            "best platform",
            "possible to launch new ideas or to sustain existing campaigns, and it's " +
            "absolutely the most efficient way to reach the most  it's absolutely " +
            "the most efficient way to reach the most",
            "adult consumers in one sitting,",
            "Despite the rise of cable, the Internet other media to compete with " +
            "broadcast television iewers and enticing a huge array of marketers ",
            ", the Super Bowl remains the most-viewed media event all year, drawing " +
            "in some 90 million ",
            "viewers and enticing a huge array of marketers to pony up the big bucks " +
            "for an ad",
            ", the price of which is running as high as $2.6 million for this year's " +
            "broadcast",
            "on CBS Corp.'s CBS network, up slightly from about a top price of about " +
            "$2.5 million last year.",
            "Comedian Carlos Mencia, of the Comedy Central show  gets ",
            "a big break with a spot set in a classroom. Lachky predicts that Mencia " +
            "will get an enormous boost Lachky predicts that Mencia will get an " +
            "enormous boost ",
            "following the appearance, which similarly did wonders for Cedric the " +
            "Entertainer.",
            "And what would Budweiser Super Bowl ads be without some animated " +
            "critters? This year, a ga",
            "ng of mischievous red crabs turn up on a beach to carry off a cooler " +
            "full of beers. As in past years, Bud is keeping many ",
        public DrawCanvasRx(int width, int height) {
            theSize.setSize(width, height);
        public Dimension getPreferredSize() {
            System.out.printf("theSize = [%d, %d]%n", theSize.width, theSize.height);
            return theSize;
        public void enlarge(int width, int height) {
            theSize.width  = width;
            theSize.height = height;
            // Mark this component as needing a new layout.
            invalidate();
        public void update(Graphics g) {
            paint(g);
        public void paint(Graphics g) {
            Rectangle r = getBounds();
            g.setColor(new Color(226,250,255));
            g.fillRect(0, 0, r.width, r.height);
            g.setColor(new Color(233,231,224));
            int line = 35;
            int line_1 = 39;
            for (int i = 0; i < contents.length; i++) {
                g.setColor(Color.BLACK);
                 g.drawString(contents, 5, line);
         g.setColor(new Color(233,231,224));
         g.drawLine(0, line_1, 605, line_1);
         line += 20;
         line_1 += 20;

Maybe you are looking for