Help in Swing

Hi
I am trying to create a demo field set with three textfields and three buttons a Up Arrow ,Down Arrow and Delete button. However my problem is that creation is fine... but clicking on the Up Arrow button should add one row above and the three textfields should be blank so as to enable the user to enter any input(string type)...upon clicking the down arrow button it should go to the current row where fields may have been entered or not...my question is that these values are never entered into JTable or so...rather they are stored in memory....Also delete button deletes the current row if values are there...
I am a newbie basic to Swing and have never worked with Field sets this kind which is kind like flipping over a calendar flipping over the textfield and adding values whatever the user is entering...
Can anyone help me in this please?
Thanks

Hi
there is a special Swing forum (different from this forum).
BB

Similar Messages

  • Help! swing problem

    i keep getting the error: boxlayout can't be shared...
    what's the problem?
    Part of My code:
    JPanel CatSubPanel = new JPanel() {
                public Dimension getMinimumSize() {
                    return getPreferredSize();
                public Dimension getPreferredSize() {
                    return new Dimension(400, super.getPreferredSize().height);
                public Dimension getMaximumSize() {
                    return getPreferredSize();
    CatSubPanel.setLayout(new BoxLayout(CatSubPanel, BoxLayout.X_AXIS));
    if (MULTICOLORED) {
                CatSubPanel.setOpaque(true);
                CatSubPanel.setBackground(new Color(0, 0, 255));
            CatSubPanel.setBorder(BorderFactory.createEmptyBorder(0,1,10,5));
          CatSubPanel.add(anotherNewPanel);

    help! swing problemI don't think so.
    I just mentioned there is a Swing forum for posting Swing related questions.
    I also gave you a link to a tutorial on How to Use Box Layout.

  • Help in swing app. tic tac toe

    Trying to make this tic tac toe game. Need a little help. I want the newGameBUT to start the game over, and I would like turnTF to display if a tie occurs. (I tried using *if button.enabled(false) {* but it didn't work. If anyone could help me out, that'd be great. Oh, also, the new game button currently add's 1 to whoever won so far, which is really weird =x. Thanks beforehand.
    import java.awt.*; //import
    import javax.swing.*; //import
    import java.awt.event.*; //import
    import java.awt.Rectangle; //import
    import java.awt.Font; //import
    import javax.swing.BorderFactory; //import
    import javax.swing.border.TitledBorder; //import
    import java.awt.Color; //import
    public class TicTacToeFrame extends JFrame implements ActionListener {
        public TicTacToeFrame() {
            try { //try the following
                jbInit();
            } catch (Exception ex) { // exit on [X]
                ex.printStackTrace(); //exit and print errors
        int xWon = 0; //counting how many times O has won
        int oWon = 0; //counting how many times X has one
        double i = 0; // loop variable to determine turn
        public void actionPerformed(ActionEvent e) {
            String turn = "null"; //current turn
            String notTurn = "null"; //not current turn
            newGameBUT.setEnabled(false); //disable new game button
            if (i % 2 == 0) { // for determining who's turn it is
                turn = "X"; // X's turn when counter is even
                notTurn = "O"; //notTurn used to show who's turn it is in turnTF
            if (i % 2 != 0) { // for determining who's turn it is
                turn = "O"; // O's turn when counter is odd
                notTurn = "X"; //notTurn used to show who's turn it is in turnTF
            turnTF.setText("Currently " + notTurn + "'s turn"); // displays turn
            if (e.getSource() == sqOneBUT) { //disable and print X or O to button
                sqOneBUT.setText(turn); //printing players symbol
                sqOneBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqTwoBUT) { //disable and print X or O to button
                sqTwoBUT.setText(turn); //printing players symbol
                sqTwoBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqThreeBUT) { //disable and print X or O to button
                sqThreeBUT.setText(turn); //printing players symbol
                sqThreeBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqFourBUT) { //disable and print X or O to button
                sqFourBUT.setText(turn); //printing players symbol
                sqFourBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqFiveBUT) { //disable and print X or O to button
                sqFiveBUT.setText(turn); //printing players symbol
                sqFiveBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqSixBUT) { //disable and print X or O to button
                sqSixBUT.setText(turn); //printing players symbol
                sqSixBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqSevenBUT) { //disable and print X or O to button
                sqSevenBUT.setText(turn); //printing players symbol
                sqSevenBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqEightBUT) { //disable and print X or O to button
                sqEightBUT.setText(turn); //printing players symbol
                sqEightBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqNineBUT) { //disable and print X or O to button
                sqNineBUT.setText(turn); //printing players symbol
                sqNineBUT.setEnabled(false); //disabling button
            String sqOne = sqOneBUT.getText(); // Strings to read to find winner
            String sqTwo = sqTwoBUT.getText(); // Strings to read to find winner
            String sqThree = sqThreeBUT.getText(); // Strings to read to find winner
            String sqFour = sqFourBUT.getText(); // Strings to read to find winner
            String sqFive = sqFiveBUT.getText(); // Strings to read to find winner
            String sqSix = sqSixBUT.getText(); // Strings to read to find winner
            String sqSeven = sqSevenBUT.getText(); // Strings to read to find winner
            String sqEight = sqEightBUT.getText(); // Strings to read to find winner
            String sqNine = sqNineBUT.getText(); // Strings to read to find winner
             OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~O WINS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
    //horizontal, top, o wins
            if (sqOne == "O") { //checking too see if player O has won
                if (sqFour == "O") {
                    if (sqSeven == "O") {
                        turnTF.setText("O wins!"); //O wins text
                        sqOneBUT.setEnabled(false); //disable all buttons
                        sqTwoBUT.setEnabled(false); //disable all buttons
                        sqThreeBUT.setEnabled(false); //disable all buttons
                        sqFourBUT.setEnabled(false); //disable all buttons
                        sqFiveBUT.setEnabled(false); //disable all buttons
                        sqSixBUT.setEnabled(false); //disable all buttons
                        sqSevenBUT.setEnabled(false); //disable all buttons
                        sqEightBUT.setEnabled(false); //disable all buttons
                        sqNineBUT.setEnabled(false); //disable all buttons
    //vertical, left, o wins
            if (sqOne == "O") { //checking too see if player O has won
                if (sqTwo == "O") {
                    if (sqThree == "O") {
                        turnTF.setText("O wins!"); //O wins text
                        sqOneBUT.setEnabled(false); //disable all buttons
                        sqTwoBUT.setEnabled(false); //disable all buttons
                        sqThreeBUT.setEnabled(false); //disable all buttons
                        sqFourBUT.setEnabled(false); //disable all buttons
                        sqFiveBUT.setEnabled(false); //disable all buttons
                        sqSixBUT.setEnabled(false); //disable all buttons
                        sqSevenBUT.setEnabled(false); //disable all buttons
                        sqEightBUT.setEnabled(false); //disable all buttons
                        sqNineBUT.setEnabled(false); //disable all buttons
    // diagonal, top left to bottom right, o wins
            if (sqOne == "O") {
                if (sqFive == "O") { //checking too see if player O has won
                    if (sqNine == "O") {
                        turnTF.setText("O wins!"); //O wins text
                        sqOneBUT.setEnabled(false); //disable all buttons
                        sqTwoBUT.setEnabled(false); //disable all buttons
                        sqThreeBUT.setEnabled(false); //disable all buttons
                        sqFourBUT.setEnabled(false); //disable all buttons
                        sqFiveBUT.setEnabled(false); //disable all buttons
                        sqSixBUT.setEnabled(false); //disable all buttons
                        sqSevenBUT.setEnabled(false); //disable all buttons
                        sqEightBUT.setEnabled(false); //disable all buttons
                        sqNineBUT.setEnabled(false); //disable all buttons
    // horizontal, mid, o wins
            if (sqTwo == "O") { //checking too see if player O has won
                if (sqFive == "O") {
                    if (sqEight == "O") {
                        turnTF.setText("O wins!"); //O wins text
                        sqOneBUT.setEnabled(false); //disable all buttons
                        sqTwoBUT.setEnabled(false); //disable all buttons
                        sqThreeBUT.setEnabled(false); //disable all buttons
                        sqFourBUT.setEnabled(false); //disable all buttons
                        sqFiveBUT.setEnabled(false); //disable all buttons
                        sqSixBUT.setEnabled(false); //disable all buttons
                        sqSevenBUT.setEnabled(false); //disable all buttons
                        sqEightBUT.setEnabled(false); //disable all buttons
                        sqNineBUT.setEnabled(false); //disable all buttons
    // horizontal, bottom, o wins
            if (sqThree == "O") { //checking too see if player O has won
                if (sqSix == "O") {
                    if (sqNine == "O") {
                        turnTF.setText("O wins!"); //O wins text
                        sqOneBUT.setEnabled(false); //disable all buttons
                        sqTwoBUT.setEnabled(false); //disable all buttons
                        sqThreeBUT.setEnabled(false); //disable all buttons
                        sqFourBUT.setEnabled(false); //disable all buttons
                        sqFiveBUT.setEnabled(false); //disable all buttons
                        sqSixBUT.setEnabled(false); //disable all buttons
                        sqSevenBUT.setEnabled(false); //disable all buttons
                        sqEightBUT.setEnabled(false); //disable all buttons
                        sqNineBUT.setEnabled(false); //disable all buttons
    // diagonal, top right to bottom left, o wins
            if (sqThree == "O") { //checking too see if player O has won
                if (sqFive == "O") {
                    if (sqSeven == "O") {
                        turnTF.setText("O wins!"); //O wins text
                        sqOneBUT.setEnabled(false); //disable all buttons
                        sqTwoBUT.setEnabled(false); //disable all buttons
                        sqThreeBUT.setEnabled(false); //disable all buttons
                        sqFourBUT.setEnabled(false); //disable all buttons
                        sqFiveBUT.setEnabled(false); //disable all buttons
                        sqSixBUT.setEnabled(false); //disable all buttons
                        sqSevenBUT.setEnabled(false); //disable all buttons
                        sqEightBUT.setEnabled(false); //disable all buttons
                        sqNineBUT.setEnabled(false); //disable all buttons
             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
             $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~X WINS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    //horizontal, top, x wins
            if (sqOne == "X") { //checking too see if player X has won
                if (sqFour == "X") {
                    if (sqSeven == "X") {
                        turnTF.setText("X wins!"); //X wins text
                        sqOneBUT.setEnabled(false); //disable all buttons
                        sqTwoBUT.setEnabled(false); //disable all buttons
                        sqThreeBUT.setEnabled(false); //disable all buttons
                        sqFourBUT.setEnabled(false); //disable all buttons
                        sqFiveBUT.setEnabled(false); //disable all buttons
                        sqSixBUT.setEnabled(false); //disable all buttons
                        sqSevenBUT.setEnabled(false); //disable all buttons
                        sqEightBUT.setEnabled(false); //disable all buttons
                        sqNineBUT.setEnabled(false); //disable all buttons
    //vertical, left, x wins
            if (sqOne == "X") { //checking too see if player X has won
                if (sqTwo == "X") {
                    if (sqThree == "X") {
                        turnTF.setText("X wins!"); //X wins text
                        sqOneBUT.setEnabled(false); //disable all buttons
                        sqTwoBUT.setEnabled(false); //disable all buttons
                        sqThreeBUT.setEnabled(false); //disable all buttons
                        sqFourBUT.setEnabled(false); //disable all buttons
                        sqFiveBUT.setEnabled(false); //disable all buttons
                        sqSixBUT.setEnabled(false); //disable all buttons
                        sqSevenBUT.setEnabled(false); //disable all buttons
                        sqEightBUT.setEnabled(false); //disable all buttons
                        sqNineBUT.setEnabled(false); //disable all buttons
    // diagonal, top left to bottom right, x wins
            if (sqOne == "X") { //checking too see if player X has won
                if (sqFive == "X") {
                    if (sqNine == "X") {
                        turnTF.setText("X wins!"); //X wins text
                        sqOneBUT.setEnabled(false); //disable all buttons
                        sqTwoBUT.setEnabled(false); //disable all buttons
                        sqThreeBUT.setEnabled(false); //disable all buttons
                        sqFourBUT.setEnabled(false); //disable all buttons
                        sqFiveBUT.setEnabled(false); //disable all buttons
                        sqSixBUT.setEnabled(false); //disable all buttons
                        sqSevenBUT.setEnabled(false); //disable all buttons
                        sqEightBUT.setEnabled(false); //disable all buttons
                        sqNineBUT.setEnabled(false); //disable all buttons
    // horizontal, mid, x wins
            if (sqTwo == "X") { //checking too see if player X has won
                if (sqFive == "X") {
                    if (sqEight == "X") {
                        turnTF.setText("X wins!"); //X wins text
                        sqOneBUT.setEnabled(false); //disable all buttons
                        sqTwoBUT.setEnabled(false); //disable all buttons
                        sqThreeBUT.setEnabled(false); //disable all buttons
                        sqFourBUT.setEnabled(false); //disable all buttons
                        sqFiveBUT.setEnabled(false); //disable all buttons
                        sqSixBUT.setEnabled(false); //disable all buttons
                        sqSevenBUT.setEnabled(false); //disable all buttons
                        sqEightBUT.setEnabled(false); //disable all buttons
                        sqNineBUT.setEnabled(false); //disable all buttons
    // horizontal, bottom, x wins
            if (sqThree == "X") { //checking too see if player X has won
                if (sqSix == "X") {
                    if (sqNine == "X") {
                        turnTF.setText("X wins!"); //X wins text
                        sqOneBUT.setEnabled(false); //disable all buttons
                        sqTwoBUT.setEnabled(false); //disable all buttons
                        sqThreeBUT.setEnabled(false); //disable all buttons
                        sqFourBUT.setEnabled(false); //disable all buttons
                        sqFiveBUT.setEnabled(false); //disable all buttons
                        sqSixBUT.setEnabled(false); //disable all buttons
                        sqSevenBUT.setEnabled(false); //disable all buttons
                        sqEightBUT.setEnabled(false); //disable all buttons
                        sqNineBUT.setEnabled(false); //disable all buttons
            // diagonal, top right to bottom left, x wins
            if (sqThree == "X") { //checking too see if player X has won
                if (sqFive == "X") {
                    if (sqSeven == "X") {
                        turnTF.setText("X wins!"); //X wins text
                        sqOneBUT.setEnabled(false); //disable all buttons
                        sqTwoBUT.setEnabled(false); //disable all buttons
                        sqThreeBUT.setEnabled(false); //disable all buttons
                        sqFourBUT.setEnabled(false); //disable all buttons
                        sqFiveBUT.setEnabled(false); //disable all buttons
                        sqSixBUT.setEnabled(false); //disable all buttons
                        sqSevenBUT.setEnabled(false); //disable all buttons
                        sqEightBUT.setEnabled(false); //disable all buttons
                        sqNineBUT.setEnabled(false); //disable all buttons
            String wins = turnTF.getText(); //Reading who won to print win winTF
            if (wins.equals("X wins!")) { //if X wins
                xWon++; //adding 1 to X's amount of wins
                String xWonString = Integer.toString(xWon); //converting to String
                xWinsTF.setText(xWonString); //displaying # of wins
                newGameBUT.setEnabled(true); //enable new game button
            if (wins.equals("O wins!")) { //if O wins
                oWon++; //adding 1 to O's amount of wins
                String oWonString = Integer.toString(oWon); //converting to String
                oWinsTF.setText(oWonString); //displaying # of wins
                newGameBUT.setEnabled(true); //enable new game button
            if (e.getSource() == newGameBUT) {
            i++; // turn switch
        /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        private void jbInit() throws Exception {
            this.getContentPane().setLayout(null);
            this.getContentPane().setBackground(Color.darkGray);
            sqTwoBUT.setBounds(new Rectangle(2, 116, 115, 115));
            sqTwoBUT.setFont(new java.awt.Font(
                    "Tw Cen MT Condensed Extra Bold",
                    Font.BOLD, 20));
            sqFourBUT.setBounds(new Rectangle(118, 1, 115, 115));
            sqFourBUT.setFont(new java.awt.Font(
                    "Tw Cen MT Condensed Extra Bold",
                    Font.BOLD, 20));
            sqFiveBUT.setBounds(new Rectangle(118, 116, 115, 115));
            sqFiveBUT.setFont(new java.awt.Font(
                    "Tw Cen MT Condensed Extra Bold",
                    Font.BOLD, 20));
            sqSixBUT.setBounds(new Rectangle(118, 232, 115, 115));
            sqSixBUT.setFont(new java.awt.Font(
                    "Tw Cen MT Condensed Extra Bold",
                    Font.BOLD, 20));
            sqOneBUT.setBounds(new Rectangle(2, 1, 115, 115));
            sqOneBUT.setFont(new java.awt.Font(
                    "Tw Cen MT Condensed Extra Bold",
                    Font.BOLD, 20));
            sqEightBUT.setBounds(new Rectangle(233, 116, 115, 115));
            sqEightBUT.setFont(new java.awt.Font(
                    "Tw Cen MT Condensed Extra Bold",
                    Font.BOLD, 20));
            sqNineBUT.setBounds(new Rectangle(233, 232, 115, 115));
            sqNineBUT.setFont(new java.awt.Font(
                    "Tw Cen MT Condensed Extra Bold",
                    Font.BOLD, 20));
            sqSevenBUT.setBounds(new Rectangle(233, 1, 115, 115));
            sqSevenBUT.setFont(new java.awt.Font(
                    "Tw Cen MT Condensed Extra Bold",
                    Font.BOLD, 20));
            sqOneBUT.addActionListener(this);
            sqTwoBUT.addActionListener(this);
            sqThreeBUT.addActionListener(this);
            sqFourBUT.addActionListener(this);
            sqFiveBUT.addActionListener(this);
            sqSixBUT.addActionListener(this);
            sqSevenBUT.addActionListener(this);
            sqEightBUT.addActionListener(this);
            sqNineBUT.addActionListener(this);
            newGameBUT.addActionListener(this);
            sqThreeBUT.setFont(new java.awt.Font(
                    "Tw Cen MT Condensed Extra Bold",
                    Font.BOLD, 20));
            turnTF.setFont(new java.awt.Font(
                    "Tw Cen MT Condensed Extra Bold",
                    Font.BOLD, 20));
            turnTF.setEditable(false);
            turnTF.setText("X goes first");
            turnTF.setHorizontalAlignment(SwingConstants.CENTER);
            turnTF.setBounds(new Rectangle(2, 346, 346, 35));
            oWinsTF.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold",
                                              Font.BOLD, 18));
            oWinsTF.setEditable(false);
            oWinsTF.setHorizontalAlignment(SwingConstants.CENTER);
            oWinsTF.setBounds(new Rectangle(256, 419, 79, 59));
            xWinsTF.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold",
                                              Font.BOLD, 18));
            xWinsTF.setEditable(false);
            xWinsTF.setHorizontalAlignment(SwingConstants.CENTER);
            xWinsTF.setBounds(new Rectangle(12, 419, 79, 59));
            oWinsLBL.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold",
                                               Font.PLAIN, 16));
            oWinsLBL.setForeground(Color.white);
            oWinsLBL.setHorizontalAlignment(SwingConstants.CENTER);
            oWinsLBL.setText("O wins:");
            oWinsLBL.setBounds(new Rectangle(256, 399, 78, 21));
            xWinsLBL.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold",
                                               Font.PLAIN, 16));
            xWinsLBL.setForeground(Color.white);
            xWinsLBL.setDisplayedMnemonic('0');
            xWinsLBL.setHorizontalAlignment(SwingConstants.CENTER);
            xWinsLBL.setText("X wins:");
            xWinsLBL.setBounds(new Rectangle(12, 393, 78, 21));
            newGameBUT.setBounds(new Rectangle(101, 455, 146, 23));
            newGameBUT.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold",
                                                 Font.BOLD, 14));
            newGameBUT.setText("New Game");
            this.getContentPane().add(sqFourBUT);
            this.getContentPane().add(sqThreeBUT);
            this.getContentPane().add(sqTwoBUT);
            this.getContentPane().add(sqOneBUT);
            this.getContentPane().add(sqFiveBUT);
            this.getContentPane().add(sqSixBUT);
            this.getContentPane().add(sqNineBUT);
            this.getContentPane().add(sqEightBUT);
            this.getContentPane().add(sqSevenBUT);
            this.getContentPane().add(turnTF);
            this.getContentPane().add(xWinsLBL);
            this.getContentPane().add(xWinsTF);
            this.getContentPane().add(oWinsLBL);
            this.getContentPane().add(oWinsTF);
            this.getContentPane().add(newGameBUT);
            sqThreeBUT.setBounds(new Rectangle(2, 232, 115, 115));
        JButton sqTwoBUT = new JButton();
        JButton sqThreeBUT = new JButton();
        JButton sqFourBUT = new JButton();
        JButton sqFiveBUT = new JButton();
        JButton sqSixBUT = new JButton();
        JButton sqOneBUT = new JButton();
        JButton sqEightBUT = new JButton();
        JButton sqNineBUT = new JButton();
        JButton sqSevenBUT = new JButton();
        JTextField turnTF = new JTextField();
        JTextField oWinsTF = new JTextField();
        JTextField xWinsTF = new JTextField();
        JLabel oWinsLBL = new JLabel();
        JLabel xWinsLBL = new JLabel();
        JButton newGameBUT = new JButton();
    }

    This code should be the poster-child for every time we tell someone that repeated code can usually be replaced with collections or method calls.
            if (e.getSource() == sqOneBUT) { //disable and print X or O to button
                sqOneBUT.setText(turn); //printing players symbol
                sqOneBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqTwoBUT) { //disable and print X or O to button
                sqTwoBUT.setText(turn); //printing players symbol
                sqTwoBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqThreeBUT) { //disable and print X or O to button
                sqThreeBUT.setText(turn); //printing players symbol
                sqThreeBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqFourBUT) { //disable and print X or O to button
                sqFourBUT.setText(turn); //printing players symbol
                sqFourBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqFiveBUT) { //disable and print X or O to button
                sqFiveBUT.setText(turn); //printing players symbol
                sqFiveBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqSixBUT) { //disable and print X or O to button
                sqSixBUT.setText(turn); //printing players symbol
                sqSixBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqSevenBUT) { //disable and print X or O to button
                sqSevenBUT.setText(turn); //printing players symbol
                sqSevenBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqEightBUT) { //disable and print X or O to button
                sqEightBUT.setText(turn); //printing players symbol
                sqEightBUT.setEnabled(false); //disabling button
            if (e.getSource() == sqNineBUT) { //disable and print X or O to button
                sqNineBUT.setText(turn); //printing players symbol
                sqNineBUT.setEnabled(false); //disabling button
            String sqOne = sqOneBUT.getText(); // Strings to read to find winner
            String sqTwo = sqTwoBUT.getText(); // Strings to read to find winner
            String sqThree = sqThreeBUT.getText(); // Strings to read to find winner
            String sqFour = sqFourBUT.getText(); // Strings to read to find winner
            String sqFive = sqFiveBUT.getText(); // Strings to read to find winner
            String sqSix = sqSixBUT.getText(); // Strings to read to find winner
            String sqSeven = sqSevenBUT.getText(); // Strings to read to find winner
            String sqEight = sqEightBUT.getText(); // Strings to read to find winner
            String sqNine = sqNineBUT.getText(); // Strings to read to find winner

  • How to implement Help in Swing Application

    Hi..
    In my Swing Application I want to put �Help� for Every field..
    Ex: After Username field ��� if I press �Whatisthis�. I will explain abt the user name field .in a popup text Area
    Thanks
    Cheers
    Mallik

    this may help you...
    http://java.sun.com/products/javahelp/
    regards
    Aniruddha

  • Help in swing components

    Hai,
    There are 9 buttons as a square in a Gui.
    When I click on a button its label should change to "W"
    How do I do it?
    This is very important to me! Kindly help me in this!
    Thankyou.

    Hi,
    Use setText on the button.
    /Kaj

  • Help! Swing freezes

    Hello,
    I developed several applications using Java V1.4.0. All apps were running at its best. Now I switched over to Java V1.4.1 and all Apps using Swing components (especially JList, JButton, JTextArea, ...) are freezing now.
    In Detail: I have an App which I use to administrate a database. I use the CardLayout to switch between the login panel and all other panels. When I start the app the login panel is shown. I enter the login data and hit the login button. Now there are many ways that can happen:
    Way 1: the button freezes but the app is still alive (the background threads which don't use Swing are still alice)
    Way 2: I have some processing but when the app wants to switch to the other panel Swing freezes (again, all background threads are still alive).
    The best thing is the server app I wrote. I can start the server but then immediately (OK, when I want to write some debug data to a JTextArea) Swing is freezing. Now I connect to the server app via some client apps and they are working perfect.
    I tried to debug the apps a little bit. Anytime Swing freezes the call stack shows that javax.swing.RepaintManager.addDirtyRegion is the last thing that executes something (or is still executing? forever??). Does Sun has changed something in that class?
    I use Linux (SuSE 8.0), Athlon TB 1.1G, Geforce 2 MX. Does it happen to anyone else?
    Best regards
    DirkBW

    Hi!
    I have the same problem. It seems that this happens if you instanciate a JComponent in the EventDispatchThread. Try to generate your Swing-Components in a seperate Thread and it will work fine. I think there's a another monitor-lock on the Repaint-Manager in the EventDispatchThread. So if you go into the addDirtyRegions - Method the JVM blocks the EventDispatchThread until the monitor-lock is released. But the EventDispatchThread is the only one who can release this lock -> deadlock. Your Applicaton is working fine after that, only Swing has locked itself. :-(
    But it's not very easy to build all JComponents in a seperate Thread. I think it's a serious problem. Maybe bug-report-worthy?
    Steve

  • Help me Swing!

    Hi! This is what I want to do:
    In a JList, select an item, press the Del key, and the selected item will be deleted.
    How can I do this? Thanks!

    This is code from the java book I have. It is for a combobox but shouldn't be too hard to amend for JList. The key is binded by InputMap and the action is carried out by ActionMap via object created by InputMap ("rubOut")
    // BindingDemo3.java
    import javax.swing.*;
    import javax.swing.plaf.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    class BindingDemo3 extends JFrame
       JComboBox jcb;
       BindingDemo3 (String title)
          super (title);
          JPanel jp = new JPanel ();
          Vector v = new Vector ();
          v.add ("Camaro");
          v.add ("Corvette");
          v.add ("Firebird");
          v.add ("TransAM");
          v.add ("Porsche");
          v.add ("Lamborgini");
          jcb = new JComboBox (v);
          jcb.setEditable (true);
          jcb.getActionMap ().put ("selectNext", new DownAction ());
          KeyStroke ks = KeyStroke.getKeyStroke (KeyEvent.VK_DELETE,
                                                 Event.CTRL_MASK);
          jcb.getInputMap (JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
             .put (ks, "rubOut");
          jcb.getActionMap ().put ("rubOut", new RubOutAction ());
          jp.setPreferredSize (new Dimension (200, 35));
          jp.add (jcb);
          getContentPane ().add (jp);
          pack ();                         
          setVisible (true);
       public static void main (String [] args)
          new BindingDemo3 ("Binding Demo3");
    class DownAction extends AbstractAction
       public void actionPerformed (ActionEvent e)
          JComboBox jcb = (JComboBox) e.getSource ();
          ComboBoxUI ui = jcb.getUI ();
          if (ui.isPopupVisible (jcb))
              int i = jcb.getSelectedIndex ();
              if (i < jcb.getModel ().getSize () - 1)
                  jcb.setSelectedIndex (i + 1);
                  jcb.repaint ();
          else
              int nItems = jcb.getItemCount ();
              ComboBoxEditor cbe = jcb.getEditor ();
              String st; // Search text
              st = ((String) cbe.getItem ()).toUpperCase ();
              for (int i = 0; i < nItems; i++)
                   String item = ((String) jcb.getItemAt (i)).toUpperCase ();
                   if (item.startsWith (st))
                       jcb.setSelectedIndex (i);
                       break;
              ui.setPopupVisible (jcb, true);
    class RubOutAction extends AbstractAction
       public void actionPerformed (ActionEvent e)
          JComboBox jcb = (JComboBox) e.getSource ();
          ComboBoxEditor cbe = jcb.getEditor ();
          cbe.setItem ("");

  • Help ! Swing Performance tuning

    Hi All
    what if I go on adding n number of components to the same location of a container without removing the previouly added component to the same location? the component count goes on increasing obviously but is there any performance issue when I remove the earlier one and then add the new one to it?
    e.g. If my JFrame contains one center JPanel and after every 10 seconds i want to change the center panel. If i just do it by setting earlier panel to visible false and add new panel to the center won't it increase the size of component list maintained by the container? does removing earlier component add then adding new one give better results over this?
    Shailesh

    Shure you get better performance, when removing not-used panels. Furthermore, swing-panels are very memory-consuming.

  • Help Update Swing

    Hi,
    I'm having some trouble with a swing application, let me explain it to you.
    I have a function (provided by a library, so it wont be easy to modify it), that retrieves files from a server; An object must be handed over to this function so the programmer can execute some code when a file is retrieved. What I'm trying to do is to update (append some text) on a JTextArea whenever a file is retrieved so the user has some idea of whats going on during the (usually) lengthy process.
    Problem here is that the JTextArea, does not get updated on the screen until during the retriving process, so it goes from an empty JTextArea (at the beginning and during the file transmission process), to a JTextArea with all the information of the process after the last file has been retrieved.
    The function which updates the JTextArea looked like this:
    public void sendReceivedObjectIndication(final String dicomFileName, final String transferSyntax, final String callingAETitle) throws DicomNetworkException, DicomException, IOException {
            if (dicomFileName != null) {
                         area.append("\nReceived: " + dicomFileName + " from " + callingAETitle);
             } else {
                //Notify failure
        }I also tried this
    public void sendReceivedObjectIndication(final String dicomFileName, final String transferSyntax, final String callingAETitle) throws DicomNetworkException, DicomException, IOException {
            if (dicomFileName != null) {
                //System.out.println("Received: " + dicomFileName + " from " + callingAETitle + " in " + transferSyntax);
                Runnable r=new Runnable() {
                    public void run() {
                       area.append("\nReceived: " + dicomFileName + " from " + callingAETitle);
                SwingUtilities.invokeLater(r);           
            } else {
               //Notify failure
        }But none of them works as expected.
    Anybody knows what to do here?
    Thanks in advance
    Jc

    You need to perform your lengthy task off of the EDT. Use a javax.swing.SwingWorker, as it facilitates periodically updating a GUI (on the EDT) while doing the lengthy task off of the EDT.
    Also, read this for a general tutorial and background on the subject: [Concurrency in Swing|http://java.sun.com/docs/books/tutorial/uiswing/concurrency/initial.html] .

  • Pls help 4m swing class

    Design, implement and test a Java class that will extract the required information from a headstone inscription. From a programming viewpoint this involves complex string manipulation with a little file handling to get the inscription from the Text file. For each inscription it is required to display on the computer screen, in tabular form, the Name, Death Date and Birth Date of each person buried under the stone.
    Note:
    That the birth date is not always given. Often the age at death in years is given hence it would be possible to compute the birth year or the year after the birth year. Complications arise with the death of young children. Often the age at death is given in days or months hence it might be possible to compute an exact birth date or at least a birth month. As each inscription is analysed the �original� inscription should be displayed, thus giving an immediate visual check that the data has been extracted correctly.
    EX
    Some sample data from gravesite Stoke Oats Esfield, UK
    In / memory of / WENDY-SARAH / SMITH 6th of March 1599/ and HENRY TODOR 28th of
    January 1547/ Forever in our thoughts / love LIZ and HARRY /
    In loving memory / of / JACK McDONALD /aged 3 days / 1799 / Jesus said suffer little /
    children to come unto Me /
    In / loving / memory of / BARRY H / BEAX-SMITH / 1798 � 1882 / PAT C / BEAX-SMITH /
    1800 � 1896 /
    / In loving memory / of / SAUL SAM NOCKLEY / late of Shire hall / died Dec 19th 1801,
    aged 71 years / also GERT NOCKLEY / wife of the above / died Oct 22nd 1811, aged 79
    years / peace perfect peace /
    Treasured memories of / a loving husband, dad and grandad / JIM WEST / who died 8th March
    1780 / aged 80 years / Joined by / a devoted wife, Mum and Nan / JUNE / who died 4th
    November 1890 / aged 92 years /
    In loving memory / of my dear husband / GEORGE WILLIAM HERN / born July 30th 1802 /
    died August 31st 1872 /
    In loving memory of our father WILLIAM JOHN AVALEZ died 2nd March 1904 aged 60
    years /And our mother APRIL AVALEZ died 2nd May 1912 aged 74 years /
    In loving memory of JOHN CLEMENT died 9th April 1720 aged 14 years /Also of HENRY
    CLEMENT died 26th March 1748 aged 45 years /
    Pray for the repose of the soul of / JAMES BACON / who died 1st February 1892 / aged 24
    years / also of Sergeant BILL BACON / killed in action / 26th September 1898 aged 24 years /
    on whose souls sweet Jesus have mercy / R.I.P / Erected by their sorrowing parents / B and J
    BACON
    Treasured / memories of / JAMES / SNOW / born 22.8.91 / died 23.8.92 / Sleep tight my /
    precious /
    Loving memories / of / ANNE / MURRAY / 11.5.70 / to / 19.4.71 / Sleeping /

    Rarely a post of this type is met with much help at all: it falls into the category of "Here is my home work do it for me." It may not be your intent for that to occur, but when you just post the assignment the readers of the forum have little else to conclude, other than, you are asking for a free grade.
    If you post your attempts along with specific questions on where you are having problems, then almost everyone will be willing to help you along the way, but a "do it for me" type of post is just not going to be met with positive results.

  • Help Needed - Swing Interview

    I m preparing for Interview. I have very less time to prepare. Guru's Could you please provide interview question and tutorial's in swing.
    and what to concentrate more.
    Regards
    Selva

    To quote the Java tutorial:
    "The single-thread rule is as follows:
    Rule: Once a Swing component has been realized, all code that might affect or depend on the state of that component should be executed in the event-dispatching thread.
    This rule might sound scary, but for many simple programs, you don't have to worry about threads. Before we go into detail about how to write Swing code, let's define the term realized.
    Realized means that the component has been painted on-screen, or that it is ready to be painted. A Swing component that's a top-level window is realized by having one of these methods invoked on it: setVisible(true), show, or pack. Once a window is realized, all the components that it contains are realized. Another way to realize a component is to add it to a container that's already realized. You'll see examples of realizing components later."

  • Help in swing application

    hi
    can any give me solution to hide the JVM console..
    that running behind the application..
    is that possible..

    Hmmm....
    NO
    Do you think Sun created javaw.exe just for the fun of it?
    If there was some other way to hide the console window javaw.exe would not be included in every JRE.

  • Help please with JFRAMES swing  and variables

    Hi...I need some help with Swing.I need to use the variable "datauser" and read it to operate with it( add,multiply,etc)
    I have two independants JFrames.(2 classes in different .java files).
    //FRAME1 get user data
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.*;
    public class FRAME1 extends javax.swing.JFrame {
              public double datauser; //i need this variable
              public JPanel jPanel1;
              public JTextField jTextField1;
              public FRAME1(){
              datauser=this.datauser;
              jPanel1 = new JPanel();
         jTextField1 = new JTextField();
              jTextField1.setText("10");
              JPanel1.add(jTextField1);
              jTextField1.addActionListener(new hearme());
              pack();
    class hearme implements ActionListener{
    public void actionPerformed(ActionEvent e)
    {     datauser= Double.parseDouble(jTextField1.getText()); //people write a number
    In other JFrame class (another .java file) i put:
    public class FRAME2 extends javax.swing.JFrame
              double aux;
              double multiplyby100() {
              aux= datauser *100;
              return aux;
    ANd i cant get anything just errors ..how can i relate to variables from differents Jframes?? I mean..how can i use a variable from Jframe1 in Jframe2. The actual value that people type in that textfield

    oh well thx for ur help...
    I meant ..i have 10 differentes Jframes (10 different clases)
    SO i have 10 differents windows...Then with a combobox ill choose what Jframe will appear.When a window appears i put ,for instance,parameters for calculating a circle area .Then i select rectangle in the combobox list and appear in the principal window its parameters to write in. Then i choose another element in that combobox and i put parameters for a square.Each one is a different window.I dont want to use Jdialog for that.
    The problem is that i want to use a variable defined in one frame to use that value in another class....for example i want to use a variable like this
    double side =double.parse(Textfield.getText()); //in a texfield in frame 1
    And do something with "side" but in a different class.(different file in the same package)
    public class hi() {
    double theside;
    theside=side; //<---------- here i have problems
    //how can i use the variable "side" in the class hi
    The exact point is that i want to get all the parameters from the user for each window that appears.And each class Jframe have their own variables .
    And i want to access to those variables in real time (what people type)
    So i cant find any solution.I have a structure for each window with labels and textfields (to put parameters).And i need to save each variable that people type in those textfields in public variables because i need to operate with data in a different class (for example in a main class).But that data is only saved into the particular classes because variables exist in there.
    Thanks in advance for ur answers .I havent slept for hours trying to think of that
    thanks!

  • The difference between "swing/awt" and "SWT"

    What is the main defference between "swing" and "SWT",
    in other word, when use them to implement a GUI,what is different?
    Once making a choice between them,what do they affect a project?

    They both are GUI toolkits. One is from Sun, one is from IBM.
    Sun's is lightweight, meaning all components paint themselves. IBM's is heavy weight meaning that all components are painted by the platform's native widget toolkits (there are exceptions to both of these, but just bear with me).
    If you use SWT, you will need to create downloads for each platform your app was meant to run on, not only that, you will need to include the corresponding platform SWT jar files in your project. Ontop of that, SWT doesn't have anywhere near the documentation or help that Swing has (but to be fair, its about 1/8th the age of Swing).
    If you are a great programmer that usually doesn't need help and can get by with a few good docs and MUST have native look and feel and fantastic GUI performance, then use SWT.
    But if you are more relaxed and what to do the easiest thing, use Swing.
    Both are good, I prefer Swing right now, but lets wait and see if IBM buys Sun.

  • Java GUI Help Needed

    Can someone help me find a link, book, tutorial or anything along those lines that can help me understand building a GUI in Java? Thanks, Jeremy

    When I was about to create my first GUI I used an IDE with "visual" capabilities. You design the GUI by using drag-and-drop and filling in tables, and then the IDE generates the code automatically for you. I found this helpful because Swing is so complex and in this way you get your options presented to you and you can study the generated code.

Maybe you are looking for

  • IPS shows Memory usage 80 % is that normal ?

    Hi there. I have a 2 5525x configured as active/standy and bot IPS modules configured with defaults there is no internet connection to them and no traffic passing thru , but IPS show memory usage 80% is that normal ?

  • Re: mixed up on few java issues

    What is java SDK? Also I have installed a few versions of JDK, each time upgrading from older one because I was given older versions when I first started on java. Now I have a few version on the computer, how do I find out which version I am using?

  • Brett Henderson app showing up on Droid 3's mysteriously

    This "software" is showing up, apparently on Droid 3's only, starting yesterday. It's not listed in Google Play and AV software (at least, Avast) doesn't mark it as malware. It also doesn't seem to be uninstallable. I realize there is a developer wit

  • How to get recently opened module name in oracle forms

    hello experts,               I am using oracle forms 11g with oracle weblogic server 10.3.5 at windows 7.How can i get the module name opened in a particular session by a user in oracle forms. regards aaditya

  • FolderUtils.create error

    I keep getting the error: JSP Error Exception: java.lang.NullPointerException at oracle.ifs.clients.webui.FolderUtils.create(FolderUtils.java:71) at ifs.files._ifs._jsp_2d_bin._ifs_2d_cts._jsps._createcdromfolder._jspService(_createcdromfolder.java:1