How do i make my public ip static?

Hello. I host a server for me and my friends to mplay on. When ever i unplug the router or the power goes out, my ip changes. Is there a way to make my ip stay the same so i dont have to tell my friends the new one? Thanks.

Call Comcast and ask for a static IP address. They will be happy to provide one for $19.95/month, or a block of 5 addresses for $24.95/month.  

Similar Messages

  • How do I make dynamic text look static while the HMTL tagging is enabled?

    Hi all,
    I am using flash 8 with AS 2.0.
    I have a dynamic text field where I am setting it's text value through a variable. Now, I need this dynamic text field content to look like static font on runtime. I tried embedding the text field but that makes my file so heavy and most importantly, it disables the HTML tagging on the text field.
    Please suggest me on how to make a dynamic text field content look static on runtime while the HTML tagging is enabled and working fine.
    Thanks.

    I am sorry. But the attachment was not intended for what you
    thought my friend.
    It was there so that there are no confusions for what I mean by look of dynamic and static text fields.

  • How do I make a clipping mask static?

    I have a group of objects that move around within a 700x500 px artboard. The size of one object within this group is a map that spills over outside the artboard. I want this group to only be 400 px high, but not change anything withing the group. Just shorten the height of the clip. When I tried to just clip the height to 400 the clipping obviously followed the zooming of the animation of the group. I want the hight to be static at 400 when the animation plays.
    Any ideas? Do I need a second clipping mask like I would have added if I worked in Illustrator? So I could move a whole group within a static clipping mask. If so, how do I create one?

    "1) remove the clip set to the group"
    How? When I mark the group and then click on clipping tool (only why I know to mark the clipping mask) I can´t delete it without deleting the entire group.
    "2) use style="overflow:hidden" instead of use style="overflow:visible"
    But that´s on the stage? It´s already set at hidden there. I don´t want to change the height of the stage.

  • How to create website on iweb and make it public, and tell me how to put a password on it.

    Hi, can you tell me how to create website on iweb and make it public, and tell me how to put a password on it, thanks.

    Find a webhosting company :
    http://www.google.jo/search?q=webhosting+jordan
    They will provide the instructions how to password protect a directory (=folder)?
    Until you find one, you can practice on your own computer :
    http://www.wyodor.net/Tutorials/iWebDemo/sFTP.html
    Here's a some tutorials :
    http://www.apple.com/findouthow/web/

  • How To Make A Public Page Parameter (similar to session)

    Hi, I'm new to Oracle Portal
    I wonder how to make a public parameter that can be accessed from any page (similar to session).
    So the portlets can use the public parameter.
    Case:
    when user logged in, I pass the employee_ID to the session.
    Portal pages, which contains employee portlet, and some other portlet depends on employee_ID.
    So I think, may be there's a way to set the parameter for once, but the value is accessible until the user log off.
    Any suggestion or help?
    Thx before,
    Chris

    Let me explain the problem once again:
    Page 1 Portlet 1 contains employee table
    ID, Name, Address
    When I click the employee ID (using event), it will be pass the value to page parameter EMPID
    And i want this EMPID can be accessed by
    Portlet 2 - Showing sales report
    Portlet 3 - Showing report
    Portlet 4 - Showing chart
    Portlet 5
    and so on
    Portlet 2, 3 4, 5, and so on is using EMPID as the parameter too,
    but these portlets are located in different page
    Portlet 2 is in page 2
    Portlet 3 is in page 3
    Portlet 4 is in page 4
    Portlet 5 is in page 5
    and so on
    First I think about using Package wwpro_api_parameters
    but after read further, this package can get and retrieve only
    I wonder can this (public page parameter) be done by using default Oracle Portal Tools / API, or I should do some java coding, or something else?
    Please help me...
    Thanx before,
    Chris

  • How to javadoc "public final static int"?

    How can we create "Field Summary" HTML document for "public final static int" variables?
    This question is probably same as the below question.
    http://forums.java.sun.com/thread.jsp?forum=41&thread=72832
    p.s.
    The below document indicates CENTER, NORTH, ...
    How an we achieve it to document "public final static" variables?
    http://java.sun.com/products/jdk/1.2/docs/api/index.html

    No, 1.3 does not have the static constant values exposed to the Doclet API,
    and so that information is not available to any doclets to place in the
    generated documentation.
    BTW, based on feedback from a developer, we changed the format from:
    public static final int NORTH = 0
    to
    public static final int NORTH
    See: Constant values
    where the "Constant values" link takes them to a summary page that
    lists all of the values. This helps discourage users from mistakenly
    seeing and using the value instead of the constant.
    -Doug Kramer
    Javadoc team

  • How to make page public / non public with api

    I need to turn some pages to be public or non-public (the same as the tick box on the access page) using plsql. But the API's wwsec_api.set_user_acl or wwsec_api.set_group_acl do not seem to work for public. How can I a page public or non public using plsql.

    supported solution for doing this is using wwsbr_api.modify_folder(p_page => p_page);
    (from version 10.1.4)
    you should have something like this
    SELECT *
    INTO r_page
    FROM wwv_user_corners
    WHERE siteid = p_pgrid
    AND id = p_pageID
    AND language = p_portal_lang;
    r_page.ispublic := 1;
    wwsbr_api.modify_folder(p_page => p_page);

  • How can I make the combo box turn to the value of black.

    When the show button is pressed (and not before), a filled black square should be
    displayed in the display area. The combo box (or drop down list) that enables the user to choose the colour of
    the displayed shape and the altering should take effect immediately.When the show button is pressed,
    the image should immediately revert to the black square, the combo box should show the value that
    correspond to the black.
    Now ,the problem is: after I pressed show button, the image is reverted to the black square,but I don't know
    how can I make the combo box turn to the value of black.
    Any help or hint?Thanks a lot!
    coding 1.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class test extends JFrame {
         private JPanel buttonPanel;
         private DrawPanel myPanel;
         private JButton showButton;
         private JComboBox colorComboBox;
    private boolean isShow;
         private int shape;
         private boolean isFill=true;
    private String colorNames[] = {"black", "blue", "cyan", "darkGray", "gray",
    "green", "lightgray", "magenta", "orange",
    "pink", "red", "white", "yellow"}; // color names list in ComboBox
    private Color colors[] = {Color.black, Color.blue, Color.cyan, Color.darkGray,
                              Color.gray, Color.green, Color.lightGray, Color.magenta,
                              Color.orange, Color.pink, Color.red, Color.white, Color.yellow};
         public test() {
         super("Draw Shapes");
         // creat custom drawing panel
    myPanel = new DrawPanel(); // instantiate a DrawPanel object
    myPanel.setBackground(Color.white);
         // set up showButton
    // register an event handler for showButton's ActionEvent
    showButton = new JButton ("show");
         showButton.addActionListener(
              // anonymous inner class to handle showButton events
         new ActionListener() {
                   // draw a black filled square shape after clicking showButton
         public void actionPerformed (ActionEvent event) {
                             // call DrawPanel method setShowStatus and pass an parameter
              // to decide if show the shape
         myPanel.setShowStatus(true);
                   isShow = myPanel.getShowStatus();
                                            shape = DrawPanel.SQUARE;
                        // call DrawPanel method setShape to indicate shape to draw
                                            myPanel.setShape(shape);
                        // call DrawPanel method setFill to indicate to draw a filled shape
                                            myPanel.setFill(true);
                        // call DrawPanel method draw
                                            myPanel.draw();
                             myPanel.setFill(true);
                             myPanel.setForeground(Color.black);
                   }// end anonymous inner class
         );// end call to addActionListener
    // set up colorComboBox
    // register event handlers for colorComboBox's ItemEvent
    colorComboBox = new JComboBox(colorNames);
    colorComboBox.setMaximumRowCount(5);
    colorComboBox.addItemListener(
         // anonymous inner class to handle colorComboBox events
         new ItemListener() {
         // select shape's color
         public void itemStateChanged(ItemEvent event) {
         if(event.getStateChange() == ItemEvent.SELECTED)
         // call DrawPanel method setForeground
         // and pass an element value of colors array
         myPanel.setForeground(colors[colorComboBox.getSelectedIndex()]);
    myPanel.draw();
    }// end anonymous inner class
    ); // end call to addItemListener
    // set up panel containing buttons
         buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(4, 1, 0, 50));
         buttonPanel.add(showButton);
    buttonPanel.add(colorComboBox);
    JPanel radioButtonPanel = new JPanel();
    radioButtonPanel.setLayout(new GridLayout(2, 1, 0, 20));
    Container container = getContentPane();
    container.setLayout(new BorderLayout(10,10));
    container.add(myPanel, BorderLayout.CENTER);
         container.add(buttonPanel, BorderLayout.EAST);
    setSize(500, 400);
         setVisible(true);
         public static void main(String args[]) {
         test application = new test();
         application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    coding 2
    import java.awt.*;
    import javax.swing.*;
    public class DrawPanel extends JPanel {
         public final static int CIRCLE = 1, SQUARE = 2;
         private int shape;
         private boolean fill;
         private boolean showStatus;
    private int shapeSize = 100;
    private Color foreground;
         // draw a specified shape
    public void paintComponent (Graphics g){
              super.paintComponent(g);
              // find center
    int x=(getSize().width-shapeSize)/2;
              int y=(getSize().height-shapeSize)/2;
              if (shape == CIRCLE) {
         if (fill == true){
         g.setColor(foreground);
              g.fillOval(x, y, shapeSize, shapeSize);
    else{
                   g.setColor(foreground);
    g.drawOval(x, y, shapeSize, shapeSize);
              else if (shape == SQUARE){
         if (fill == true){
         g.setColor(foreground);
                        g.fillRect(x, y, shapeSize, shapeSize);
    else{
                        g.setColor(foreground);
    g.drawRect(x, y, shapeSize, shapeSize);
    // set showStatus value
    public void setShowStatus (boolean s) {
              showStatus = s;
         // return showstatus value
    public boolean getShowStatus () {
              return showStatus;
         // set fill value
    public void setFill(boolean isFill) {
              fill = isFill;
         // set shape value
    public void setShape(int shapeToDraw) {
              shape = shapeToDraw;
    // set shapeSize value
    public void setShapeSize(int newShapeSize) {
              shapeSize = newShapeSize;
    // set foreground value
    public void setForeground(Color newColor) {
              foreground = newColor;
         // repaint DrawPanel
    public void draw (){
              if(showStatus == true)
              repaint();

    Hello,
    does setSelectedIndex(int anIndex)
    do what you need?
    See Java Doc for JComboBox.

  • How can i make my scrollpane in a way that at the opening of a frame it doe

    How can i make my scrollpane in a way that at the opening of a frame it does not scroll down automatically?
    code is below
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.net.*;
    import javax.swing.JOptionPane.*;
    import java.io.*;
    import javax.swing.colorchooser.*;
    import javax.swing.filechooser.*;
    import javax.accessibility.*;
    import javax.swing.border.*;
    import java.sql.*;
    public class Signup extends JFrame
         JLabel p1,p2,p3,p4,p5,p6,uid,upass,cpass,fname,sname,hint,sl,ed,age,adr,cit,zip;
         JTextField uname,fnamet,snamet,hintt,adrt,adrt1,city,zipcode;
         JPasswordField upassw,cpassw;     
         JComboBox sex,education,agegr;
         Signup()
         Container c=getContentPane();
         c.setLayout(null);
         c.setBackground(Color.white);
         /** JPanel c = new JPanel();
         c.setBackground(Color.white);
         int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
         int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
         JScrollPane jsp = new JScrollPane(c, v, h); ***/
    p1=new JLabel("Create Your Icafe!ID",10);
         p2=new JLabel("Personal Information");
         p3=new JLabel("User Address");
         p4=new JLabel("Tell Us About Your Hobbiess (Optional) ");
         p5=new JLabel("Tell us something about what you like. This will help us choose the kind of content to display on           your pages.");
         p6=new JLabel("--------------------------------------------------------------------------------");
    uid=new JLabel("User Id");
         upass=new JLabel("Password");
         cpass=new JLabel("Confirmation Password");
         fname=new JLabel("UserName");
         sname=new JLabel("SurName");
         hint=new JLabel("Hint Question");
    sl=new JLabel("Sex");
         ed=new JLabel("Education");     
         age=new JLabel("Age Group");     
         adr=new JLabel("Address");
    cit=new JLabel("City");
    zip=new JLabel("ZipCode");
         uname=new JTextField(10);
         uname.requestFocus();     
         uname.setToolTipText("UserName");
    upassw=new JPasswordField(10);
         upassw.setToolTipText("Password");
         upassw.setEchoChar('*');
         cpassw=new JPasswordField(10);
         cpassw.setToolTipText("Confirmation Password");
         cpassw.setEchoChar('*');
         fnamet=new JTextField(10);
         fnamet.setToolTipText("FullName");
         snamet=new JTextField(10);
         snamet.setToolTipText("SurName");
         hintt=new JTextField(10);
         hintt.setToolTipText("Hint Question");     
    String[] gender={"[Select one]","Male","Female"};
         sex = new JComboBox(gender);          
    String[] edu={"[Select one]","S.S.C","Inter","Graduate","Post Graduate"};
         education= new JComboBox(edu);     
    String[] ageg={"[Select one]","0 - 15","16 - 35","36 - 70","70 - 100"};
         agegr= new JComboBox(ageg);     
    adrt=new JTextField(15);
         adrt.setToolTipText("Address");
         adrt1=new JTextField(15);
         adrt1.setToolTipText("Address");
         city=new JTextField(15);
         city.setToolTipText("City");
    zipcode=new JTextField(15);
         zipcode.setToolTipText("ZipCode");
         p1.setBounds(200,70,160,30);
         uid.setBounds(350,100,160,30);
         uname.setBounds(400,100,160,30);
         upass.setBounds(335,140,160,30);
         upassw.setBounds(400,140,160,30);
         cpass.setBounds(260,180,160,30);
         cpassw.setBounds(400,180,160,30);
         p2.setBounds(200,220,160,30);
         fname.setBounds(330,260,160,30);
         fnamet.setBounds(400,260,160,30);
         sname.setBounds(335,300,160,30);
         snamet.setBounds(400,300,160,30);
    hint.setBounds(315,340,160,30);     
    hintt.setBounds(400,340,160,30);
         sl.setBounds(370,380,160,30);     
         sex.setBounds(400,380,160,30);
         ed.setBounds(335,420,160,30);     
         education.setBounds(400,420,160,30);
    age.setBounds(330,460,160,30);
    agegr.setBounds(400,460,160,30);
    p3.setBounds(200,500,160,30);
         adr.setBounds(340,540,160,30);
         adrt.setBounds(400,540,160,30);
         adrt1.setBounds(400,580,160,30);
         cit.setBounds(370,620,160,30);
         city.setBounds(400,620,160,30);
    zip.setBounds(590,620,160,30);
    zipcode.setBounds(640,620,160,30);
         Font font = new Font("SansSerif",Font.BOLD, 12);
         setFont(font);
         c.add(p1);
    c.add(uid);
         c.add(uname);     
         c.add(upass);
         c.add(upassw);
    c.add(cpass);
         c.add(cpassw);
    c.add(p2);
    c.add(fname);     
         c.add(fnamet);
    c.add(sname);
    c.add(snamet);
         c.add(hint);
    c.add(hintt);     
    c.add(sl);
    c.add(sex);
    c.add(ed);
         c.add(education);
    c.add(age);
         c.add(agegr);
    c.add(p3);
    c.add(adr);
         c.add(adrt);
         c.add(adrt1);
    c.add(cit);
    c.add(city);
    c.add(zip);
    c.add(zipcode);
         setResizable(false);
         //int a=DO_NOTHING_ON_CLOSE;
         //setDefaultCloseOperation(a);
         show();
         setSize(800,500);
    // Border raisedBorder = new BevelBorder(BevelBorder.RAISED);     
         setContentPane(c);     
    public static void main (String arg[])
         try{
         UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
         }catch(Exception s)
         Signup swu=new Signup();

    just try the following:
    jsp.getVerticalScrollbar().setValue(0);after inserting and adding all your components. this will set the vertical scrollbar up to the very first line.
    regards

  • How do I make this code generate a new pro when the "NEXT" button is pushed

    How do I make this code generate a new set of problem when the "NEXT" Button is pushed
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    /* Figure out how to create a new set of problms
    * Type a list of specifications, include a list of test cases
    * DONE :]
    package javaapplication1;
    import java.awt.GridLayout;
    import java.awt.Window;
    import javax.swing.*;
    import java.awt.event.*;
    * @author Baba Akinlolu -
    class Grid extends JFrame{
        int done = 0;
        final int score = 0;
        final int total = 0;           
            //Create Panels
            JPanel p2 = new JPanel();
            JPanel p3 = new JPanel();
            final JPanel p1 = new JPanel();
            //Create Radio buttons & group them
            ButtonGroup group = new ButtonGroup();
            final JRadioButton ADD = new JRadioButton("Addition");
            final JRadioButton SUB = new JRadioButton("Subtraction");
            final JRadioButton MUL = new JRadioButton("Multiplication");
            final JRadioButton DIV = new JRadioButton("Division");
            //Create buttons
            JButton NEXT = new JButton("NEXT");
            JButton END = new JButton("End");
            //Create Labels
            JLabel l1 = new JLabel("First num");
            JLabel l2 = new JLabel("Second num");
            JLabel l3 = new JLabel("Answer:");
            JLabel l4 = new JLabel("Score:");
            final JLabel l5 = new JLabel("");
            JLabel l6 = new JLabel("/");
            final JLabel l7 = new JLabel("");
            //Create Textfields
            final JTextField number = new JTextField(Generator1());
            final JTextField number2 = new JTextField(Generator1());
            final JTextField answer = new JTextField(5);
        Grid(){
            setLayout(new GridLayout(4, 4, 2 , 2));
            p2.add(ADD);
            p2.add(SUB);
            group.add(ADD);
            group.add(SUB);
            group.add(MUL);
            group.add(DIV);
            p2.add(ADD);
            p2.add(SUB);
            p2.add(DIV);
            p2.add(MUL);
            //Add to panels
            p1.add(l1);
            p1.add(number);
            p1.add(l2);
            p1.add(number2);
            p1.add(l3);
            p1.add(answer);
            p1.add(l4);
            p1.add(l5);
            p1.add(l6);
            p1.add(l7);
            p3.add(NEXT);
            p3.add(END);
            //Add panels
            add(p2);
            add(p1);
            add(p3);
            //Create Listners
            Listeners();
    void Listeners(){
          NEXT.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
             int answer1 = 0;
             //Grab the numbers entered
             int numm1 = Integer.parseInt(number.getText());
             int numm2 = Integer.parseInt(number2.getText());
             int nummsanswer = Integer.parseInt(answer.getText());
             //Set the score and total into new variabls
             int nummscore = score;
             int nummtotal = total;
             //Check if the add radio button is selected if so add
             if (ADD.isSelected() == true){
                 answer1 = numm1 + numm2;
             //otherwise check if the subtract button is selected if so subtract
             else if (SUB.isSelected() == true){
                 answer1 = numm1 - numm2;
             //check if the multiplication button is selected if so multiply
             else if (MUL.isSelected() == true){
                 answer1 = numm1 * numm2;
             //check if the division button is selected if so divide
             else if (DIV.isSelected() == true){
                 answer1 = numm1 / numm2;
             //If the answer user entered is the same with th true answer
             if (nummsanswer == answer1){
                 //add to the total and score
                 nummtotal += 1;
                 nummscore += 1;
                 //Convert the input back to String
                 String newscore = String.valueOf(nummscore);
                 String newtotal = String.valueOf(nummtotal);
                 //Set the text
                 l5.setText(newscore);
                 l7.setText(newtotal);
             //Otherwise just increase the total counter
             else {
                 nummtotal += 1;
                 String newtotal = String.valueOf(nummtotal);
                 l7.setText(newtotal);
      //Create End listener
    END.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // get the root window and call dispose on it
            Window win = SwingUtilities.getWindowAncestor(p1);
            win.dispose();
    //new Grid();
    String Generator1(){
         int randomnum;
         randomnum = (1 + (int)(Math.random() * 100));
         String randomnumm = String.valueOf(randomnum);
         return randomnumm;
    public class Main {
         * @param args the command line arguments
        public static void main(String[] args) {
            // TODO code application logic here
            JFrame frame = new Grid();
            frame.setTitle("Flashcard Testing");
            frame.setSize(500, 200);
            frame.setLocationRelativeTo(null);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
    }Edited by: SirSaula on Dec 7, 2009 10:17 AM

    Not only are you continuing to post in the wrong forum but now you are multiposting: [http://forums.sun.com/thread.jspa?threadID=5418935]
    If people haven't answered you other posting its probably because we don't understand the question. Quit cluttering the forum by asking the same question over and over and then next time you have a new question post it in the proper forum. Your first posting was moved becuase you didn't post it properly.

  • How do i make Images show ?

    Hello :) I'm writing a simple game but I am having so much trouble with it :( here is the code now all it does right now is it writes out the values of the cards on the screen in an applet however I want it to display card images from http://www.waste.org/~oxymoron/cards
    i can't get it to use the string values and give me the card images instead of text... please help a woman in trouble ;O) thank you
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    //import java.applet.*;
    ///import java.util.*;
    public class HighLowGUI extends JApplet {
    //private HighLowGUI label = new HighLowGUI("Socrates");      // CyberPet
        //private JLabel nameLabel = new JLabel("Hi! My name is ");
        //private TextField stateField = new TextField(12);      // A TextField
       public void init() {
             // The init() method lays out the applet.
             // A HighLowCanvas occupies the CENTER position of the layout.
             // On the bottom is a panel that holds three buttons.  The
             // HighLowCanvas object listens for ActionEvents from the
             // buttons and does all the real work of the program.
          setBackground( new Color(130,50,40) );
          HighLowCanvas board = new HighLowCanvas();
          getContentPane().add(board, BorderLayout.CENTER);
          JPanel buttonPanel = new JPanel();
          buttonPanel.setBackground( new Color(220,200,180) );
          getContentPane().add(buttonPanel, BorderLayout.SOUTH);
          JButton higher = new JButton( "Deal" );
          higher.addActionListener(board);
          buttonPanel.add(higher);
          JButton newGame = new JButton( "New Game" );
          newGame.addActionListener(board);
          buttonPanel.add(newGame);
         // JLabel nameLabel = new JLabel("Hi! My name is ");
       }  // end init()
       class HighLowCanvas extends JPanel implements ActionListener {
             private Image eatImg, eat2Img, sleepImg, happyImg;     // Images for animation
            // A nested class that displays the cards and does all the work
             // of keeping track of the state and responding to user events.
          Deck deck;       // A deck of cards to be used in the game.
          Hand hand;       // The cards that have been dealt.
          String message;  // A message drawn on the canvas, which changes
                           //    to reflect the state of the game.
          boolean gameInProgress;  // Set to true when a game begins and to false
                                   //   when the game ends.
          Font bigFont;      // Font that will be used to display the message.
          Font smallFont;    // Font that will be used to draw the cards.
          HighLowCanvas() {
                // Constructor.  Creates sets the foreground and
                // background colors, and starts the first game.
          setBackground( new Color(0,120,0) );
             setForeground( Color.yellow);
                     //  smallFont = new Font("SansSerif", Font.PLAIN, 12);
                      // bigFont = new Font("Serif", Font.BOLD, 14);
            doNewGame();
          } // end constructor
          public void actionPerformed(ActionEvent evt) {
                 // Respond when the user clicks on a button by calling
                 // the appropriate procedure.  Note that the canvas is
                 // registered as a listener in applet's init() method.
             String command = evt.getActionCommand();
             if (command.equals("Deal"))
                doDeal();
             else if (command.equals("New Game"))
                doNewGame();
          } // end actionPerformed()
          void doDeal() {
                   // Called by actionPerformmed() when user clicks "Higher" button.
                   // Check the user's prediction.  Game ends if user guessed
                   // wrong or if the user has made three correct predictions.
             if (gameInProgress == false) {
                   // If the game has ended, it was an error to click "Higher",
                   // So set up an error message and abort processing.
                message = "Click \"New Game\" to start a new game!";
                repaint();
                return;
             hand.addCard( deck.dealCard() );     // Deal a card to the hand.
             int cardCt = hand.getCardCount();
             Card thisCard = hand.getCard( cardCt - 1 );  // Card just dealt.
             Card prevCard = hand.getCard( cardCt - 2 );  // The previous card.
             if ( thisCard.getValue() < prevCard.getValue() ) {
                gameInProgress = false;
                message = "Too bad! You lose.";
             else if ( thisCard.getValue() == prevCard.getValue() ) {
                gameInProgress = false;
                message = "Too bad!  You lose"; // on ties
             else if ( cardCt == 4) {    //CHANGED+++++++++++++++++=
                gameInProgress = false;
               message = "You win! Hurra! ";
             else {
                message = "Got it right!  Try for " + cardCt + " Press  -Deal- ";
             repaint();
          } // end
          void doNewGame() {
                 // Called by the constructor, and called by actionPerformed() if
                 // the use clicks the "New Game" button.  Start a new game.
             if (gameInProgress) {
                     // If the current game is not over, it is an error to try
                     // to start a new game.
                message = "You still have to finish this game! Press   -Deal-";
                repaint();
                return;
             deck = new Deck();   // Create the deck and hand to use for this game.
             hand = new Hand();
             deck.shuffle();
             hand.addCard( deck.dealCard() );  // Deal the first card into the hand.
             message = "Deal your cards";
             gameInProgress = true;
             repaint();
          } // end doNewGame()
          public void paintComponent(Graphics g) {
                // This method draws the message at the bottom of the
                // canvas, and it draws all of the dealt cards spread out
                // across the canvas.  If the game is in progress, an
                // extra card is dealt representing the card to be dealt next.
             super.paintComponent(g);
                  g.setFont(bigFont);
                  g.drawString(message,10,135);
                  g.setFont(smallFont);
             int cardCt = hand.getCardCount();
                  for (int i = 0; i < cardCt; i++)
                        drawCard(g, hand.getCard(i), 10 + i * 90, 10);
             if (gameInProgress)
                drawCard(g, null, 10 + cardCt * 90, 10);
          } // end paintComponent()
          void drawCard(Graphics g, Card card, int x, int y) {
                  // Draws a card as a 80 by 100 rectangle with
                  // upper left corner at (x,y).  The card is drawn
                  // in the graphics context g.  If card is null, then
                  // a face-down card is drawn.  (The cards are
                  // rather primitive.)
             if (card == null) {      // Draw a face-down card
                g.setColor(Color.blue);
                g.fillRect(x,y,80,100);
                g.setColor(Color.white);
                g.drawRect(x+3,y+3,73,93);
                g.drawRect(x+4,y+4,71,91);
             else {
                g.setColor(Color.white);
                g.fillRect(x,y,80,100);
                g.setColor(Color.gray);
                g.drawRect(x,y,79,99);
                g.drawRect(x+1,y+1,77,97);
             if (card.getSuit() == Card.DIAMONDS || card.getSuit() == Card.HEARTS)
                g.setColor(Color.red);
             else
                g.setColor(Color.black);
                g.drawString(card.getValueAsString(), x + 10, y + 30);
                g.drawString("of", x+ 10, y + 50);
                g.drawString(card.getSuitAsString(), x + 10, y + 70);
          } // end drawCard()
       } // end nested class HighLowCanvas
    } // end class HighLowGUI
       An object of class card represents one of the 52 cards in a
       standard deck of playing cards.  Each card has a suit and
       a value.
    public class Card {
        public final static int SPADES = 0,       // Codes for the 4 suits.
                                HEARTS = 1,
                                DIAMONDS = 2,
                                CLUBS = 3;
        public final static int ACE = 1,          // Codes for the non-numeric cards.
                                JACK = 11,        //   Cards 2 through 10 have their
                                QUEEN = 12,       //   numerical values for their codes.
                                KING = 13;
        private final int suit;   // The suit of this card, one of the constants
                                  //    SPADES, HEARTS, DIAMONDS, CLUBS.
        private final int value;  // The value of this card, from 1 to 11.
        public Card(int theValue, int theSuit) {
                // Construct a card with the specified value and suit.
                // Value must be between 1 and 13.  Suit must be between
                // 0 and 3.  If the parameters are outside these ranges,
                // the constructed card object will be invalid.
            value = theValue;
            suit = theSuit;
        public int getSuit() {
                // Return the int that codes for this card's suit.
            return suit;
        public int getValue() {
                // Return the int that codes for this card's value.
            return value;
        public String getSuitAsString() {
                // Return a String representing the card's suit.
                // (If the card's suit is invalid, "??" is returned.)
            switch ( suit ) {
               case SPADES:   return "Spades";
               case HEARTS:   return "Hearts";
               case DIAMONDS: return "Diamonds";
               case CLUBS:    return "Clubs";
               default:       return "??";
        public String getValueAsString() {
                // Return a String representing the card's value.
                // If the card's value is invalid, "??" is returned.
            switch ( value ) {
               case 1:   return "A";
               case 2:   return "2";
               case 3:   return "3";
               case 4:   return "4";
               case 5:   return "5";
               case 6:   return "6";
               case 7:   return "7";
               case 8:   return "8";
               case 9:   return "9";
               case 10:  return "10";
               case 11:  return "J";
               case 12:  return "Q";
               case 13:  return "K";
               default:  return "??";
        public String toString() {
               // Return a String representation of this card, such as
               // "10 of Hearts" or "Queen of Spades".
            //return ""+"
            return getValueAsString() + " of " + getSuitAsString();
    } // end class Card
        An object of type Deck represents an ordinary deck of 52 playing cards.
        The deck can be shuffled, and cards can be dealt from the deck.
    public class Deck {
        private Card[] deck;   // An array of 52 Cards, representing the deck.
        private int cardsUsed; // How many cards have been dealt from the deck.
        public Deck() {       // Create an unshuffled deck of cards.
           deck = new Card[52];
           int cardCt = 0;    // How many cards have been created so far.
           for ( int suit = 0; suit <= 3; suit++ ) {
              for ( int value = 1; value <= 13; value++ ) {
                 deck[cardCt] = new Card(value,suit);
                 cardCt++;
           cardsUsed = 0;
        public void shuffle() {
              // Put all the used cards back into the deck, and shuffle it into
              // a random order.
            for ( int i = 51; i > 0; i-- ) {
                int rand = (int)(Math.random()*(i+1));
                Card temp = deck;
    deck[i] = deck[rand];
    deck[rand] = temp;
    cardsUsed = 0;
    public int cardsLeft() {
    // As cards are dealt from the deck, the number of cards left
    // decreases. This function returns the number of cards that
    // are still left in the deck.
    return 52 - cardsUsed;
    public Card dealCard() {
    // Deals one card from the deck and returns it.
    if (cardsUsed == 52)
    shuffle();
    cardsUsed++;
    return deck[cardsUsed - 1];
    } // end class Deck
    An object of type Hand represents a hand of cards. The maximum number of
    cards in the hand can be specified in the constructor, but by default
    is 5. A utility function is provided for computing the value of the
    hand in the game of Blackjack.
    import java.util.Vector;
    public class Hand {
    private Vector hand; // The cards in the hand.
    public Hand() {
    // Create a Hand object that is initially empty.
    hand = new Vector();
    public void clear() {
    // Discard all the cards from the hand.
    hand.removeAllElements();
    public void addCard(Card c) {
    // Add the card c to the hand. c should be non-null. (If c is
    // null, nothing is added to the hand.)
    if (c != null)
    hand.addElement(c);
    public void removeCard(Card c) {
    // If the specified card is in the hand, it is removed.
    hand.removeElement(c);
    public void removeCard(int position) {
    // If the specified position is a valid position in the hand,
    // then the card in that position is removed.
    if (position >= 0 && position < hand.size())
    hand.removeElementAt(position);
    public int getCardCount() {
    // Return the number of cards in the hand.
    return hand.size();
    public Card getCard(int position) {
    // Get the card from the hand in given position, where positions
    // are numbered starting from 0. If the specified position is
    // not the position number of a card in the hand, then null
    // is returned.
    if (position >= 0 && position < hand.size())
    return (Card)hand.elementAt(position);
    else
    return null;
    public void sortBySuit() {
    // Sorts the cards in the hand so that cards of the same suit are
    // grouped together, and within a suit the cards are sorted by value.
    // Note that aces are considered to have the lowest value, 1.
    Vector newHand = new Vector();
    while (hand.size() > 0) {
    int pos = 0; // Position of minimal card.
    Card c = (Card)hand.elementAt(0); // Minumal card.
    for (int i = 1; i < hand.size(); i++) {
    Card c1 = (Card)hand.elementAt(i);
    if ( c1.getSuit() < c.getSuit() ||
    (c1.getSuit() == c.getSuit() && c1.getValue() < c.getValue()) ) {
    pos = i;
    c = c1;
    hand.removeElementAt(pos);
    newHand.addElement(c);
    hand = newHand;
    public void sortByValue() {
    // Sorts the cards in the hand so that cards of the same value are
    // grouped together. Cards with the same value are sorted by suit.
    // Note that aces are considered to have the lowest value, 1.
    Vector newHand = new Vector();
    while (hand.size() > 0) {
    int pos = 0; // Position of minimal card.
    Card c = (Card)hand.elementAt(0); // Minumal card.
    for (int i = 1; i < hand.size(); i++) {
    Card c1 = (Card)hand.elementAt(i);
    if ( c1.getValue() < c.getValue() ||
    (c1.getValue() == c.getValue() && c1.getSuit() < c.getSuit()) ) {
    pos = i;
    c = c1;
    hand.removeElementAt(pos);
    newHand.addElement(c);
    hand = newHand;

    Please don't crosspost. It cuts down on the effectiveness of responses, leads to people wasting their time answering what others have already answered, makes for difficult discussion, and is generally just annoying and bad form.

  • How do you make an array of image icons and then call them?

    How do you make an array of image icons and then call them, i have searched all over the internet for making an array of icons, but i have
    found nothing. Below is my attempt at making an array of icons, but i cant seem to make it work. Basically, i want the image to match the value of the roll of the dice (rollVal)
    Any help would be greatly appreciated, some code or link to tuturial, ect.
    /** DiceRoller.java
    * Roll, print, Gui
    import javax.swing.*;
    public class DiceRoller extends JFrame
         private ImageIcon[] image  ;
         public String[] images = { "empty", "dice1.jpg",
                   "dice2.jpg", "dice3.jpg", "dice4.jpg",
                   "dice5.jpg", "dice6.jpg" };
         public Dice die;
         private int rollVal;
         public int rollNum;
         private JLabel j1;
         public DiceRoller(){
              j1= new JLabel("");
           die =new Dice();
           int rollVal;
           rollVal = die.roll();     
           image = new  ImageIcon[images.length];
         for(int i = 0; i < images.length; i++){
          image[i] = new ImageIcon(images);
         if (image!=null){
              j1.setIcon(image[rollVal]);
         System.out.println("Roll = "+die.roll());

    Demo:
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    public class IconExample {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    launch();
        static void launch() {
            try {
                Icon[] icons = new Icon[6];
                for(int i=0; i<icons.length; ++i) {
                    String url = "http://www.eureka-puzzle.be/cast/images/dice" + (i + 1) + ".jpg";
                    icons[i] = new ImageIcon(new URL(url));
                display(icons);
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
        static void display(Icon[] icons) {
            JPanel cp = new JPanel();
            for(Icon icon : icons) {
                cp.add(new JLabel(icon));
            JFrame f = new JFrame();
            f.setContentPane(cp);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • How do you make the program repeat itself?

    How would I make it so that when the if statement at the end of the code the program starts over from the begining?
    Any help appreciated. Here is the code if you wanna see it.
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    class SuperTester{
         public static void main ( String[] args ){
         // Create array that will hold deck
         Deck[] decko = new Deck[52];     
         // Fill the array with a deck
         decko = Deck.makeDeck();
         // Print new deck
         System.out.println( "PRINT NEW DECK" );
         System.out.println( "" );
         Deck.printDeck( decko );
         // Shuffle the deck ( simulated riffle shuffling )!
         decko = Deck.shuffleDeck( decko );
         // Print the shuffled deck
         System.out.println( "" );
         System.out.println( "PRINT SHUFFLED DECK" );
         System.out.println( "" );
         Deck.printDeck( decko );
         // Print first 5
         System.out.println( "" );
         System.out.println( "PRINT TOP 5" );
         System.out.println( "" );
         Deck.printFirstFive( decko );
         // Print single card
         System.out.println( "" );
         System.out.println( "PRINT SINGLE CARD" );
         System.out.println( "" );
         Deck.printCard ( decko [2] );
         System.out.println( "" );     
         BufferedReader in = new BufferedReader( new InputStreamReader (System.in));
         int input;
         System.out.println( " Do you want to re-run program? " );
         System.out.println( " Push 1 for yes " );
         System.out.println( " Push 2 for no " );
         System.out.println( "" );
    try
         input = Integer.parseInt( in.readLine() );
    catch( Exception e ){
    if ( input == 1 ){
    //WHAT DO I PUT HERE TO MAKE THE PROGRAM REPEAT ITSELF?
         } // end method
    } // end class

    So i should just do something like?
    int x = 0;
    while (x == 0){
    //code
    if (inpu == 1) {
        x == 0;
    }else{ x == 1; }                                                                                                                                                                                                                                                       

  • How can I make ANY vector  graphics with graphics2D and save on clipboard?

    I am at my wits end here, and need some help. Simply put, I have a program that creates a basic x-y graph, drawn in a jpanel. I want to create the graph as a vector (emf, eps, svg, I don't care anymore, any of them would be good). But, all I get is a jpg or bitmap.
    I tried using the infamous FreeHEP programs, but it won't recognize the output as anything but "image" which means bitmap/jpg.
         The user enters x/y data, clicks a button, which crreates a jpanel thusly:
    public class GraphMaker extends JPanel {
    static BufferedImage image = new BufferedImage(600, 500, BufferedImage.TYPE_INT_ARGB);
    GraphMaker(double[] xVals, double[] yVals, double[] sems){
    setPreferredSize(new Dimension (600,500));     
    symSize = 10;
    XminV = 0;
    XmaxV = 0;
    // code here just converts input x and y's to pixel coordinates, spacing of ticks, etc...
    for (int i =0;i < ArLn; i++){
    gX[i] = xO + (gX[i] * xRat);
    gX[i] -= xStart;
    gY[i] = gY[i] * yRat;
    gY[i] = yEnd - gY;
    semVal[i] = semVal[i]*yRat;
         Ymin = yEnd - (Ymin*yRat);
         Ymax = yEnd - (Ymax*yRat);
    BufferedImage anImage = new BufferedImage(600, 500, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = anImage.createGraphics();
    g2.setBackground(white);
    g2.setColor( Color.WHITE );
    g2.fillRect(0,0,600,500);
    g2.setStroke(stroke);
    // here I use the values to draw lines and circles - nothing spectacular:
              g2.setPaint(Color.blue);
              int ii = 0;
              for ( int j = 0; j < ArLn[ii]; j++ ) {
    g2.fill(new Ellipse2D.Float(LgX[ii][j] - symOffst, gY[ii][j]-symOffst, symSize,symSize));
    g2.draw(new Line2D.Float(LgX[ii][j],(gY[ii][j]-semVal[ii][j]),LgX[ii][j],(gY[ii][j]+semVal[ii][j])));
    g2.draw(new Line2D.Float(LgX[ii][j]-2.0f,(gY[ii][j]-semVal[ii][j]),LgX[ii][j]+2.0f,(gY[ii][j]-semVal[ii][j])));
    g2.draw(new Line2D.Float(LgX[ii][j]-2.0f,(gY[ii][j]+semVal[ii][j]),LgX[ii][j]+2.0f,(gY[ii][j]+semVal[ii][j])));
                        g2.draw(new Line2D.Float(xLoVal[ii],yLoVal[ii],xHiVal[ii],yHiVal[ii]));
    image = anImage;
    And, when the user clicks on the "copy" button, invokes this:
    public class Freep implements Transferable, ClipboardOwner {
         public static final DataFlavor POSTSCRIPT_FLAVOR = new DataFlavor("application/postscript", "Postscript");
         private static DataFlavor[] supportedFlavors = {
              DataFlavor.imageFlavor,
              POSTSCRIPT_FLAVOR,
              DataFlavor.stringFlavor
         private static JPanel chart;
         private int width;
         private int height;
         public Freep(JPanel theGraph, int width, int height) {
              this.theGraph = Graphs;
              this.width = width;
              this.height = height;
    //******This is the key method right here: It is ALWAYS imageFlavor, never anything else. How do I make this an EPS flavor?
         public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    if (flavor.equals(DataFlavor.imageFlavor)) {
    return GraphMaker.image;
    else if (flavor.equals(POSTSCRIPT_FLAVOR)) {
                   return new ByteArrayInputStream(epsOutputStream().toByteArray());
    else if (flavor.equals(DataFlavor.stringFlavor)) {
                   return epsOutputStream().toString();
              } else{
                   throw new UnsupportedFlavorException(flavor);
         private ByteArrayOutputStream epsOutputStream() throws IOException {
    EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
    g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
    ByteArrayOutputStream out = new ByteArrayOutputStream();
         public DataFlavor[] getTransferDataFlavors() {
              return supportedFlavors;
         public boolean isDataFlavorSupported(DataFlavor flavor) {
              for(DataFlavor f : supportedFlavors) {
                   if (f.equals(flavor))
                        return true;
              return false;
         public void lostOwnership(Clipboard arg, Transferable arg1) {
    The same happens with FreeHEP - I want the flavor to be EMF, but the program sees an image so it is always imageFlavor. I know I am missing something, but what, I don't know.
    thanks for your help.

    I don't think there's a built-in solution. One workaround I've seen is to create a dummy graphics class that overrides the desired drawing functions. Instead of actually drawing pixels, the object writes postscript commands to a buffer. There also seems to be commercial code that does exactly this.

  • How do I make content in a text field continue onto a new page?

    I am creating a form and one of the pages contains a text field for an essay. I'd like the responses in this text field to carry onto new pages if they reach the end of the first page. How do I make new pages appear with only the continued text field? Thanks!

    All right...
    public class guiClient extends JFrame implements ActionListener {
    static String userString;
    static String currentFont;
    String fontchoice;
    String fontlist;
    static JTextField userName = new JTextField();
    public guiClient() {
         super("My Client");
    public guiClient() {
         super("My Client");
    // Create a ComboBox
    GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String envfonts[] = gEnv.getAvailableFontFamilyNames();
    Vector vector = new Vector();
    for ( int i = 1; i < envfonts.length; i++ ) {
    vector.addElement(envfonts);
    JComboBox fontlist = new JComboBox (envfonts);
         fontlist.setSelectedIndex(0);
         fontlist.setEditable(true);
         fontlist.addActionListener(this);
         fontchoice = envfonts[0];     
    //Create a regular text field.
         JTextField textField = new JTextField(10);
         textField.setActionCommand(textFieldString);
         textField.addActionListener(this);
    public void actionPerformed(ActionEvent e) {
    //if the action is from the textfield (e.g. user hits enter)
         if (e.getActionCommand().equals(textFieldString)) {
              JTextField fromUser = (JTextField)e.getSource();
         if (fromUser != null){
    //place user text in editor pane
    //send message to server
                   if (userName.getText() != null) {
                        userString = userName.getText().trim();
                   out.println(userString + ": " + fromUser.getText());
              fromUser.setText("");
         else if (e.getActionCommand().equals(fontlist)){
         JComboBox cb = (JComboBox)e.getSource();
    String newSelection = (String)cb.getSelectedItem();
    currentFont = newSelection;
         userString = currentFont;
    return;

Maybe you are looking for