A short GUI question????

Hi guys...
I am writing a small program that reads a file in .csv format and creates a html file which is used to display the data contained in the .csv file out in the browser.
My question is how do you invoke the html file so that you get the html file diplayed in the browser by clicking in the JBotton porvided by the GUI of my program...
Cheers guys...

Hi johanup...
Are you saying that the code shieroi wrote would NOT
work on Mac, Linux, or Windows ME, 98 or 95. Yes, that's exactly what I said. I'm sorry if I wasn't clear enough. The code works on Windows NT, 2000 and XP by running cmd.exe, the command interpreter on those operating systems. Other OSs don't have that program. (They have similar programs doing similar things, but not with the same name.)
I checked the BrowserLauncher but I am not sure if it
is a class contained in the j2sdk 1.4.1.02 I have
downloaded from the java.sun.com or do you have to
download it from some site...No, it's not included in Sun's jdk.
If you have to download it form somewhere can you tell
me the url...Ehm, that's the URL I gave you.

Similar Messages

  • System.out.println in gui--- question

    Hello People.
    First of all, I'm new to the forums, so if it doesn't belong here, plese tell me where to post questions like this.
    The Problem:
    I have a GUI and another class,which contains the Program.
    Here's the code of my class:
    int Battle(String CharName) {
              System.out.println(CharName + " Is fighting agains a monster");
              while (CharHP > 0 && MonsterHP != 0) {
                   MonsterHP = MonsterHP - CharDmg;
                   System.out.println("The monster has " + MonsterHP + "Hitpoints left ");
                   CharHP = CharHP - MonsterDamage;
                   System.out.println(CharName + " has " + CharHP + " Hitpoints left");
              if (MonsterHP == 0) {
                   System.out.println(CharName + "Has lost the fight!");
                   CharEXP = CharEXP + 20;
                   System.out.println("You have gained " + CharEXP + " Exp");
              if (CharHP == 0) {
                   System.out.println("You have lost the fight!");
              return CharHP;
         }So what would be the code to print all the "System.out.println's" here into the gui test area?

    camickr wrote:
    Check out the [Message Console|http://www.camick.com/java/blog.html?name=message-console].
    Just out of curiosity, how do you come up with ideas for all the awesome stuff on your blog?

  • Administration Port / command line /  console gui question

    In the Admin_ref.pdf doc it says "After enabling the administration port, all Administration Console traffic must connect via the administration port". Does this mean that you can no longer use the web gui console to manage the servers?
    I would like the option to script deployments (deploy ears, stop start servers etc.) via command line to reduce the possibility of user error during routine deployments.
    I do config mgmt. and am not a developer so I may be getting hung up on the language here.
    Thanks,
    gj

    Hi
    For first question the answer is no. With the administration port, you enable the SSL between the admin server and Node manager-managed Servers. You can still use the web console.
    For teh second question, you can use ANT or can use the WLS Scripting ..you can get more details in dev2dev.bea.com
    Jin

  • Repository connection information gui question

    I am going through the "Getting started with oracle data integrator" document (E12641-01). I am at the part where I am supposed to create a work repository(step 5 of page 4-4). Unfortunately, the repostory connection information gui will not allow me to input a name for the work repository in the little text field. The cursor blinks but no text appears when I type. It is as if the text field is locked.
    The following describes my system configuration:
    Microsoft Windows Server 2003 R2 Standard x64 Edition Service Pack 2
    Oracle Data Integrator 11g Standalone Edition Version 11.1.1
    Build ODI_11.1.1.3.0_GENERIC_100623.1635
    Java(TM) Platform 1.6.0_25-ea
    Oracle IDE 11.1.1.3.0
    WebLogic server 10.3
    Oracle Server 11gR1
    I have both JDK 32bit and 64bit packages installed on my 64-bit machine. Apparently, odiclient only works with 32-bit jdk package.

    Question solved:
    http://st-curriculum.oracle.com/obe/fmw/odi/odi_11g/ODImaster_work_repos/ODImaster_work_repos.htm

  • GUI question on drawing x & y axis

    hey, im in the process of creating a gui that prints and sorts the bar graph according to the sorting method the user chooses through a menu. i havent came across any problems on getting the data and sorting it until it came to drawing out the bar graph. question is ive looked every where even my labs and lecture notes on how to draw GUI's but none mentioned how to draw and label the x and y axis.
    my y axis is the price which is 0-100 any suggestions on how i can draw out the y axis and have it increment with either $5 or $10 up till 100. and is it possible to put a letter on top of the bar graph that it belongs to?
    such as bar graph #1 can be labeled as A, which is placed on top of it because my x axis will not be given values. so bar graph#1 will be A ,with a price of $7
    any suggestions on how i can get started on drawing my graph or sites that i can learn from?

    import java.awt.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.text.NumberFormat;
    import javax.swing.*;
    public class GraphTest
        public static void main(String[] args)
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new GraphPanel());
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    class GraphPanel extends JPanel
        final int PAD;
        Font font;
        NumberFormat nf;
        public GraphPanel()
            PAD = 38;
            font = new Font("lucida bright regular", Font.PLAIN, 14);
            nf = NumberFormat.getInstance();
            nf.setMaximumFractionDigits(2);
            nf.setMinimumFractionDigits(2);
            setBackground(Color.white);
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setFont(font);
            FontRenderContext frc = g2.getFontRenderContext();
            int w = getWidth();
            int h = getHeight();
            double yInc = (h - 2*PAD)/10.0;
            // ordinate
            g2.draw(new Line2D.Double(PAD, PAD, PAD, h - PAD));
            // tick marks
            double x = PAD, y = h - PAD - yInc;
            for(int j = 0; j < 10; j++)
                g2.draw(new Line2D.Double(x - 2, y, x, y));
                y -= yInc;
            // labels
            y = h - PAD;
            float width, height, sx, sy;
            for(int j = 0; j <= 10; j++)
                String s = "$" + j;
                width = (float)font.getStringBounds(s, frc).getWidth();
                LineMetrics lm = font.getLineMetrics(s, frc);
                height = lm.getAscent() - lm.getDescent();
                sx = (float)(x - 4 - width);
                sy = (float)(y + height/2);
                g2.drawString(s, sx, sy);
                y -= yInc;
            // abcissa
            g2.draw(new Line2D.Double(PAD, h - PAD, w - PAD, h - PAD));
            // show value = 7
            double x1, x2, xInc = 40;
            double value = 7.00;
            String s = "$" + nf.format(value);
            width = (float)font.getStringBounds(s, frc).getWidth();
            LineMetrics lm = font.getLineMetrics(s, frc);
            height = lm.getAscent() - lm.getDescent();
            x1 = PAD + 3 * xInc;
            x2 = x1 + xInc;
            y = (h - PAD) - (value) * (h - 2*PAD)/10.0;
            g2.draw(new Line2D.Double(x1, y, x1, h - PAD));
            g2.draw(new Line2D.Double(x1, y, x2, y));
            g2.draw(new Line2D.Double(x2, y, x2, h - PAD));
            // label bar top
            sx = (float)(x2 - (xInc + width)/2);
            sy = (float)(y - 2);
            g2.drawString(s, sx, sy);
    }

  • A SAPinst GUI question - can't connect to port 21212

    Hello,
    I'm trying to install a BW 3.0B system 'BSB' using Linux/Oracle on 32-bit Intel hardware.  The Linux is Suse Linux Enterprise Server 9 (SLES9).  The Oracle is 9.2. 
    I was able to see the 1st SAP Installation GUI screen.  The two fields on the screen appeared as follows:
      Installation Host: <i>localhost</i>
      Port: <i>21212</i>
    <u>But when I clicked the 'OK' button, nothing happened.  The screen and the two fields remained the same.</u>  The messages from the UNIX install session, on two attempts using root id, are attached.  There is nothing in the <i>sapinst.log</i> file in the install directory <i>/INSTBW30B/CI</i>.  My Linux Administrator thought  the SAPinst listener is not working.
    The SAPinst I used is version 1.0, from a SAP BW 3.0B Installation CD, published in 2002.
    Please advise.  Thanks.
    Regards,
    Jack Wu
    lsapd002 /home/bsbadm> su -
    Password:
    lsapd002:~ # umask
    0022
    lsapd002:~ # export DISPLAY=10.101.62.19:0.0
    lsapd002:~ # export JAVA_HOME=/INSTBW30B/JAVA/j2sdk1.4.2_09
    lsapd002:~ # export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
    lsapd002:~ # export LD_LIBRARY_PATH=/sapmnt/BSB/exe
    lsapd002:~ # export LD_ASSUME_KERNEL=2.4.1
    lsapd002:~ # export SAPINST_DIR=/INSTBW30B/CI
    lsapd002:~ #
    lsapd002:~ # cd /INSTBW30B/CI
    lsapd002:/INSTBW30B/CI #
    lsapd002:/INSTBW30B/CI # <b>./startinstgui.sh</b>
    Log file: /INSTBW30B/CI/instgui.log
    2005.10.19 08:45:15: JVM version is '1.4.2_09' (1.4)
    2005.10.19 08:45:15: InstGui started.
    Setting javax.swing.plaf.metal.MetalLookAndFeel at com.sap.ins.gui.Main.setPLAF(Main.java:311)
    2005.10.19 08:45:16: SAPinst GUI Version:  2002/03/13   //bc/dev/src/ins/SAPINST/impl/src/gui/src/com/sap/ins/gui
    addXMLListener for sapinstgui at com.sap.ins.gui.xml.XMLParser.addXMLListener(XMLParser.java:28)
    addXMLListener for sapinstlog at com.sap.ins.gui.xml.XMLParser.addXMLListener(XMLParser.java:28)
    addXMLListener for sapinstfile at com.sap.ins.gui.xml.XMLParser.addXMLListener(XMLParser.java:28)
    addXMLListener for sapinstalert at com.sap.ins.gui.xml.XMLParser.addXMLListener(XMLParser.java:28)
    addXMLListener for sapinstguilogon at com.sap.ins.gui.xml.XMLParser.addXMLListener(XMLParser.java:28)
    Using In-Q-My XML parser at com.sap.ins.gui.xml.XMLParser.setParser(XMLParser.java:317)
    Connecting to localhost:21212 at com.sap.ins.gui.network.Thread.connect(Thread.java:91)
    Not connected. at com.sap.ins.gui.network.Thread.connect(Thread.java:101)
    Connecting to localhost:21212 at com.sap.ins.gui.network.Thread.connect(Thread.java:91)
    Not connected. at com.sap.ins.gui.network.Thread.connect(Thread.java:101)
    Connecting to localhost:21212 at com.sap.ins.gui.network.Thread.connect(Thread.java:91)
    Not connected. at com.sap.ins.gui.network.Thread.connect(Thread.java:101)
    Connecting to lsapd002:21212 at com.sap.ins.gui.network.Thread.connect(Thread.java:91)
    Not connected. at com.sap.ins.gui.network.Thread.connect(Thread.java:101)
    lsapd002:/INSTBW30B/CI #
    lsapd002:/INSTBW30B/CI # <b>telnet lsapd002 21212</b>
    Trying 10.48.110.58...
    telnet: connect to address 10.48.110.58: Connection refused
    lsapd002:/INSTBW30B/CI #
    lsapd002:/INSTBW30B/CI # <b>./startinstgui.sh -port 21212</b>
    Log file: /INSTBW30B/CI/instgui.log
    2005.10.19 09:41:16: JVM version is '1.4.2_09' (1.4)
    2005.10.19 09:41:16: InstGui started.
    Setting javax.swing.plaf.metal.MetalLookAndFeel at com.sap.ins.gui.Main.setPLAF(Main.java:311)
    2005.10.19 09:41:16: SAPinst GUI Version:  2002/03/13   //bc/dev/src/ins/SAPINST/impl/src/gui/src/com/sap/ins/gui
    addXMLListener for sapinstgui at com.sap.ins.gui.xml.XMLParser.addXMLListener(XMLParser.java:28)
    addXMLListener for sapinstlog at com.sap.ins.gui.xml.XMLParser.addXMLListener(XMLParser.java:28)
    addXMLListener for sapinstfile at com.sap.ins.gui.xml.XMLParser.addXMLListener(XMLParser.java:28)
    addXMLListener for sapinstalert at com.sap.ins.gui.xml.XMLParser.addXMLListener(XMLParser.java:28)
    addXMLListener for sapinstguilogon at com.sap.ins.gui.xml.XMLParser.addXMLListener(XMLParser.java:28)
    Using In-Q-My XML parser at com.sap.ins.gui.xml.XMLParser.setParser(XMLParser.java:317)
    Connecting to localhost:21212 at com.sap.ins.gui.network.Thread.connect(Thread.java:91)
    Not connected. at com.sap.ins.gui.network.Thread.connect(Thread.java:101)
    Connecting to localhost:21212 at com.sap.ins.gui.network.Thread.connect(Thread.java:91)
    Not connected. at com.sap.ins.gui.network.Thread.connect(Thread.java:101)

    Hello Daniel,
    Thanks for the quick reply.  The following are the whole story:
    1. When I started, I followed the SAP "<i>BW 3.0B Installation Guide on UNIX/Oracle</i>" and SAP note 580772.  After getting the error message "Floating point exception", I added the missing environment variable <b>LD_ASSUME_KERNEL=2.4.1</b> according SAP note 797084.
    2. Then I tried again:
    lsapd002:/INSTBW30B/CI <b># /sapcd/KERBW30B/SAPINST/UNIX/LINUX_32/INSTALL</b>
    This time I got different error messages:
    ERROR      2005-10-18 10:50:23 [syuxcnodut.cpp:589]
               CSyNodeUtils::isExistingWithType(iastring, bool, ISyNode::eNodeType)
    <u>FSL-02013  Unable to access file /INSTBW30B/CI/keydb.1.xml: Success.</u>
    ERROR      2005-10-18 10:50:24 [iaxxcsihlp.hpp:344]
               main()
    <u>FCO-00034  An error occurred during the installation. Problem: caught an unexpected exception.</u>
    The error message FSL-02013 is confusing.  Was it successful or not?  It appears not.  There is a keydb.xml in the installation directory /INSTBW30B/CI.  But for unknown reason, <b>sapinst</b> couldn't copy it to create keydb.1.xml.  Also, I'm not sure whether FSL-02013 caused FCO-00034, or the two messages are not related?
    3. I looked into the "<i>SAPinst Troubleshooting Guide v 1.20 5/27/2002</i>", found a symptom on p.11, followed the solution part 1:
    lsapd002:/INSTBW30B/CI <b># ./sapinst SAPINST_NO_GUISTART=true</b>
    I got the same error messages as in Step 2.
    4. I tried to fool the installer by doing manually:
    lsapd002:/INSTBW30B/CI <b># cp -p keydb.xml keydb.1.xml</b>
    5. Then tried the installation again
    lsapd002:/INSTBW30B/CI <b># ./sapinst</b>
    I got similar, but not identical error messages
    ERROR      2005-10-18 16:38:18 [syuxcnodut.cpp:589]
               CSyNodeUtils::isExistingWithType(iastring, bool, ISyNode::eNodeType)
    FSL-02013  Unable to access file /INSTBW30B/CI/keydb.<b>2</b>.xml: Success.
    ERROR      2005-10-18 16:38:18 [iaxxcsihlp.hpp:344]
               main()
    FCO-00034  An error occurred during the installation. Problem: caught an unexpected exception.
    <u>Please notice that the FSL-02013 complains about keydb.<b>2</b>.xml this time.</u>
    6. Then I gave up on solution part 1 in the "SAPinst <i>Troubleshooting Guide</i>" and continued with solution part 2, which is to run the shell script <b>startinstgui.sh</b>.  After having difficulty with port 21212, I posted the question in the SDN Forum on 10/19/2005.
    According to your reply, <b>startinstgui.sh</b> is just running the GUI which isn't really the installation.  So I still need to resolve the errors with <b>sapinst</b>, i.e. FSL-02013 and FCO-00034.  Any suggestion?
    Regards,
    Jack Wu

  • Music for short film question...

    So I'm editing my first, and bad, short film. I'm wondering what's the best way to go about music, obtaining and dropping music tracks in? How does one go about putting, lets say, Mozart under some video? Thanks, I know this is a noob question but I'm still getting used to it!

    I keep a folder on my hard drive that is just filled with music of different types that I import from music CDs: classics, rock, pop, etc. It all comes in handy for background music in one kind of video or another, and gives me lots of choices and raw material. In fact, as Hollywood knows, the background music can make or break the video. Can you imagine all the tear-jerker scenes in the Titanic without the theme music, or the Ken Burns special on the Civil War without that special theme song he used? It's the music that sets the mood.
    Like the other guys said, use some program such as iTunes, SoundStudio, or QuickTime Player Pro to convert whatever comes off your music CDs into AIFF form (although I've found FCE will try to work with just about any kind of audio file, and usually can), and then just drag and drop the music file's icon into your Final Cut Express browser (remembering that what gets dropped into FCE is only a pointer back to the original audio file). Once it's in the Browser, you can double-click it into the Viewer, and there in the Viewer window listen to it and set IN and OUT points (with the I and O keys on the keyboard) to make the length of the audio clip approximately match the length of the video clip you want to put it under, and also to choose the most appropriate part of the music or song to fit the video. You can always override these IN and OUT points on the timeline, of course, just by dragging the edges of the audio clip left or right to make it longer or shorter, or slipping it around with FCE's tools, but setting the IN and OUT points in the viewer like that before you drag the audio clip down to the audio tracks from the Browser gives you a rough starting point. If you just drag the entire audio file down onto the timeline immediately, without such adjustments, you can get an awful long audio clip stretched way down your Timeline (and it might also accidentally run over, and move, or obliterate, some other clips on that audio track way downstream). Then you must whittle that overly long audio clip down with the razor blade or other editing tool to match the video clip above it, although I did it that way before learning that it's better to do it in the Viewer window.
    Once the audio clip is in the timeline, use the pen tool on the red audio volume line running down the length of it, to adjust overall volume, and to raise and lower the volume at specific points in the video clip, and to fade it in and out at the beginning, end, and elsewhere as needed. To do this, just click on the red line with the pen tool to establish control points (keyframes) so you can pull the volume line up and down. Setting the audio clips to show the waveforms of the music while you do this can help with the precision of these adjustments.
    Yeah, music is so important to the mood of a video that I'm amazed so many people neglect it, or choose the wrong music (see YouTube for just how bad it can get). Some time spent experimenting to get the right music, and the most effective use of it, really pays off. I've had tears running down peoples' eyes (OK, my own too sometimes) watching some of my sentimental family videos with the right music behind it.
    Same goes for comedy: check out this video comedy I created in FCE and uploaded to YouTube, and see how the music absolutely makes the main scene, and how you can match the beat of the music to the action in the video. It takes time, sliding the video clips around to match the beat, but it pays off--I've seen people fall out of their chairs laughing while watching this one: <http://tinyurl.com/6xdymg>

  • Another GUI question..

    Hi, I just want to know the most appropriate way of making a Gui update itself. For instance my GUI contains data that should change as I hit buttons though the data will not change unless I close the window then open the window again.. what is the "auto-update" command beyond using setVisible(false) then setVisible(true) everytime I change data in the window.
    Cheers.

    Phantasm235,
    Well without knowing the full scope of your project, and the code you are trying to do this with I cannot provide you an helpful examples. However there are several Online tutorials right here on Sun's website:
    This is the best I could find on short notices, but I know there are more, this one well explain Event Handling which is what I was talking about, and also teach you how to write your own events:
    http://web2.java.sun.com/docs/books/tutorial/uiswing/events/index.html
    The links below are to the main tutorial sites showing all they have to offer, you may want to look through them if the above did not help:
    http://developer.java.sun.com/developer/onlineTraining/
    http://web2.java.sun.com/docs/books/tutorial/
    I hope these can help,
    -Rodney

  • First gui question

    hello all
    I use netbeans6.9 ,under windows xp , i try to create simple gui application,
    File-->new Project-->Categories -->Java-->Projects--> Java Application
    Next
    Project Name :HelloWorldGui
    Finish
    File-->new File-->Categories --->Swing GUI Forms--->File Types--->JFrame Form
    ClassName:JFrame1
    on the jFrame1 ,i place jButton1 and jTextField1
    double clicking jButton1 i get
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here
    I replace the word // TODO add your handling code here with jTextField1.setText("HelloWorld");
    so i get
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    jTextField1.setText("HelloWorld");
    I try to run by press F6 but nothing happen
    what i have done wrong ?
    tq ia
    denny

    //here is my code
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * jFrame1.java
    * Created on Aug 22, 2010, 9:06:41 AM
    package helloworlgui;
    * @author han
    public class jFrame1 extends javax.swing.JFrame {
    /** Creates new form jFrame1 */
    public jFrame1() {
    initComponents();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
    jButton1 = new javax.swing.JButton();
    jTextField1 = new javax.swing.JTextField();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jButton1.setText("jButton1");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    jTextField1.setText("jTextField1");
    jTextField1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jTextField1ActionPerformed(evt);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(37, 37, 37)
    .addComponent(jButton1)
    .addGap(51, 51, 51)
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(58, Short.MAX_VALUE))
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(48, 48, 48)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jButton1)
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(62, Short.MAX_VALUE))
    pack();
    }// </editor-fold>
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    jTextField1.setText("HelloWorld");
    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new jFrame1().setVisible(true);
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration
    tq
    denny

  • Reversi GUI question, A LOT of code in here!

    okay, so I've been working on his code for a long time. A REAL long time, working on it bit by bit, and all I got left is the Reversi's GUI. Basically I want to use the Jbutton and have x represent black and o represent white. I'm getting stuck on how to go about it. Any ideas?
    Here's alllll the code.
    package com.Ozo.games.reversi;
    * This utility class provides a number of static constants and
    * methods that provide abstractions for player colors and moves.
    * Colors and moves could be implemented as objects of separate
    * classes, but instead we represent them as integers and provide
    * the abstraction via these operations.
    public class Reversi {
         public static final int Black = 1;
         public static final int White = 2;
         public static final int Empty = 0;
          * Gives the color of a player's opponent.
          * @param color of this player.
          * @return color of the opponent.
         public static int playerOpposite(int color) {
              if (color == Black) return White;
              if (color == White) return Black;
              throw new Error("Player must be Black or White");
          * Compare two scores and determine whether the first is better than the second.
          * Better for black means more positive.  Better for white means more negative.
          * @param colorAsking
          * @param score1
          * @param score2
          * @return whether score1 is better than score2, as far as colorAsking is concerned.
         public static boolean isBetterScore(int colorAsking, int score1, int score2) {
              if (colorAsking == Black) return score1 > score2;
              if (colorAsking == White) return score1 < score2;
              throw new Error("Player must be Black or White");
          * Encode a move from this position as an integer.
          * A "pass" move is recorded as (-1,-1).
          * @param pos the board this move is for.
          * @param row the row at which the piece is placed.
          * @param col the column at which the piece is placed.
          * @return encoded move.
         public static int newMove(ReversiPosition pos, int row, int col) {
              return row * pos.ncols() + col;
          * A "pass" move.  I.e. no piece is placed.
         public static int newMovePass(ReversiPosition pos) {
              return newMove(pos, -1, -1);
          * Find the row of an encoded move.
          * @param pos the board this move is for.
          * @param move
          * @return the row.
         public static int moveRow(ReversiPosition pos, int move) {
              return move / pos.ncols();
          * Find the column of an encoded move.
          * @param pos the board this move is for.
          * @param move
          * @return the column.
         public static int moveCol(ReversiPosition pos, int move) {
              return move % pos.ncols();
    package com.Ozo.games.reversi;
    * Top-level driver for a Reversi game.
    public class ReversiGame {
         private ReversiPosition   _pos;
         private int               _toMoveColor;
         private ReversiTextIO     _userInterface;
         public ReversiGame(int nrows, int ncols) {
              _pos           = new ReversiPosition(nrows, ncols);
              _toMoveColor   = Reversi.Black;
              _userInterface = null;
              ReversiRules.setStartingPosition(_pos);
         public void setUserInterface(ReversiTextIO ui) {
              _userInterface = ui;
         public ReversiPosition currentPosition() { return _pos; }
         public int             toMoveColor()     { return _toMoveColor; }
         public void getHumanMoveAndApplyIt() {
              if (ReversiRules.countLegalMoves(_pos, _toMoveColor) != 0) {
                   int move = _userInterface.getMove(_pos, _toMoveColor);
                   _pos.applyMove(move, _toMoveColor);
              else
                   _userInterface.message("You have no move.  I get another turn.");
              _toMoveColor = Reversi.playerOpposite(_toMoveColor);
         public void getComputerMoveAndApplyIt() {
              if (ReversiRules.countLegalMoves(_pos, _toMoveColor) != 0) {
                   int move = ReversiStrategy.findBestMove(_pos, _toMoveColor);
                   _pos.applyMove(move, _toMoveColor);
              else
                   _userInterface.message("I have no move.  You get another turn.");
              _toMoveColor = Reversi.playerOpposite(_toMoveColor);
         public void play() {
              _userInterface.output(_pos);
              for (;;) {
                   if (ReversiRules.isGameOver(_pos, _toMoveColor)) { gameOverMessage(); break; }
                   getHumanMoveAndApplyIt();
                   _userInterface.output(_pos);
                   if (ReversiRules.isGameOver(_pos, _toMoveColor)) { gameOverMessage(); break; }
                   getComputerMoveAndApplyIt();
                   _userInterface.output(_pos);
         public void gameOverMessage() {
              _userInterface.message("Game over...");
              int winner = ReversiRules.winningColor(_pos, _toMoveColor);
              if      (winner == Reversi.Black) _userInterface.message("Black wins.");
              else if (winner == Reversi.White) _userInterface.message("White wins.");
              else    _userInterface.message("Draw.");
    package com.Ozo.games.reversi;
    * The main class to start a Reversi game as an application.
    public class ReversiMain {
         public static void main(String[] args) {
              ReversiGame   game = new ReversiGame(8, 8);
              ReversiTextIO tui  = new ReversiTextIO(System.in, System.out);
              game.setUserInterface(tui);
              game.play();
    }

    package com.Ozo.games.reversi;
    * This class provides all of the intelligence for a program to play Reversi.
    * It contains all the knowledge of play strategy.  (The knowledge of the rules
    * is maintained by the ReversiRules class.)
    * The principal method is findBestMove, which does an exhaustive search a number
    * of plys deep, and then applies a hueristic position evaluation function.
    public class ReversiStrategy {
         private static int PlysToTry = 6;
          * Find the best move for the player of the given color.
          * If there is no move, then return "pass".
          * @param pos the position to be evaluated.
          * @param toMoveColor the color of player to move.
          * @param plysRemaining the depth to examine (must be >= 1).
          * @return the best move within the default horizon.
         public static int findBestMove(ReversiPosition pos, int toMoveColor) {
              return findBestMove(pos, toMoveColor, PlysToTry).move;
          * This class is used to return a pair of values:  the best move and the score it achieves
          * after the number of plys remaining are played.
         public static class BestMove {
              public int move;
              public int score;
              public BestMove(int m, int s) { move = m; score = s; }
          * Find the best move for the player of the given color within
          * the given number of plys.
          * @param pos the position to be evaluated.
          * @param toMoveColor the color of player to move.
          * @param plysRemaining the depth to examine (must be >= 1).
          * @return a BestMove object returning the best move found and the score it achieves.
         public static BestMove findBestMove(ReversiPosition pos, int toMoveColor, int plysRemaining) {
              if (plysRemaining < 1) throw new Error("findBestMove needs plysRemaining >= 1");
              // Generate the legal moves.  If there are none, then pass.
              int opponentColor = Reversi.playerOpposite(toMoveColor);
              int[] moves = ReversiRules.generateMoves(pos, toMoveColor);
              if (moves.length == 0) {
                   if (plysRemaining == 1)
                        return new BestMove(Reversi.newMovePass(pos), summaryScore(pos));
                   else
                        return findBestMove(pos, opponentColor, plysRemaining-1);
              // Try all the moves.  Re-use one position object to make the move.
              ReversiPosition afterMove = pos.copy();
              // Start with a hypothetical worst scenario and then look for what's better.
              afterMove.fill(opponentColor);
              int bestScore = 2*summaryScore(afterMove);  // Worse that the worst possible real score.
              int bestIndex = -1;
              for (int i = 0; i < moves.length; i++) {
                   pos.copyInto(afterMove);      // Re-use the position object.
                   afterMove.applyMove(moves, toMoveColor);
                   int thisScore = (plysRemaining == 1) ?
                        summaryScore(afterMove) :
                        findBestMove(afterMove, opponentColor, plysRemaining - 1).score;
                   if (Reversi.isBetterScore(toMoveColor, thisScore, bestScore)) {
                        bestScore = thisScore;
                        bestIndex = i;
              if (bestIndex == -1) System.out.println("Number of moves " + moves.length + " plys " + plysRemaining);
              return new BestMove(moves[bestIndex], bestScore);
         * Examine contents of square and return 1 for Black, -1 for White, 0 for Empty.
         * Useful in computing scores.
         * @param r row number.
         * @param c column number.
         * @return +1/-1/0
         private static int squareVal(ReversiPosition pos, int r, int c) {
              if (pos.getSquare(r, c) == Reversi.White) return -1;
              if (pos.getSquare(r, c) == Reversi.Black) return +1;
              return 0;
         * Count the number of black squares minus the number of white squares.
         * @return difference in number of black and white squares.
         public static int squareScore(ReversiPosition pos) {
              int nBminusW = 0;
              for (int r = 0; r < pos.nrows(); r++)
                   for (int c = 0; c < pos.ncols(); c++)
                        nBminusW += squareVal(pos, r, c);
              return nBminusW;
         * Count the number of black edge squares minus the number of white ones.
         * @return difference in number of black and white squares.
         public static int edgeScore(ReversiPosition pos) {
              int nBminusW = 0;
              // East and west edges.
              for (int r = 1; r < pos.nrows()-1; r++)
                   nBminusW += squareVal(pos, r, 0) + squareVal(pos, r, pos.ncols()-1);
              // North and south edges.
              for (int c = 1; c < pos.ncols()-1; c++)
                   nBminusW += squareVal(pos, 0, c) + squareVal(pos, pos.nrows()-1, c);
              return nBminusW;
         * Count the number of black corner squares minus the number of white ones.
         * @return difference in number of black and white squares.
         public static int cornerScore(ReversiPosition pos) {
              int rlast = pos.nrows()-1, clast = pos.ncols()-1;
              return squareVal(pos, 0, 0) + squareVal(pos, 0, clast) +
              squareVal(pos, rlast, 0) + squareVal(pos, rlast, clast);
         * Compute a heuristic score for a given position. The more positive,
         * the better for Black. Controlling corners is weighted most heavily,
         * folowed by sides, then regular squares. In principle a different weight
         * function should be used at the end of the game, since then it is really
         * the total number of squares that counts.
         * @param pos the position to be assessed.
         * @return the numerical score, with positive being good for Black, negative good for White.
         public static int summaryScore(ReversiPosition pos) {
                   return squareScore(pos) + 8*edgeScore(pos) + 20*cornerScore(pos);
    }Edited by: Oozaro on Nov 19, 2009 12:41 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • A GUI Question

    How do I put in a button for each day of the calender (done in this code):
    for (int i=1; i<=nod; i++)
    int row = new Integer((i+som-2)/7);
         int column = (i+som-2)%7;
         mtblCalendar.setValueAt(i, row, column);
    I want a screen that I have coded to  pop-up which has tasks for the day. This is the Window I want for to pop-up when I click the button:
    package Calender;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MainWindow extends JFrame
         JMenuBar menubar;
         JMenu m1, m2, m3, m4;
         JMenuItem add1, remove, display, about;
         public MainWindow()
              setLayout(new FlowLayout());
              menubar = new JMenuBar();
              add(menubar);
              m1 = new JMenu("Add a task..");
              m2 = new JMenu("Remove a task..");
              m3 = new JMenu("Display tasks..");
              m4 = new JMenu("About..");
              menubar.add(m1);
              menubar.add(m2);
              menubar.add(m3);
              menubar.add(m4);
              add1 = new JMenuItem("add");
              m1.add(add1);
              remove = new JMenuItem("remove");
              m2.add(remove);
              display = new JMenuItem("display");
              m3.add(display);
              about = new JMenuItem("about");
              m4.add(about);
              setJMenuBar(menubar);
              EventA e = new EventA();
              add1.addActionListener(e);
              EventRem i = new EventRem();
              remove.addActionListener(i);
              EventDis a = new EventDis();
              display.addActionListener(a);
              EventAb b = new EventAb();
              about.addActionListener(b);
         public class EventA implements ActionListener
              public void actionPerformed(ActionEvent e)
                   AddWindow gui = new AddWindow(MainWindow.this);
                   gui.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                   gui.setSize(500,100);
                   gui.setLocation(300,300);
                   gui.setTitle("Add a task...");
                   gui.setVisible(true);
         public class EventAb implements ActionListener
              public void actionPerformed(ActionEvent e)
                   AboutWindow gui = new AboutWindow(MainWindow.this);
                   gui.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                   gui.setSize(500,100);
                   gui.setLocation(300,300);
                   gui.setTitle("About..");
                   gui.setVisible(true);
         public class EventRem implements ActionListener
              public void actionPerformed(ActionEvent e)
                   RemoveWindow gui = new RemoveWindow(MainWindow.this);
                   gui.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                   gui.setSize(500,100);
                   gui.setLocation(300,300);
                   gui.setTitle("Remove a task...");
                   gui.setVisible(true);
         public class EventDis implements ActionListener
              public void actionPerformed(ActionEvent e)
                   DisplayWindow gui = new DisplayWindow(MainWindow.this);
                   gui.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                   gui.setSize(500,100);
                   gui.setLocation(300,300);
                   gui.setTitle("Display tasks...");
                   gui.setVisible(true);
         public static void main(String[] args)
              MainWindow gui = new MainWindow();
              gui.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
              gui.setSize(500, 100);
              gui.setVisible(true);
              gui.setTitle("Main Window");
    Here is my entire calendar class:
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class Calendar
         static JLabel lblMonth, lblYear;
         static JButton btnPrev, btnNext;
         static JTable tblCalendar;
         static JComboBox cmbYear;
         static JFrame frmMain;
         static Container pane;
         static DefaultTableModel mtblCalendar; //Table model
         static JScrollPane stblCalendar; //The scroll plane
         static JPanel pnlCalendar;
         static int realYear, realMonth, realDay, currentYear, currentMonth;
         * Changes days, months, years, etc
         public static void refreshCalendar(int month, int year)
              String[] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
              int nod, som; //Number Of Days, Start Of Month
              //Allow/disallow buttons
              btnPrev.setEnabled(true);
              btnNext.setEnabled(true);
              if (month == 0 && year <= realYear-1){btnPrev.setEnabled(false);} //Too early
              if (month == 11 && year >= realYear+5){btnNext.setEnabled(false);} //Too late
              lblMonth.setText(months[month]); //Refresh the month label (at the top)
              lblMonth.setBounds(160-lblMonth.getPreferredSize().width/2, 25, 180, 25); //Re-align label with calendar
              cmbYear.setSelectedItem(String.valueOf(year)); //Select the correct year in the combo box
              //ImageIcon middleButtonIcon = createImageIcon("images/middle.gif");
              //Clears table
              for (int i=0; i<6; i++)
                   for (int j=0; j<7; j++)
                        mtblCalendar.setValueAt(null, i, j);
              //Get first day of month and number of days
              GregorianCalendar cal = new GregorianCalendar(year, month, 1);
              nod = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
              som = cal.get(GregorianCalendar.DAY_OF_WEEK);
              //Draw calendar
              for (int i=1; i<=nod; i++)
                   int row = new Integer((i+som-2)/7);
                   int column = (i+som-2)%7;
                   mtblCalendar.setValueAt(i, row, column);
              tblCalendar.setDefaultRenderer(tblCalendar.getColumnClass(0), new tblCalendarRenderer());
         static class tblCalendarRenderer extends DefaultTableCellRenderer
              public Component getTableCellRendererComponent (JTable table, Object value, boolean selected, boolean focused, int row, int column)
                   super.getTableCellRendererComponent(table, value, selected, focused, row, column);
                   if (column == 0 || column == 6) //Week-end
                        setBackground(new Color(255, 220, 220));
                   else //Week
                        setBackground(new Color(255, 255, 255));
                   if (value != null)
                        if (Integer.parseInt(value.toString()) == realDay && currentMonth == realMonth && currentYear == realYear) //Today
                             setBackground(new Color(220, 220, 255));
                   setBorder(null);
                   setForeground(Color.black);
                   return this;
         static class GoBackAction implements ActionListener
              public void actionPerformed (ActionEvent e)
                   if (currentMonth == 0) //Back one year
                        currentMonth = 11;
                        currentYear -= 1;
                   else //Back one month
                        currentMonth -= 1;
                   refreshCalendar(currentMonth, currentYear);
         static class GoNextAction implements ActionListener
              public void actionPerformed (ActionEvent e){
                   if (currentMonth == 11){ //Foward one year
                        currentMonth = 0;
                        currentYear += 1;
                   else{ //Foward one month
                        currentMonth += 1;
                   refreshCalendar(currentMonth, currentYear);
         static class cmbYearAction implements ActionListener
              public void actionPerformed (ActionEvent e)
                   if (cmbYear.getSelectedItem() != null)
                        String b = cmbYear.getSelectedItem().toString();
                        currentYear = Integer.parseInt(b);
                        refreshCalendar(currentMonth, currentYear);
         public static void main (String args[])
              try {UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}
              catch (ClassNotFoundException e) {}
              catch (InstantiationException e) {}
              catch (IllegalAccessException e) {}
              catch (UnsupportedLookAndFeelException e) {}
              //makes the frame for the console
              frmMain = new JFrame ("APCS Calender"); //Create frame
              frmMain.setSize(330, 375); //Set size to 400x400 pixels
              pane = frmMain.getContentPane(); //Get content pane
              pane.setLayout(null); //Apply null layout
              frmMain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Close when X is clicked
              //Creates the controls for the screan
              lblMonth = new JLabel ("January");
              lblYear = new JLabel ("Change year:");
              cmbYear = new JComboBox();
              btnPrev = new JButton ("<<");
              btnNext = new JButton (">>");
              mtblCalendar = new DefaultTableModel(){public boolean isCellEditable(int rowIndex, int mColIndex){return false;}};
              tblCalendar = new JTable(mtblCalendar);
              stblCalendar = new JScrollPane(tblCalendar);
              pnlCalendar = new JPanel(null);
              //Sets the border for the screen
              pnlCalendar.setBorder(BorderFactory.createTitledBorder("Calendar"));
              btnPrev.addActionListener(new GoBackAction());
              btnNext.addActionListener(new GoNextAction());
              cmbYear.addActionListener(new cmbYearAction());
              //Add controls to screen
              pane.add(pnlCalendar);
              pnlCalendar.add(lblMonth);
              pnlCalendar.add(lblYear);
              pnlCalendar.add(cmbYear);
              pnlCalendar.add(btnPrev);
              pnlCalendar.add(btnNext);
              pnlCalendar.add(stblCalendar);
              //Set boundaries for day, month, year
              pnlCalendar.setBounds(0, 0, 320, 335);
              lblMonth.setBounds(160-lblMonth.getPreferredSize().width/2, 25, 100, 25);
              lblYear.setBounds(10, 305, 80, 20);
              cmbYear.setBounds(230, 305, 80, 20);
              btnPrev.setBounds(10, 25, 50, 25);
              btnNext.setBounds(260, 25, 50, 25);
              stblCalendar.setBounds(10, 50, 300, 250);
              //Make frame visible
              frmMain.setResizable(false);
              frmMain.setVisible(true);
              //Gets the real month, year and day
              GregorianCalendar cal = new GregorianCalendar(); //Create calendar
              realDay = cal.get(GregorianCalendar.DAY_OF_MONTH); //Get day
              realMonth = cal.get(GregorianCalendar.MONTH); //Get month
              realYear = cal.get(GregorianCalendar.YEAR); //Get year
              currentMonth = realMonth; //Match month and year
              currentYear = realYear;
              //Add headers to screen
              String[] headers = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; //All headers
              for (int i=0; i<7; i++){
                   mtblCalendar.addColumn(headers);
              tblCalendar.getParent().setBackground(tblCalendar.getBackground()); //Set background
              //Makes it so that you can't resize or reorder
              tblCalendar.getTableHeader().setResizingAllowed(false);
              tblCalendar.getTableHeader().setReorderingAllowed(false);
              tblCalendar.setColumnSelectionAllowed(true);
              tblCalendar.setRowSelectionAllowed(true);
              tblCalendar.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
              //Set row and column count
              tblCalendar.setRowHeight(38);
              mtblCalendar.setColumnCount(7);
              mtblCalendar.setRowCount(6);
              //puts values in the table
              for (int i=realYear-1; i<=realYear+5; i++)
                   cmbYear.addItem(String.valueOf(i));
              //Refresh calendar
              refreshCalendar (realMonth, realYear); //Refresh calendar

    Moderator action: Moved from Java Programming.
    Moderator advice: Please read the announcement(s) at the top of the forum listings and the FAQ linked from every page. They are there for a purpose.
    Then edit your post and format the code correctly.
    db

  • Labels on GUI question

    Hi, I want to put labels on a GUI that basically continually shows values of various parameters which change regularly. What would be the best way of doing this? I was thinking of just using a thread and putting a loop that continually gets the value of the parameter until the program stops, but how do you actually change what is printed on the label?
    Thanks!

    Hmmm... setText is one thing, but what's this about spinning off a thread to poll parameter values?
    If you want to decouple the code that changes the parameter values from the code
    that notices those values have changed and reacts by changing label text, then
    Grasshopper, I think you should be aware of the Observer Pattern:
    http://sern.ucalgary.ca/courses/SENG/609.04/W98/lamsh/observerLib.html
    http://www.wohnklo.de/patterns/observer.html
    http://c2.com/cgi/wiki?ObserverPattern
    http://www.javaworld.com/javaworld/javaqa/2001-05/04-qa-0525-observer.html
    http://www.research.ibm.com/designpatterns/example.htm

  • Very Basic GUI Question

    Can anyone tell me why this GUI won't display at all? Thanks
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;  //For colors
    import java.awt.event.*;
    public class Baseball extends JFrame {
    public Baseball(){
        setTitle("Baseball!");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        JPanel panel = new JPanel();
       getContentPane().add(panel,BorderLayout.CENTER);
       panel.setBackground(Color.BLUE);
        setSize(400, 400);
        pack();
        setVisible(true);
         * @param args the command line arguments
        public static void main(String[] args) {
            // TODO code application logic here
           java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Baseball();
    }I have no idea what this means: java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() Edited by: Champachikla on Feb 7, 2010 2:01 AM

    Dan_Koldyr wrote:
    1. avoid pack();/setVisible(true); directly in frame constructor But do not neglect to call pack() at some stage before setVisible(true).
    2. invokeLater in main method makes no sense.It does in rare circumstances. (E.G. one visible app. calling the main of another app.)
    So i would suggest modify your code like following
    public Baseball(){
    setSize(400, 400);
    No. The previous poster got it right when talking about setting the preferred size. After pack(), your GUI will be shrunk as well.

  • Netbeans 5.0 GUI question

    Hey guys!
    im a newbie JSF coder and well im in my work term and one of my projects is to develop a Web application(using JSF) to replicate a VB program that my company has but on the web.
    Im on teh front-end stage of the project and reading a JSF(core) book and well they mention a GUI Builder. Im using NetBeans IDE 5.0....is there something within this IDE that i can design a front-end as i would using Visual Basic? Tad annoying if there isn't and it'll take me quite a long itme to actually code something up without a graphical tool :(
    Cheers and many thanks,
    Dan

    Do you get this error when selecting "run" from within NetBeans?
    When I create a project using Netbeans 5.0 beta using the form designer NetBeans automatically adds swing-layout-0.7.jar to the list of libraries in the libraries node in the project window. I didn't do anything fancy.
    Do you get this error if you create another project?
    it works fine for me.

  • JPanel GUI question

    I am writing a program that updates a Jpanel on the gui when a button is clicked ( GUI or editGUI).
    The program currently loadsup to the GUI and switches to editGUI no problem at all, but won't switch back
    I think I've tracked down the problem to this section of code, what am I doing wrong??? (booleans checked not the problem)
    private void layoutCentre()
              if (editgui == false)
              remove(this.textcentre);
              String s = createDisplay();
              JtextArea.setText(s);     
              Jpanel.add(JTextArea);
              add(JPanel, BorderLayout.CENTER);
              Jpanel.revalidate();
              this.repaint();
              else
                   remove(this.textcentre);
                   JPanel=new EditGUI();
                   JPanel = egui.layoutEdit();
                   add(JPanel, BorderLayout.CENTER);
                   Jpanel.revalidate();
                   this.repaint();
         }

    airomega wrote:
    Thanks everyone, I'm a noob to the forums and to Java so sorry for lack of forum etiquette. No big deal. Your etiquette was fine.
    I sorted it by separating panel creation into two classes, and checking the boolean when calling the methods instead. Still that makes two of us now who have recommended that you look into CardLayout. If you haven't done so, I suggest you do this now.

Maybe you are looking for

  • Problem with Twitter for Mac notifications

    Hello, I have a strange problem with Twitter for Mac. On both my home and office Macs. New posts appear in app window but there aren't any notifications even though notifications are set in preferences to show in both dock and menubar. Perhaps anyone

  • Using cue points to acrivate movie clips

    I'm trying to write a simple piece of ActionScript that I can adapt and re-use easily. (I'm not very good at programming and I've been finding the "help" information very confusing.) I've devised quite an elegant solution, if only I could get it to w

  • Can't figure this out

    Hi, This probably has a simple explanation, but I just don't understand why this happens. Can someone explain me why number 1 is never printed? value = "[1][2][3][6]"; if( value.indexOf("[1]") > 0 ) {      System.out.println(1); if( value.indexOf("[2

  • Logos in Photoshop or Illustrator?

    A client wants me to create a logo for them using an image inside chunky text. They want an outline around the text. The first thing is that I'm having a hard time doing this in Photoshop (the outline part, that is). The second thing is that I'm wond

  • XMLDocumentSplitter

    When I try to compile the XMLDocumentSplitter I get an error message '...uses or overrides a deprecated API'. Is there trick in compiling it properly ? Thanks