Repainting the frame

Hi all,
I have put the source code (modified from http://java.sun.com/docs/books/tutorial/uiswing/learn/example6.html) of a simple swing application. I ve added a sleep method under my comment /* My modification */
Please run this program selecting "Canditate1" (radio button) and click the "Vote" button. You will get a gray background (in my theme) until this sleep method finishes its execution. Is there any way of avoiding this gray background so that even when the sleep method is executing, my window should be repainted, without forming a gray background. Even i tried by calling repaint() method, but still it is not working. Can anybody help me on this issue??????????
* VoteDialog.java is a 1.4 example that requires
* no other files.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class VoteDialog extends JPanel {
JLabel label;
JFrame frame;
String simpleDialogDesc = "The candidates";
public VoteDialog(JFrame frame) {
super(new BorderLayout());
this.frame = frame;
JLabel title;
//Create the components.
JPanel choicePanel = createSimpleDialogBox();
System.out.println("passed createSimpleDialogBox");
title = new JLabel("Click the \"Vote\" button"
+ " once you have selected a candidate.",
JLabel.CENTER);
label = new JLabel("Vote now!", JLabel.CENTER);
label.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
choicePanel.setBorder(BorderFactory.createEmptyBorder(20,20,5,20));
//Lay out the main panel.
add(title, BorderLayout.NORTH);
add(label, BorderLayout.SOUTH);
add(choicePanel, BorderLayout.CENTER);
void setLabel(String newText) {
label.setText(newText);
private JPanel createSimpleDialogBox() {
final int numButtons = 4;
JRadioButton[] radioButtons = new JRadioButton[numButtons];
final ButtonGroup group = new ButtonGroup();
JButton voteButton = null;
final String defaultMessageCommand = "default";
final String yesNoCommand = "yesno";
final String yeahNahCommand = "yeahnah";
final String yncCommand = "ync";
radioButtons[0] = new JRadioButton(
"<html>Candidate 1: <font color=red>Sparky the Dog</font></html>");
radioButtons[0].setActionCommand(defaultMessageCommand);
radioButtons[1] = new JRadioButton(
"<html>Candidate 2: <font color=green>Shady Sadie</font></html>");
radioButtons[1].setActionCommand(yesNoCommand);
radioButtons[2] = new JRadioButton(
"<html>Candidate 3: <font color=blue>R.I.P. McDaniels</font></html>");
radioButtons[2].setActionCommand(yeahNahCommand);
radioButtons[3] = new JRadioButton(
"<html>Candidate 4: <font color=maroon>Duke the Java<font size=-2><sup>TM</sup></font size> Platform Mascot</font></html>");
radioButtons[3].setActionCommand(yncCommand);
for (int i = 0; i < numButtons; i++) {
group.add(radioButtons);
//Select the first button by default.
radioButtons[0].setSelected(true);
voteButton = new JButton("Vote");
voteButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String command = group.getSelection().getActionCommand();
//ok dialog
if (command == defaultMessageCommand) {
JOptionPane.showMessageDialog(frame,
"This candidate is a dog. Invalid vote.");
                         /* My modification */
                         try
                              //System.out.println("Going inside");
     //repaint();                         java.lang.Thread.sleep(5000);
                         catch(InterruptedException ie)
                              System.out.println("Exp --------------<<<<<<<<<<<");
//yes/no dialog
} else if (command == yesNoCommand) {
int n = JOptionPane.showConfirmDialog(frame,
"This candidate is a convicted felon. \nDo you still want to vote for her?",
"A Follow-up Question",
JOptionPane.YES_NO_OPTION);
if (n == JOptionPane.YES_OPTION) {
setLabel("OK. Keep an eye on your wallet.");
} else if (n == JOptionPane.NO_OPTION) {
setLabel("Whew! Good choice.");
} else {
setLabel("It is your civic duty to cast your vote.");
//yes/no (with customized wording)
} else if (command == yeahNahCommand) {
Object[] options = {"Yes, please", "No, thanks"};
int n = JOptionPane.showOptionDialog(frame,
"This candidate is deceased. \nDo you still want to vote for him?",
"A Follow-up Question",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]);
if (n == JOptionPane.YES_OPTION) {
setLabel("I hope you don't expect much from your candidate.");
} else if (n == JOptionPane.NO_OPTION) {
setLabel("Whew! Good choice.");
} else {
setLabel("It is your civic duty to cast your vote.");
//yes/no/cancel (with customized wording)
} else if (command == yncCommand) {
Object[] options = {"Yes!",
"No, I'll pass",
"Well, if I must"};
int n = JOptionPane.showOptionDialog(frame,
"Duke is a cartoon mascot. \nDo you "
+ "still want to cast your vote?",
"A Follow-up Question",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[2]);
if (n == JOptionPane.YES_OPTION) {
setLabel("Excellent choice.");
} else if (n == JOptionPane.NO_OPTION) {
setLabel("Whatever you say. It's your vote.");
} else if (n == JOptionPane.CANCEL_OPTION) {
setLabel("Well, I'm certainly not going to make you vote.");
} else {
setLabel("It is your civic duty to cast your vote.");
return;
System.out.println("calling createPane");
return createPane(simpleDialogDesc + ":",
radioButtons,
voteButton);
private JPanel createPane(String description,
JRadioButton[] radioButtons,
JButton showButton) {
int numChoices = radioButtons.length;
JPanel box = new JPanel();
JLabel label = new JLabel(description);
box.setLayout(new BoxLayout(box, BoxLayout.PAGE_AXIS));
box.add(label);
for (int i = 0; i < numChoices; i++) {
box.add(radioButtons[i]);
JPanel pane = new JPanel(new BorderLayout());
pane.add(box, BorderLayout.NORTH);
pane.add(showButton, BorderLayout.SOUTH);
System.out.println("returning pane");
return pane;
* 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("VoteDialog");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Set up the content pane.
Container contentPane = frame.getContentPane();
contentPane.setLayout(new GridLayout(1,1));
contentPane.add(new VoteDialog(frame));
//Display the window.
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();

Yours is the King of the FAQ for the Java GUI programming, i.e. the most recurring one.
Java GUI runs as a single thread. If you are doing a time-consuming non-GUI task on a GUI thread,
typically in an event handler code, GUI is blocked until your long task completes.
Solution is that you do your long task as a separate thread. If you need to update GUI from within
the thread, you should use SwingUtilities.invokeLater() or invokeAndWait() method(*) to do it. Read
the API documentation for the methods and other documentations linked from there.
(*)Or, java.awt.EventQueue.invokeLater() or invokeAndWait() method.

Similar Messages

  • Anybody knows how to bounce them off the edge of the frame ...

    I want them to change position randomly and smothly and also bounce off the edge of the frame. i will be so happy if you can help me.
    Here is the code:
    FlatWorld:
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    * This FlatWorld contains random number(between 1 and 10) of disks
    * that can be drawn on a canvas.
    public class FlatWorld
        // initialize the width and height of the Canvas in FlatWorld...
        final int WIDTH = 400;
        final int HEIGHT = 400;
        // create random numbers of disks (1-10) using array.
        Random myRandom = new Random();
        int numbersOfDisks = myRandom.nextInt(10) + 1;
        Disk myDisk[] = new Disk[numbersOfDisks];
        // The Canvas on which things can be drawn or painted...
        private Canvas myCanvas;
        * creates a Canvas and disks
       FlatWorld()
            //Creates our disks using array.
            for( int i = 0; i < numbersOfDisks; i++ )
                myDisk[i] = new Disk(WIDTH,HEIGHT);
            //creates a canvas and store it in the instance variable...
            myCanvas = new Canvas(WIDTH,HEIGHT,this);
       /* Draws our disks using array.
        * @param graphicsContext The Graphics context required to do the drawing.
        * Supplies methods like "setColor" and "fillOval". */
       public void drawYourself(Graphics graphicsContext)
            for (int i = 0; i < numbersOfDisks; i++)
                myDisk.drawDisk(graphicsContext);
    public void change()
    final int movementScale = 8;
    for (int i = 0; i < numbersOfDisks; i++)
    int deltax = (int)( Math.random() - 0.5 * movementScale );
    int deltay = (int)( Math.random() - 0.5 * movementScale );
    myDisk[i].move(deltax, deltay);
    Disk:
    import java.awt.*;
    import java.util.*;
    * The Disk class is used to creates a disk with a random position
    * and a random color and a random diameter (between 1/20 width and 1/4 width)
    public class Disk
        /* instance variables */                    
        private int x;
        private int y;
        private int Diameter;
        private Color randomColor;
        private int red, green, blue;
         * Constructor for objects of class Disk
        //creat a disk at a 2D random position between width and height
        public Disk(int width, int height)
            /* Generates a random color red, green, blue mix. */
            red =(int)(Math.random()*256);
            green =(int)(Math.random()*256);
            blue =(int)(Math.random()*256);
            randomColor = new Color (red,green,blue);
            /* Generates a random diameter between 1/20 and 1/4 the width of the world. */
            double myRandom = Math.random();
            Diameter = (width/20) + (int)(( width/4 - width/20 )*myRandom);
            /* Generates a random xy-offset.
             * If the initial values of the xy coordinates cause the disk to draw out of the boundry,
             * then the x and/or y will change their values in order to make the whole disk visible in
             * the boundry. */
            int randomX = (int)(Math.random() * width);
            int randomY = (int)(Math.random() * height);
            int endPointX = randomX + Diameter;
            int xPixelsOutBound = endPointX - width;
            if ( endPointX > width)
                randomX = randomX - xPixelsOutBound;
            int endPointY = randomY + Diameter;
            int yPixelsOutBound = endPointY - width;
            if ( endPointY > width)
                randomY = randomY - yPixelsOutBound;
            setXY(randomX , randomY);
            /* replace values of newX and newY (randomX and randomY) into the x and y variables
             * @param newX The x-position of the disk
             * @param newY The y-position of the disk */
            public void setXY( int newX, int newY )
                x = newX;
                y = newY;
            /* Draw a disk by its coordinates, color and diameter...
             * @param graphicsContext The Graphics context required to do the drawing.
             * Supplies methods like "setColor" and "fillOval". */
            public void drawDisk(Graphics graphicsContext)
                graphicsContext.setColor(randomColor);
                graphicsContext.fillOval( x , y, Diameter , Diameter );
            public void move (int deltaX, int deltaY)
                x = x + deltaX;
                y = y + deltaY;
    }[i]Canvas:import java.awt.*;
    import javax.swing.*;
    public class Canvas extends JPanel
    // A reference to the Frame in which this panel will be displayed.
    private JFrame myFrame;
    // The FlatWorld on which disks can be create...
    FlatWorld myFlatWorld;
    * Initialize the Canvas and attach a Frame to it.
    * @param width The width of the Canvas in pixels
    * @param height The height of the Canvas in pixels
    public Canvas(int width, int height, FlatWorld sourceOfObjects)
    myFlatWorld = sourceOfObjects;
    // Set the size of the panel. Note that "setPreferredSize" requires
    // a "Dimension" object as a parameter...which we create and initialize...
    this.setPreferredSize(new Dimension(width,height));
    // Build the Frame in which this panel will be placed, and then place this
    // panel into the "ContentPane"....
    myFrame = new JFrame();
    myFrame.setContentPane(this);
    // Apply the JFrame "pack" algorithm to properly size the JFrame around
    // the panel it now contains, and then display (ie "show") the frame...
    myFrame.pack();
    myFrame.show();
    * Paint is automatically called by the Java "swing" components when it is time
    * to display or "paint" the surface of the Canvas. We add whatever code we need
    * to do the drawing we want to do...
    * @param graphics The Graphics context required to do the drawing. Supplies methods
    * like "setColor" and "fillOval".
    public void paint(Graphics graphics)
    // Clears the previous drawing canvas by filling it with the background color(white).
    graphics.clearRect( 0, 0, myFlatWorld.WIDTH, myFlatWorld.HEIGHT );
    // paint myFlatWorld
    myFlatWorld.drawYourself(graphics);
    //try but if --> {pauses the program for 100 miliseconds} dont work -->
    try {Thread.sleep(70);}
         catch (Exception e) {}
         myFlatWorld.change();
         repaint();

    Here is my contribution:
    FlatWorld:
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    * This FlatWorld contains random number(between 1 and 10) of disks
    * that can be drawn on a canvas.
    public class FlatWorld {
       // initialize the width and height of the Canvas in FlatWorld...
       final int WIDTH = 400;
       final int HEIGHT = 400;
       // create random numbers of disks (1-10) using array.
       Random myRandom = new Random();
       int numbersOfDisks = myRandom.nextInt(10) + 1;
       FlatWorldDisk myDisk[] = new FlatWorldDisk[numbersOfDisks];
       // The Canvas on which things can be drawn or painted...
       private FlatWorldCanvas myCanvas;
        * creates a Canvas and disks
       public FlatWorld() {       
            //Creates our disks using array.
            for( int i = 0; i < numbersOfDisks; i++ ) {
                myDisk[i] = new FlatWorldDisk(WIDTH,HEIGHT);
            //creates a canvas and store it in the instance variable...
            myCanvas = new FlatWorldCanvas(WIDTH,HEIGHT,this);
       /* Draws our disks using array.
        * @param graphicsContext The Graphics context required to do the drawing.
        * Supplies methods like "setColor" and "fillOval". */
       public void drawYourself(Graphics graphicsContext) {
            for (int i = 0; i < numbersOfDisks; i++) {
                myDisk.drawDisk(graphicsContext);
    public void change() {
    final int movementScale = 8;
    for (int i = 0; i < numbersOfDisks; i++) {
    int deltax = (int)( Math.random() - 0.5 * movementScale );
    int deltay = (int)( Math.random() - 0.5 * movementScale );
    myDisk[i].move(deltax, deltay, WIDTH, HEIGHT);
    public static void main(String[] args) {
    new FlatWorld();
    FlatWorldDisk:
    import java.awt.*;
    import java.util.*;
    * The FlatWorldDisk class is used to creates a disk with a random position
    * and a random color and a random diameter (between 1/20 width and 1/4 width)
    public class FlatWorldDisk {
       /* Constants */
       private static final int DIRECTION_NW = 1;
       private static final int DIRECTION_N  = 2;
       private static final int DIRECTION_NE = 3;
       private static final int DIRECTION_W  = 4;
       private static final int DIRECTION_E  = 5;
       private static final int DIRECTION_SW = 6;
       private static final int DIRECTION_S  = 7;
       private static final int DIRECTION_SE = 8;
       /* instance variables */               
       private int x;
       private int y;
       private int diameter;
       private Color randomColor;
       private int red, green, blue;
       private int direction;
        * Constructor for objects of class FlatWorldDisk
       //creat a disk at a 2D random position between width and height
       public FlatWorldDisk(int width, int height) {
          /* Generates a random color red, green, blue mix. */
          red =(int)(Math.random()*256);
          green =(int)(Math.random()*256);
          blue =(int)(Math.random()*256);
          randomColor = new Color (red,green,blue);
          /* Generates a random diameter between 1/20 and 1/4 the width of the world. */
          double myRandom = Math.random();
          diameter = (width/20) + (int)(( width/4 - width/20 )*myRandom);
          /* Generates a random xy-offset.
           * If the initial values of the xy coordinates cause the disk to draw out of the boundry,
           * then the x and/or y will change their values in order to make the whole disk visible in
           * the boundry. */
          int randomX = (int)(Math.random() * width);
          int randomY = (int)(Math.random() * height);
          int endPointX = randomX + diameter;
          int xPixelsOutBound = endPointX - width;
          if (endPointX > width) randomX = randomX - xPixelsOutBound;
          int endPointY = randomY + diameter;
          int yPixelsOutBound = endPointY - width;
          if (endPointY > width) randomY = randomY - yPixelsOutBound;
          setXY(randomX , randomY);
          /* Generates a random direction */
          direction = (int)(Math.random() * 8) + 1;
       /* replace values of newX and newY (randomX and randomY) into the x and y variables
        * @param newX The x-position of the disk
        * @param newY The y-position of the disk */
       public void setXY(int newX, int newY) {
          x = newX;
          y = newY;
       /* Draw a disk by its coordinates, color and diameter...
        * @param graphicsContext The Graphics context required to do the drawing.
        * Supplies methods like "setColor" and "fillOval". */
       public void drawDisk(Graphics graphicsContext) {
          graphicsContext.setColor(randomColor);
          graphicsContext.fillOval( x , y, diameter , diameter );
       public void move(int deltaX, int deltaY,
                        int width, int height) {
          int dx = Math.abs(deltaX);
          int dy = Math.abs(deltaY);
          int olddir = direction;
          int newdir = olddir;
          switch(olddir) {
             case DIRECTION_NW: { int newX = x - dx, newY = y - dy;
                                  if ((newX < 0) && ((y - dy) < 0))         newdir = DIRECTION_SE;
                                  else if (((newX) >= 0) && ((y - dy) < 0)) newdir = DIRECTION_SW;
                                  else if (((newX) < 0) && ((y - dy) >= 0)) newdir = DIRECTION_NE;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     x = newX; y = newY;
                                  break;
             case DIRECTION_N:  { int newY = y - dy;
                                  if ((newY) < 0) newdir = DIRECTION_S;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     y =newY;
                                  break;
             case DIRECTION_NE: { int newX = x + dx, newY = y - dy;
                                  if (((newX + diameter) > width) && (newY < 0))       newdir = DIRECTION_SW;
                                  else if (((newX + diameter) > width) && (newY >= 0)) newdir = DIRECTION_NW;
                                  else if (newY < 0)                                   newdir = DIRECTION_SE;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     x = newX; y = newY;
                                  break;
             case DIRECTION_W:  { int newX = x - dx;
                                  if (newX < 0) newdir = DIRECTION_E;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     x = newX;
                                  break;
             case DIRECTION_E:  { int newX = x + dx;
                                  if (newX + diameter > width) newdir = DIRECTION_W;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     x = newX;
                                  break;
             case DIRECTION_SW: { int newX = x - dx, newY = y + dy;
                                  if ((newX < 0) && ((newY + diameter) > height))     newdir = DIRECTION_NE;
                                  else if (newX <0)                                   newdir = DIRECTION_SE;
                                  else if ((newY + diameter) > height)                newdir = DIRECTION_NW;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     x = newX; y = newY;
                                  break;
             case DIRECTION_S:  { int newY = y + dy;
                                  if ((newY + diameter) > height) newdir = DIRECTION_N;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     y =newY;
                                  break;
             case DIRECTION_SE: { int newX = x + dx, newY = y + dy;
                                  if (((newX + diameter) > width) && ((newY + diameter) > height)) newdir = DIRECTION_NW;
                                  else if ((newX + diameter) > width)                              newdir = DIRECTION_SW;
                                  else if ((newY + diameter) > height)                             newdir = DIRECTION_NE;
                                  if (newdir != olddir) {
                                     direction = newdir;
                                     move(deltaX, deltaY, width, height);
                                  else {
                                     x = newX; y = newY;
                                  break;
    FlatWorldCanvas remains unchanged.
    Hope this will help,
    Regards.

  • Panel doesn't display properly until I resize the frame

    Hiya folks,
    I'm currently trying to write a simple piece of music notation software. This is my first time using swing beyond a relatively simple JApplet and some dialog stuff. Anywho, I ran into a pretty discouraging issue early on. So far I've got a frame with a menu bar and a toolbar on the bottom border. The toolbar contains a button which should draw a new staff panel containing 11 panels (potentially more) within it, alternating between lines and spaces. Sort of like this:
    import javax.swing.*;
    import java.awt.*;
    public class Staff extends JPanel {
       private static JPanel nsp1,nsp3,nsp5,nsp7,nsp9,nsp11;
       private static JPanel nsp2,nsp4,nsp6,nsp8,nsp10;
       private ImageIcon image= new ImageIcon(this.getClass().getResource( "icons/treble clef.gif"));
        public Staff(){
        setLayout(new GridLayout(11,1));
        add(nsp1= new NoteSpace());
        add(nsp2= new LineSpace());
        add(nsp3= new NoteSpace());
        add(nsp4= new LineSpace());
        add(nsp5= new NoteSpace());
        add(nsp6= new LineSpace());
        add(nsp7= new NoteSpace());
        add(nsp8= new LineSpace());
        add(nsp9= new NoteSpace());
        add(nsp10= new LineSpace());
        add(nsp11= new NoteSpace());
    static class NoteSpace extends JPanel{
        public NoteSpace(){
        setPreferredSize(new Dimension(this.getWidth(),2));
    static class LineSpace extends JPanel{
          public LineSpace(){
          setPreferredSize(new Dimension(this.getWidth(),1));
          public void paint(Graphics g) {
              super.paint(g);
              g.drawLine(0, (int) super.getHeight()/2, (int)super.getWidth(), (int)super.getHeight()/2);
    }Anyway, this panel displays as a tiny box wherein nothing is visible until I resize the frame. Really frustrating. And I have have no idea what the problem might be. Here's the actionlistener:
    jbtcleff.addActionListener(new ActionListener (){
            public void actionPerformed (ActionEvent e){
                staff.setBounds(50,panel.getHeight()/2,panel.getWidth()-50,panel.getHeight()/2);
                panel.add(staff);
                staff.repaint();
            });...which is located in a custom jtoolbar class within the Main class, an extension of JFrame:
    public class Main extends JFrame{
       JMenuBar jmb=new CustomMenuBar();
       JToolBar jtb= new CustomToolBars("ToolBar");
       static boolean isStaff=false;
       static boolean isNote=false;
       static JPanel panel = new JPanel();
       private static Staff staff= new Staff();
        private static Toolkit toolkit= Toolkit.getDefaultToolkit();
       private static Image image=toolkit.getImage("C:/Users/tim/Documents/NetBeansProjects/ISP/src/MusicGUI/icons/treble clef.jpg");
        private static Cursor noteCursor = toolkit.createCustomCursor(image,new Point(0,0),"Image"); 
       public Main (String m) {   
            super(m);
            setJMenuBar(jmb);    
            getContentPane().add(jtb,BorderLayout.SOUTH);       
            panel.setLayout(new CardLayout(60,60));
            getContentPane().add(panel);
    public static void main (String[]args){
            JFrame frame= new Main("Music");
            frame.setSize(800,400);
            frame.setLocationRelativeTo(null);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
            frame.setIconImage(image);
           Sorry for all the code. I'm desperate.
    Thanks!

    Oh my... have you been through the Swing tutorial?
    Let's look at some of your code,
    static class NoteSpace extends JPanel{
        public NoteSpace(){
        setPreferredSize(new Dimension(this.getWidth(),2));
    static class LineSpace extends JPanel{
          public LineSpace(){
          setPreferredSize(new Dimension(this.getWidth(),1));
          public void paint(Graphics g) {
              super.paint(g);
              g.drawLine(0, (int) super.getHeight()/2, (int)super.getWidth(), (int)super.getHeight()/2);
    }Here, NoteSpace and LineSpace are being set to a preferred size of 0x2 pixels, and 0x1 pixels respectfully. If you want them at 0 width, how do you expect them to show? In particular, NoteSpace isn't doing anything special. It's just a panel. Why an inner class? Lastly you should not override paint() for SWING. That's AWT stuff. For Swing, you override paintComponent(Graphics g) .
    Then we have this
    jbtcleff.addActionListener(new ActionListener (){
            public void actionPerformed (ActionEvent e){
                staff.setBounds(50,panel.getHeight()/2,panel.getWidth()-50,panel.getHeight()/2);
                panel.add(staff);
                staff.repaint();
            });I'm not sure what the variable jbtcleff is, but it seems you are adding your Staff panel to "panel" every time a button is pressed.... why? Why not just add it once (outside the action listener) and be done with it. Your panel object has a CardLayout, so I assume you meant to create a new+ staff panel everytime a button is pressed, and then add it to the card layout panel. Even so, setBounds(...) does not seem pertinant to this goal. (In fact, in most situtations the use of setBounds(...) is the antithesis of using layout managers).
    The problem you mentioned though seems to be related to the use of a JPanel (your Staff class) that adds zero-width compontents to a grid array.

  • Problem to "repaint" the 3D screen

    Hi everyone, I wrote an application that moves some geometrical objects when the user click on them, using Picking. The situation was supposed to happens like this: after the user clicks on an object i translate it to a distant position in order to hide it, so the place where the objects were stays empty, then i wait for some seconds and other configurations (i mean other positions) of the objects appear.
    The problem is that the place does not stays empty it keep the old frame (i mean the old positions configuration) during all time i wait and just after that the frame show the new configuration. I guess it something related to Thread.sleep() the method i use to wait some seconds.
    So my question is: Is there other strategy to do this such thing i intend? Maybe something like �Repaint�. Since now thanks a lot. I hope to have made myself to understand due my poor English writing.
    �der.

    messengers, i'm writing the Behavior class but i got a doubt, how can i get the action that wakeup the Thread.sleep in order to pass to wakeuponBehaviorPost class?
    The code i found is like this:
      public class MyBehaviorTranslation extends Behavior{
          MyBehaviorTranslation(Group root, Bounds bounds) {
            this.setSchedulingBounds(bounds);
            BranchGroup branchGroup = new BranchGroup();
            branchGroup.addChild(this);
            root.addChild(branchGroup);
          public void initialize(){
              // set initial wakeup condition
              this.wakeupOn(new WakeupOnBehaviorPost(???, 0));
              // set someIntegerValue to your specific value
              // null can be replaced by an specific Behavior Object to send this value
          // called by Java 3D when appropriate stimulus occures
          public void processStimulus(Enumeration criteria){
            // do what is necessary
            // resetup Behavior
             this.wakeupOn(new WakeupOnBehaviorPost(????, 0));
      }Thanks a lot since now.
    �der.

  • Can you repaint certain elements (ie a ball) while NOT repainting the board

    I'm really just starting out writing java applets. I don't use Applet, i use JApplet because the coding is much more familiar. I understand that this might be a bad decision and if it is, please tell me! Anyway, my question is: Can I have the paint method (called via repaint()) paint the board one time, then only repaint the ball and it's constant change in position? I want to do this because the only way I can think of to have constant motion of the ball (I'm trying to simulate Pong) is by adding repaint() to the end of the paint function. This causes the applet to repaint very rapidly and everything gets all cut up and looks like crap. Any ideas on how I can make it run smoother? my code is teh following, if it helps (I realize that it isn't really commented, I am very messy and I do apologize):
    import java.util.Random;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Date;
    public class NewProj extends JApplet implements ActionListener, MouseListener, MouseMotionListener, KeyListener{
    /** Creates a new instance of NewProj */
    private int xBar1,yBar1,xBar2,yBar2;
    private String code;
    private int bar1H, bar2H, yMovement, xMovement;
    private int frame;
    private int ballX,ballY;
    private boolean hitTop,hitBottom,hitLeft,hitRight,hitPaddle1,hitPaddle2;
    private int score1,score2;
    private Date date;
    public NewProj() {
    date = new Date();
    score1=0;
    score2=0;
    ballX=175;
    ballY=125;
    yMovement=ballY+3;
    xMovement=ballX+3;
    frame=0;
    bar1H=40;
    bar2H=40;
    code="";
    xBar1=30;
    yBar1=130;
    xBar2=320;
    yBar2=130;
    this.addMouseMotionListener(this);
    this.addMouseListener(this);
    this.addKeyListener(this);
    public void paint(Graphics g){
    super.paint(g);
    g.drawString("Score: "+score1,220,20);
    g.drawString("Score: " + score2,80,20);
    if(frame==25){
    //initiate a and xMovement as moving linearly with a slope of 1.
    yMovement=ballY+3;
    xMovement=ballX+3;
    if(ballX<=xBar1+8 && ballX>=xBar1 && ballY<=yBar1+bar1H && ballY>=yBar1){
    hitPaddle1=true;
    hitPaddle2=false;
    hitRight=false;
    hitLeft=false;
    if(ballX<=xBar2+8 && ballX>=xBar2 && ballY<=yBar2+bar2H && ballY>=yBar2){
    hitPaddle2=true;
    hitRight=false;
    hitLeft=false;
    //check if the ball hit the Top
    if(ballY<1){
    hitBottom=false;
    hitTop=true;
    if(ballY>250){
    hitTop=false;
    hitBottom=true;
    if(ballX<10){
    hitPaddle2=false;
    hitPaddle1=false;
    hitRight=false;
    hitLeft=true;
    score1++;
    if(ballX>350){
    hitPaddle2=false;
    hitPaddle1=false;
    hitLeft=false;
    hitRight=true;
    score2++;
    if(hitBottom){
    yMovement=ballY-3;
    if(hitTop){
    yMovement=ballY+3;
    if(hitLeft){
    xMovement=ballX+3;
    if(hitRight)
    xMovement=ballX-3;
    if(hitPaddle1){
    xMovement=ballX+3;
    if(hitPaddle2){
    xMovement=ballX-3;
    System.out.println(yMovement+" is yMovement " + "and" + xMovement + " is xmove");
    ballY=yMovement;
    ballX=xMovement;
    frame=0;
    repaint();
    if(code.equals("penis")){
    if(bar1H>=60)
    bar1H=60;
    else bar1H+=5;
    code="";
    //top & bottom
    g.drawLine(0,0,350, 0);
    g.drawLine(0,250,350,250);
    //left & right sides
    g.drawLine(0,0,0,250);
    g.drawLine(350,0,350,250);
    //Midline
    g.drawLine(175,0,175,250);
    //ball
    g.setColor(Color.MAGENTA);
    g.fillOval(ballX,ballY,8,8);
    g.setColor(Color.RED);
    g.fillRect(xBar1,yBar1,5,bar1H);
    g.setColor(Color.BLUE);
    g.fillRect(xBar2,yBar2,5,bar2H);
    frame++;
    for(int b = 0; b<1000;b++){
    int hilbo=b+3;
    repaint();
    public void mouseClicked(MouseEvent e) {
    public void mouseEntered(MouseEvent e) {
    repaint();
    public void mouseExited(MouseEvent e) {
    public void mousePressed(MouseEvent e) {
    public void mouseReleased(MouseEvent e) {
    public void actionPerformed(ActionEvent e) {
    public void mouseDragged(MouseEvent e) {
    public void mouseMoved(MouseEvent e) {
    int y = e.getY();
    if(y<=(250-bar1H))
    yBar1 = y-(int)bar1H/2;
    else yBar1 = 250-bar1H;
    public void keyPressed(KeyEvent e) {
    if(e.getKeyCode()==40){
    yBar2+=10;
    if(e.getKeyCode()==38){
    yBar2-=10;
    if(yBar2>=225)
    yBar2=225;
    if(yBar2<=0)
    yBar2=0;
    repaint();
    for(int i=65;i<=90;i++){
    String s = "";
    switch(e.getKeyCode()){
    case 80: code=code+"p";
    break;
    case 69: code=code+"e";
    break;
    case 78: code=code+"n";
    break;
    case 73: code=code+"i";
    break;
    case 83: code=code+"s";
    break;
    case 82: code=code+"r";
    break;
    case 65: code=code+"a";
    break;
    case 75: code=code+"k";
    default:code="";
    break;
    public void keyReleased(KeyEvent e) {
    public void keyTyped(KeyEvent e) {

    Check out the tutorials on this site. Start here: http://java.sun.com/docs/books/tutorial/
    You can have a thread like this:public class Game extends java.awt.Component {
      public void init() {
        Thread t = new Thread(new GameLoop());
        t.start();
      public void paint(Graphics g) {
        // draw your game here.  Do nothing other than drawing.
      private class GameLoop { // inner class
        public void run() {
           while(true) {
              // update your game state here -- e.g., move the ball's position
              try {
                 Thread.sleep(200); // 200 miliseconds, 1/5 of a second
               catch(InterruptedException e) {
                  // this is the rare exception that it's generally OK to ignore
               repaint();
    }that's not perfect but it will get you started

  • Help! I don't understand the frame mechanics.

    Hi, I've been trying to figure out how frames work in Flash.  I'm new to ActionScript, so I don't know the inner workings of the language.  I tried checking the API but no Frame class is listed.  The closest thing was FrameLabel and that wasn't helpful.  I need to know a few things:
    1) How can I tell what frame I am in?  If there is a class method for this, what is the exact name?
    2) How does a frame advance?  I have some code with no timer, only event listeners/handlers, and I've got a hacked animation working without playing clips on the time line.  The displayed pictures change whenever I press a directional button to move the character.  This is not really what I want to do however, because I'm switching the visibility of many different symbols and updating their position according to the original player symbol.  Very inefficient.  And does that mean that the frame only advances when a button is pressed? Am I even advancing the frame at all?  I don't know any frame advance method.
    3) How do frames work on the time line?  I have all of my symbols on a single frame.  I made their visibility false in my constructor because I don't want some things to show when I first load up the .swf file.  When I created a second frame, everything went crazy and things began to show up.  This suggests that the visibility = false was only done in the first frame?  What caused the frame to change?  I don't really get it.
    Ideally I want to achieve a dynamically modifiable animation because the game actions are not going to be linear.  The player character will be responding to controls (which will change the animation) and the AI will be responding to the player (which will also change the animation).  I don't think I can do this without understanding frames, so please help me.  I'm very confused!  Even pointing me in the right direction as to where I can read about frame details would be cool.  I've tried Adobe tutorials, support, and documentation but it was not sufficient.  Is there any place where there is a very in depth explanation about frames, or would someone be so kind as to tutor me about them?
    Thanks in advance.

    You can find out the current frame by using the currentFrame property. There are a number of ways to change frames, where the most common would be prevFrame(), nextFrame(), play(), gotoAndPlay(), and gotoAndStop().  There are plenty of ways to make use of frames in a Flash file, from having linear animations along the timeline, to have each frame being a distinct zone of operation that contains elements having their own timelines.
    One thing you may need to get a handle on are the different types of frames.  There are plain frames and there are keyframes.  Plain frames genrally involve a continuation of preceding frames, while keyframes mark an area of change.  In your example of things going crazy when you added a second frame, I am guessing you implanted a new keyframe because had you inserted a plain frame the status of your content from frane 1 would not have been impacted.
    I don't know of any resources for you to follow up with for learning more about frames--I came to learn them thru trial and error.  Someone else may come along with some suggestions for reference materials.

  • Text wrap for a paragraph: How to define the width of a Text box /  active text area? I simply need a longish text to wrap within the frame!

    Hello, I've been searching for a good while in the forums now, but have found no solution or real mention of the problem – I hope some of you can help.
    I want to very simply layout a text between scenes, a slightly longer text that wraps within the frame margins. Here's an example of how I want it to look:
    Now, I couldn't for the life of me get the Custom Text to behave like that, as there are no parameters to set for the width of the text area. The Text Size, yes, along with the Tracking, Baseline and all that, but the width of the text box, no. The above was created by customizing one of the other Text Generator presets that happened to be left aligned.
    However, this preset has a fade in/fade out transition, which I do not want. There's no way to remove this transition as it seems integrated into the Text Generator (meaning they are not really presets, but separate kinds of Text objects? Very silly.)
    So I am asking you: Is there any way to get the Custom Text generator to behave like that? Just a text paragraph as above. Below you'll see all I can manage with the diffferent Custom Text parameters. Any kind of repositioning and resizing of the text just changes the position and size of the frame – but the actual text items are just cropped off where they extend out of that frame. Apparently the bounding box for the text is just some default length, and I can't find any way to adjust the width. See below my different attempts.
    The same text pasted into a Custom Text generator clearly extends outside the frame:
    Here Transform just moves – or resizes – the video frame that the Text Box exists inside:
    The Crop gives similar results, and of course Distort doesn't get me closer to what I need, either. There should be simply a Text Box Width parameter to set somewhere, but if it exists they have hidden it very well. How do you do it?
    Thanks for any help, this is a silly problem, but one of now many trivial problems that amount to me growing quite dissatisfied with FCPX. Hopefully I've just overlooked something.
    All the best,
    Thomas

    Thomas...same kind of crap here.
    I used Custom Text - entered a sentence, hit return, entered another.
    Set to 72 pt.
    The default alignment is centred - I want left aligned text...the text start point stays at the centre of frame and the sentence runs off the edge of the bounding box.
    There is no settings in the Text or Title inspector dialog to correct that!
    Using Transform will not sort it!

  • How to get the frame rate of my application

    Hi again...
    How can I get the frame rate of my application?
    I also want the frame rate value to be the title of the frame, updated every second. How do I do that?
    thanks in advance...

    To get the path where your application has been installed you have to do the following:
    have a class called "what_ever" in the folder.
    then you do a litte:
    String path=
    what_ever.class.getRessource("what_ever.class").toString()
    That get you a string like:
    file:/C:/Program Files/Cool_program/what_ever.class
    Then you process the result a little to remove anything you don't want:
    path=path.substring(path.indexOf('/')+1),path.lastIndexOf('/'))
    //Might be a little error here but you should find out //quickly if it's the case
    And here you go, you have a nice
    C:/Program Files/Cool_program
    which is the path to your application.
    Hooray

  • Where is the frame rate setting control when making a slide show?

    I am trying to make a slide show using QuickTime Pro and cannot find the frame rate control.I put all my consectively-numbered jpegs in one folder. I then clicked on "File," the "Open Image Sequence," then a window opened up and I click on the first jpeg in the series of photos I want in my slide show. Then the first image appears in the QT Window. The instructions next say that I should be able to change the rate at which each slide/jpeg appears, but it doesn't tell you where to find the "frame rate" so I can change it. It doesn't appear at all on its own, so where is it? Anything else I'm missing? Thank you.

    barbaric135
    What version of Photoshop Elements and or Premiere Elements are you using and on what computer operating system?
    In addition, could you please clarify?
    It sounds like you are creating your slideshow in the Elements Organizer. Where are you seeing these distortions and blurs, in the Elements Organizer Slideshow Editor Filmstrip or in the Premiere Elements workspace after you have transferred the slideshow from the Elements Organizer 9 Slideshow Editor to Premiere Elements workspace?
    What are the pixel dimensions of the photos in this slideshow and how many of these photos are in the slideshow? What format are they in..jpg, psd, other?
    With regard to what you wrote:
    Also how do I transport them from Elements to Premier, it has a tab to do that but when I get to the elements file I don't know where to drag and drop into.
    If you are in the Elements Organizer Slideshow Editor and use the Output option Edit with Premiere Elements, then you would expect the automatic transfer of the slideshow to Premiere Elements, with a copy in video format (.psess) in the project media as well as on the Timeline. Nothing for you to drag and drop.
    For all those reasons, I am asking for clarification.
    Thanks.
    ATR

  • How can I link two frames via a button on one of the frame?help Plz

    Ok,here is the problem. I got two fully working java frames,each has different funcion. On one of the frames(my home Frame" Frame 1" ) i got a button called "Add User", when i press it i should then get my other frame(Frame2) to popup/run. in Frame1 i got this code as action for the add user button.Note: each Frame have thier own Main class.
    public void actionPerformed (ActionEvent e)
    if (e.getSource()==jbtnAddUser)
    // new Frame2(this,"hshsh",jb);
    ////////////// The commented line is where i am not sure what to put in there, Frame1 is the name of my Frame 2 class......
    Please could anyone tell me how do i link Frame 2 to Frame 1....i appreciate it....Max

    You can create both together on pgm startup (instaniation of the class).
    Next for frame1 - I'll call it - you can setBounds(int, int, int, int) and setVisible(true); When you press the button on frame1 to get frame2, you can then do frame1.hide(), followed by frame2 setBounds and setVisible. Finally, when you are done with frame2 you can do frame2.dispose() and frame1.show(). try that.

  • How do I replace the frame from the monitor on my GX740?

    Problem: When I move the hinges on my laptop, sometimes the screen goes black until I move it into a different position, like the light disconnects (in fact, I'm pretty sure that's exactly what happens, as I can still see some stuff on the screen; it's just not lit). Having had LCD problems in the past with other machines, I figured "hey, probably just a loose connector, it happens; I should be able to just lock that strip back in place quite easily" (why they don't just make those connectors less prone to falling out - especially ones located in or near hinges - eludes me).
    Sure. If I can just get inside the monitor frame. Which it seems I can't. I removed the screws, but when I tried to pull off the plastic frame, it cracked. The plastic frame around my monitor now has visible cracks in it.
    So now I need to know not only how to remove this frame, but if possible, also where I can get a replacement for just that one part. I'll gladly take just an answer to the first part and live with the cracked frame as long as I can do something about the loose connector, but if there's an answer to the second part as well, that'd be really neat.
    So...how do I remove the frame? Where can I get a new one now that I've ruined this one? Are there spares? Are they expensive?
    I'd greatly appreciate a quick answer to the frame removal question, as I intend to bring this computer on a trip overseas and would like the LCD light to not have disconnected completely by the time I arrive, so I'd like to properly attach it before it's time to leave.
    I've never had a machine that's so hard to open. This strikes me as quite user-unfriendly design, especially given how little it takes for an LCD connector disconnect, especially one located in the hinge area of a laptop.

    GX720 disassembly guide
    https://forum-en.msi.com/moderator/assembly-guides/ms-1722-disassemble-sop.pdf
    GX700 disassembly guide
    https://forum-en.msi.com/moderator/assembly-guides/assemble-1719.pdf
    I'm not certain they are the same as the GX740 but I would I imagine they are very similar.
    As far as finding another bezel, your best bet might be ebay.
    http://www.storesavings.com/products--search-msi-bezel.html?aid=31738-4176544-53943996&utm_source=google&utm_medium=cpc&utm_campaign=watches&utm_content=&utm_term=+msi%20+bezel&utm_a=1s5&utm_t=b&utm_n=s&utm_c=34127592272&utm_p=&utm_m=&gclid=COiglouo670CFUoV7AodN1UA1g&qo=6143279&so=1 That might work as well, not sure though.

  • How do I set the frame size

    I am Making a program for purchasing games, with the basic layout alsot done, except on problem. When the purchase button is pressed, a dialog shows up but nothing is seen until i resize it. How would i set the frame size so that i do not need to resize it each time? below is the code for the files. Many thanks in advance.
    CreditDialog
    import java.awt.*;
    import java.awt.event.*;
    class CreditDialog extends Dialog implements ActionListener { // Begin Class
         private Label creditLabel = new Label("Message space here",Label.RIGHT);
         private String creditMessage;
         private TextField remove = new TextField(20);
         private Button okButton = new Button("OK");
         public CreditDialog(Frame frameIn, String message) { // Begin Public
              super(frameIn); // call the constructor of dialog
              creditLabel.setText(message);
              add("North",creditLabel);
              add("Center",remove);
              add("South",okButton);
              okButton.addActionListener(this);
              setLocation(150,150); // set the location of the dialog box
              setVisible(true); // make the dialog box visible
         } // End Public
         public void actionPerformed(ActionEvent e) { // Begin actionPerformed
    //          dispose(); // close dialog box
         } // End actionPerformed
    } // End Class
    MobileGame
    import java.awt.*;
    import java.awt.event.*;
    class MobileGame extends Panel implements ActionListener { // Begin Class
         The Buttons, Labels, TextFields, TextArea 
         and Panels will be created first.         
         private int noOfGames;
    //     private GameList list;
         private Panel topPanel = new Panel();
         private Panel middlePanel = new Panel();
         private Panel bottomPanel = new Panel();
         private Label saleLabel = new Label ("Java Games For Sale",Label.RIGHT);
         private TextArea saleArea = new TextArea(7, 25);
         private Button addButton = new Button("Add to Basket");
         private TextField add = new TextField(3);
         private Label currentLabel = new Label ("Java Games For Sale",Label.RIGHT);
         private TextArea currentArea = new TextArea(3, 25);
         private Button removeButton = new Button("Remove from Basket");
         private TextField remove = new TextField(3);
         private Button purchaseButton = new Button("Purchase");
         private ObjectList gameList = new ObjectList(20);
         Frame parentFrame; //needed to associate with dialog
         All the above will be added to the interface 
         so that they are visible to the user.        
         public MobileGame (Frame frameIn) { // Begin Constructor
              parentFrame = frameIn;
              topPanel.add(saleLabel);
              topPanel.add(saleArea);
              topPanel.add(addButton);
              topPanel.add(add);
              middlePanel.add(currentLabel);
              middlePanel.add(currentArea);
              bottomPanel.add(removeButton);
              bottomPanel.add(remove);
              bottomPanel.add(purchaseButton);
              this.add("North", topPanel);
              this.add("Center", middlePanel);
              this.add("South", bottomPanel);
              addButton.addActionListener(this);
              removeButton.addActionListener(this);
              purchaseButton.addActionListener(this);
              The following line of code below is 
              needed inorder for the games to be  
              loaded into the SaleArea            
         } // End Constructor
         All the operations which will be performed are  
         going to be written below. This includes the    
         Add, Remove and Purchase.                       
         public void actionPerformed (ActionEvent e) { // Begin actionPerformed
         If the Add to Basket Button is pressed, a       
         suitable message will appear to say if the game 
         was successfully added or not. If not, an       
         ErrorDialog box will appear stateing the error. 
              if(e.getSource() == addButton) { // Begin Add to Basket
    //          GameFileHandler.readRecords(list);
                   try { // Begin Try
                        String gameEntered = add.getText();
                        if (gameEntered.length() == 0 ) {
                             new ErrorDialog (parentFrame,"Feild Blank");
                        } else if (Integer.parseInt(gameEntered)< 0
                                  || Integer.parseInt(gameEntered)>noOfGames) { // Begin Else If
                             new ErrorDialog (parentFrame,"Invalid Game Number");
                        } else { // Begin Else If
                             //ADD GAME
                        } // End Else
                   } catch (NumberFormatException num) { // Begin Catch
                        new ErrorDialog(parentFrame,"Please enter an Integer only");
                   } // End Catch
              } // End Add to Basket
         If the Remove From Basket Button is pressed, a  
         a suitable message will appear to say if the    
         removal was successful or not. If not, an       
         ErrorDialog box will appear stateing the error. 
         if(e.getSource() == removeButton) { // Begin Remove from Basket
              try { // Begin Try
                        String gameEntered = remove.getText();
                        if (gameEntered.length() == 0 ) {
                             new ErrorDialog (parentFrame,"Feild Blank");
                        } else if (Integer.parseInt(gameEntered)< 1
                                  || Integer.parseInt(gameEntered)>noOfGames) { // Begin Else If
                             new ErrorDialog (parentFrame,"Invalid Game Number");
                        } else { // Begin Else If
                             //ADD GAME CODE
                        } // End Else
                   } catch (NumberFormatException num) { // Begin Catch
                        new ErrorDialog(parentFrame,"Please enter an Integer only");
                   } // End Catch
              } // End Remove from Basket
         If the purchase button is pressed, the          
         following is executed. NOTE: nothing is done    
         when the ok button is pressed, the window       
         just closes.                                    
              if(e.getSource() == purchaseButton) { // Begin Purchase
                   String gameEntered = currentArea.getText();
                   if (gameEntered.length() == 0 ) {
                        new ErrorDialog (parentFrame,"Nothing to Purchase");
                   } else { // Begin Else If
                        new CreditDialog(parentFrame,"Cost � 00.00. Please enter Credit Card Number");
                   } // End Else               
              } // End Purchase
         } // End actionPerformed
    } // End Class
    RunMobileGame
    import java.awt.*;
    public class RunMobileGame { // Begin Class
         public static void main (String[] args) { // Begin Main
              EasyFrame frame = new EasyFrame();
              frame.setTitle("Game Purchase for 3G Mobile Phone");
              MobileGame purchase = new MobileGame(frame); //need frame for dialog
              frame.setSize(500,300); // sets frame size
              frame.setBackground(Color.lightGray); // sets frame colour
              frame.add(purchase); // adds frame
              frame.setVisible(true); // makes the frame visible
         } // End Main
    } // End Class
    EasyFrame
    import java.awt.*;
    import java.awt.event.*;
    public class EasyFrame extends Frame implements WindowListener {
    public EasyFrame()
    addWindowListener(this);
    public EasyFrame(String msg)
    super(msg);
    addWindowListener(this);
    public void windowClosing(WindowEvent e)
    dispose();
    public void windowDeactivated(WindowEvent e)
    public void windowActivated(WindowEvent e)
    public void windowDeiconified(WindowEvent e)
    public void windowIconified(WindowEvent e)
    public void windowClosed(WindowEvent e)
    System.exit(0);
    public void windowOpened(WindowEvent e)
    } // end EasyFrame class
    ObjectList
    class ObjectList
    private Object[] object ;
    private int total ;
    public ObjectList(int sizeIn)
    object = new Object[sizeIn];
    total = 0;
    public boolean add(Object objectIn)
    if(!isFull())
    object[total] = objectIn;
    total++;
    return true;
    else
    return false;
    public boolean isEmpty()
    if(total==0)
    return true;
    else
    return false;
    public boolean isFull()
    if(total==object.length)
    return true;
    else
    return false;
    public Object getObject(int i)
    return object[i-1];
    public int getTotal()
    return total;
    public boolean remove(int numberIn)
    // check that a valid index has been supplied
    if(numberIn >= 1 && numberIn <= total)
    {   // overwrite object by shifting following objects along
    for(int i = numberIn-1; i <= total-2; i++)
    object[i] = object[i+1];
    total--; // Decrement total number of objects
    return true;
    else // remove was unsuccessful
    return false;
    ErrorDialog
    import java.awt.*;
    import java.awt.event.*;
    class ErrorDialog extends Dialog implements ActionListener {
    private Label errorLabel = new Label("Message space here",Label.CENTER);
    private String errorMessage;
    private Button okButton = new Button("OK");
    public ErrorDialog(Frame frameIn, String message) {
    /* call the constructor of Dialog with the associated
    frame as a parameter */
    super(frameIn);
    // add the components to the Dialog
              errorLabel.setText(message);
              add("North",errorLabel);
    add("South",okButton);
    // add the ActionListener
    okButton.addActionListener(this);
    /* set the location of the dialogue window, relative to the top
    left-hand corner of the frame */
    setLocation(100,100);
    // use the pack method to automatically size the dialogue window
    pack();
    // make the dialogue visible
    setVisible(true);
    /* the actionPerformed method determines what happens
    when the okButton is pressed */
    public void actionPerformed(ActionEvent e) {
    dispose(); // no other possible action!
    } // end class
    I Know there are alot of files. Any help will be much appreciated. Once again, Many thanks in advance

    setSize (600, 200);orpack ();Kind regards,
      Levi
    PS:
        int i;
    parses to
    int i;
    , but
    [code]    int i;[code[i]]
    parses to
        int i;

  • I have made a book of my I Photo pictures. In certain layouts there is a textframe. How can I avoid the frame becoming visible in the print if I don't want to write anything? Should I just leave it or should I delete the text "Write your text here" ?

    I have made a book of my iPhoto pictures. In certain layouts there is a text frame. How can I avoid the frame becoming visible in the print if I don't want to write anything?  Should I just leave it untouched or should I delete the instructing text "Write your text here"?

    Most pages have layouts for pictures only or pictures with text boxes. Either select the same layout for that page but the one without the text box or put a space in the text box.
    Putting a space in the text box will avoid getting the warning when ordering that there's an unfilled text box in the book. The box will not be visible in the final product.  You can and should check the book before ordering by previewing it as described in this Apple document: iPhoto '11: Preview a book, card, or calendar before you order or print it
    Happy Holidays

  • How to find a text in the Frame maker document via script?

    How to find a particular text in the Frame maker document via script?

    johnsyns wrote:
    Why it doesn't work for the other days? When i tried to change the days other than wednesday. it return nothing.
    Reason why Justin's code does not work for other days is date format mask DAY returns day blank padded to 9 characters which is the longest day name which, yes you guessed right, is WEDNESDAY. You either need to blank pad or use format modifier FM:
    SQL> select *
      2    from (SELECT TO_DATE(SYSDATE+ROWNUM, 'DD-MON-YY') dt
      3            FROM DUAL CONNECT BY ROWNUM <= 27)
      4  WHERE TO_CHAR(dt,'DAY') = 'TUESDAY'
      5  /
    no rows selected
    SQL> select *
      2    from (SELECT TO_DATE(SYSDATE+ROWNUM, 'DD-MON-YY') dt
      3            FROM DUAL CONNECT BY ROWNUM <= 27)
      4  WHERE TO_CHAR(dt,'DAY') = 'TUESDAY  '
      5  /
    DT
    07-APR-09
    14-APR-09
    21-APR-09
    28-APR-09
    SQL> select *
      2    from (SELECT TO_DATE(SYSDATE+ROWNUM, 'DD-MON-YY') dt
      3            FROM DUAL CONNECT BY ROWNUM <= 27)
      4  WHERE TO_CHAR(dt,'FMDAY') = 'TUESDAY'
      5  /
    DT
    07-APR-09
    14-APR-09
    21-APR-09
    28-APR-09
    SQL> SY.

  • How can I change the frame rate of a project in imovie 10?

    My problem is: I made a gopro movie with a frame rate of 50 fps. I imported it to imovie. So far so good.
    Scrubbing over the clip i found one single frame which looked amazing. So I draged some seconds of that clip into the timeline (the project if you will).
    The goal was to make a freeze frame out of this "spezial" frame.
    Unfortunately I could not find this frame in the timeline any more - it's gone.
    I think imovie dropped half of the frames to fit the clip into the projekt, which I assume is using 24-25fps.
    The only solution I found is to decrease the speed of the clip to let's say 50%.
    But is there a better way?
    Can I change the frame rate of the projekt somehow? I think it was possible in imovie 11.
    many thanks
    Rainer
    (from austria)

    iMovie 10 won't share at 50 fps and so for 25 fps output probably drops every other frame.  This is different from Imovie 9 which could handle 50 fps.  However, if you do 50% speed it will use all the available frames so that is indeed the way to find the frame you want.  After you have made a freeze frame I think you can switch the clip back to normal speed.  I am not aware of a better way in iMovie 10  By the way there is also no facility to export a still of a frame in iMovie.
    As a GoPro user I think FCP 10.1 would be the best choice.
    Geoff.

Maybe you are looking for

  • Steps to upgrade Discoverer 4i to 11g

    Hi, Can you one please let me know what are the steps required to upgrade 4i to 11g. Thanks, Sri

  • How to get to your files when your Time Capsule dies :(

    I am posting this here to help someone who cannot access a Time Machine backup because the backup was "corrupted" the <insert whatever obscure message that contains the word "sparsebundle" here> message appears the Time Machine won't open up your bac

  • Create record by the enter key

    I have a form with 10 items. Looks like this P16_ID hidden P16_Created_on Date Picker P16_Order_No Text Field P16_Origin Display as Text(saves state) P16_Destination Display as Text(saves state) P16_Bill_To_Location Display as Text(save state) P16_Ra

  • Connect to a printer that connected to a PC running Windows 7

    Hello I'm using an iMac running Snow Leopard, and a PC running Windows 7. I have a Brother DCP 130-C printer/scanner connected to the PC. I want the printer to be shared between both computers to be able to print wirelessly from my mac. How can I do

  • Ipad mini won't stay connected to home network...and I've tried ALL the fixes

    I know other people have been posting this problem, but none of the fixes posted in the forums work for me. No matter whether I restart or reset my mini, it only holds the wifi connection for a few minutes. Then, though it says it's still connected,