Gui Help ( toolbar )

Greetings,
Ive came across problems while doing a tutorial work piece.
i've to design a toobar ( yup a JToolBar ) with 5 buttons inside it, that will do certain functions for a JSlider.( set them at certain values )
Its simple enough to go and write 5 buttons into my code, but thats not wot ive to do.
The idea is that you will
develop one button that is customisable at design time to have one of 5 different
appearances. Developing 5 separate buttons is NOT an acceptable solution.
Is this even possible? ( pls note the 5 different appearances are Symbals )
Problem: Placing 5 buttons inside a JToolBar, and positing it under my created JSlider
// bob smith
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Testing extends JFrame
  int min = 40;
  int max = 180;
  int value = min;
  JSlider slider = new JSlider(min,max,value);
  MyUI ui = new MyUI(slider);
  int tw,sw,startGap;
  public Testing(){
    setSize(250,100);
    setLocation(400,200);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    slider.setUI(ui);
    slider.addMouseListener(new MouseAdapter(){
      public void mousePressed(MouseEvent me)
        slider.setValue(min+(max-min)*(me.getX()-startGap)/tw);
    slider.setMajorTickSpacing(20);
    slider.setMinorTickSpacing(10);
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);
    getContentPane().add(slider);
    setVisible(true);
    tw = ui.getTrackWidth();
    sw = slider.getWidth();
    startGap = (sw-tw)/2;
  public static void main(String args[]){new Testing();}
class MyUI extends javax.swing.plaf.basic.BasicSliderUI
  public MyUI(JSlider js)
   super(js);
  public int getTrackWidth()
    return (int)((Rectangle)trackRect).getWidth();
}Any help or guidance AT all, would be amazing :)
Thanks!

Check the  below links :
create cl_gui_toolbar object
Picture on selection screen
http://help.sap.com/saphelp_nw04/helpdata/en/ce/cd7c3ec24d11d2bd8d080009b4534c/frameset.htm
Program to execute WWW
Reward Points if it is helpful
Thanks
Seshu

Similar Messages

  • Portal w/SAP GUI; Help -- Application Help causes all windows be destroyed

    Hello All -
    I have a user who has portal windows (IE) open in the portal, multiple sessions.  When he has a SAP GUI transaction in the application content area and selects the SAP GUI 'Help' --> 'Application Help' link, all the session windows are closed, and the primary goes to SAP help.
    This destroys what the user was working on. 
    My computer does not do this, even when that user is logged in on my computer.
    Any ideas?

    Hi,
    Your requirements are not 100% clear. In  your message you say you are looking for SNC between SAP GUI and SAP ABAP, but the help page you posted a link for is not related to this, but explains how to use SNC for CPIC.
    If you are looking to use SNC for authenticating users of SAP GUI to SAP ABAP, then you have a number of options. If your SAP ABAP server is on Windows then SAP have a library which can be obtained for no cost to give you basic SSO using Active Directory authentication (aka Kerberos). If your SAP application server is on Unix or Linux, then you can look on SAP EcoHub for third party SAP certified products which provide this functionality. SAP have also just launched a new product which has some functionality for SAP GUI SSO, but this is not free.
    Please let me know if you have any more questions or need clarification.
    Thanks,
    Tim

  • I am in need of serious GUI help... can someone save me please?? :(!  !   !

    Hello people..
    I need to write a program to let users to design a GUI as they want. They can add a swing or awt component to a panel by choosing options from menu or toolbar. Obviously they can see what they have at runtime.
    1.) I don't know how to display these components at runtime.
    2.) how do i automatically add code, corresponding to the components being added to the panel, to a text file?
    3.) and how do i save the text file and graphical design of the GUI together, which will allow users to return to the unfinished GUI, hence redisplaying the graphical design and text file of the code simultaneously?
    4.) how can i delete a component, thus removing the corresponding code??
    help would be very very very much appreciated..
    thanx in advance... :)

    This is somehow a very very very complicated task !
    Visit www.visaj.com,and here you will find a tool for building a GUI ,may be you get some idea.

  • Both side chatting with simple GUI ,,helps pls?

    guys I'm Java application programmer i don't have well knowledge in network programing ,,my question ,,,from where should i start to design a simple GUI client*s* server chat program ,i mean some thing like simple yahoo messenger the program should include also adding contact and make that contact appears ON if he login or OFF if he sign out like red color for ON-line contact and and white color for off-line contact ...........
    another thing that chat system should include shared folder all the contact can enter it and upload file or download file ...
    please guys i run to you to help me i have 2 weeks only to do that thing please don't let me down i need your help ....TIPS,code,any thing full code :) ,,any thing will be really appreciated .
    guys for more information the program includes only the chat of course its both sides chat between the clients and these is no conference room
    or audio or video nothing ,,just text only nothing else except the folder shearing service and the colors of the contacts for login or not .
    guys once more help me give me codes or any thing useful i count on you guys.
    thx a lot in advance
    RSPCPro
    Edited by: RSPCPRO on Oct 3, 2008 6:25 PM

    RSPCPRO wrote:
    Dude , u r right ,,,but still its simple GUI issueI'm not sure why you are getting this impression. It's not a simple "GUI issue." Yes, you can simply create the GUI for this, but will it be functional? No. Furthermore, if it was so simple, why are you posting asking for help?
    For an instant message chat program, in addition to GUI programming, you need to know how client / server systems work and you need to implement one. A server should be running on one system and the client(s) will connect to it. The server usually maintains the buddy list and passes the messages to/from different clients. This presents several problems that you will need to solve:
    1. How will you develop a protocol between the client / server for communication?
    2. How will you authenticate users?
    3. How will you maintain the buddy list on the server (data structure, database, file)?
    4. How will you pass messages from one client to another (simple string message, serialized data object, etc.)?
    5. etc.
    Now, I'm not saying this is "impossible" so please don't take it that way. I'm simply trying to help you realize that there are a lot of factors to consider when developing this type of application.
    RSPCPRO wrote:
    and for the "FTP?" ,,,its folder shearing as i said earlier every one of your friends can access it not FTP .....Talking about "folder sharing" is a whole other issue. What I meant by saying "FTP?" is, how do you plan on implementing "folder sharing" remotely? One option is FTP. How would you do it?
    RSPCPRO wrote:
    and one thing please don't assume any thing u don't knowIf you ask a very broad question and ask for code, I can only assume one thing.
    RSPCPRO wrote:
    be cooler with others and u will get what u want.I agree. You should take your own advice. I'm not the one looking for help, you are.
    RSPCPRO wrote:
    thx dude for ur advice and for the link have a good day.You're welcome, and good luck.

  • Basic GUI Help

    I'm working on a big GUI, using NetBeans since it simplified the initial container design... but now I need to link all the components to actions and events... which I'm not very experienced with.
    I made a dummy GUI that does similar, but far fewer functions like my real project. Can someone help me design the actions/events for this little dummy gui, and explain how they work, so I can use that as a guide...?
    The dummy project has two java files. A Scan class (Scan.java) will be used to parse a 'patient' text file, and create a String with info from that file (Scan.patient), as well as store the original pathname (Scan.path).
    http://deviantone.com/javagui/Scan.java
    You can create a Scan object by giving the constructor a File or String (file path) argument. You can then call the patient or path vars. The dummy 3 line patient file:
    http://deviantone.com/javagui/dummy.txt
    Now the hard part, the GUI from NetBeans... the syntax is a little bloated since it's machine generated, but shouldn't be too hard to figure out.
    http://deviantone.com/javagui/dummyGui.java
    The GUI is meant to parse whatever text file opened (for the purposes of this dummy gui, only dummy.txt will ever be browsed to, since the program can handle only 3 lines) into C:\output.txt (which you can create and leave blank beforehand).
    What I need:
    (1) The Open button (JButton openButton) needs to call a file chooser, where a user can browse to our dummy text file. dummyGui.java should then make a Scan object using this file.
    (2) Once opened, the file path should appear in the JLabel pathLabel (you can use another gui component instead of a JLabel if you want, I just didn't know what would be the appropriate one for this sort of operation)
    (3) You can select Yes/No or input some text into the combo box (JComboBox statusCombo) as well as input stuff into a text field, let's say a date (JTextField dateField). This information will also be written into output.txt
    (4) Once you hit the Write button, Scan.patient, and the contents of statusCombo and dateField should be written into output.txt (it doesn't matter what line contains what, for simplicity maybe make statusCombo first, then dateField, then Scan.patient which is 2 lines)... I just need to see how to make a button do such an operation using another Object (Scan) as well as user input...
    So far, I have looked through the API and File Chooser examples, and I've added the following to my code:
    - instance variable to the dummyGui.java: File file; for the file that file chooser will get.
    - also added openButton.addActionListener(this); to the initComponents() method.
    - and another method:
    public void actionPerformed(ActionEvent e) {
        if(e.getSource() == openButton){
          JFileChooser chooser = new JFileChooser();
          int returnVal = chooser.showOpenDialog(dummyGui.this);
          if(returnVal == JFileChooser.APPROVE_OPTION) {
            file = chooser.getSelectedFile();
    }But when I run the GUI, and hit Open, the button gets pressed in and then the window freezes while no file browser shows ... =/

    Don't use an IDE to generate your code, you don't learn anything.
    Read the [url http://java.sun.com/docs/books/tutorial/uiswing/TOC.html]Swing tutorial. It gives sample programs on using the various Swing components.

  • Unix Ate My OSX GUI Help Please

    Hi All,
    I have the darndest problem . I have a G4 AGP Powermac running OSX10.4.11. Processors are dual giga designs 1.8 ghz. One day I shut my Mac down as usual. The next day I start up and I get a gray apple screen with the rosette. The screen changes to blue,After a minute or so I get a black screen and welcome to darwin! There is a login and password which appear. I can login and it accepts my password, I receive my name with a dollar sign after it. I do not want to be there. I want to be in the non unix world of the uninformed typical GUI user. How do I get out of the shell and into my nice safe GUI interface of Tiger? I know of no issues that put me there. I have done some research into Unix and have used the most basic of commands. Help, info, exit, list. I admit I am totally lost.
    So, any help would be greatly appreciated as all of my important stuff, pics music movies,etc. is on this computer. I have another internal hard drive in the G4 which is my backup, but am unable to access it at this time. It has no operating system on it.
    Any help would be appreciated.
    TakeCare
    Bill

    I doubt this is just as simple as that. Ordinarily the OS wouldn't boot to single user mode unless a) you held down a specific combination of keys at boot, or b) there's some problem affecting the normal boot problem.
    I suspect the latter.
    You should look carefully at the messages on screen. There should be something there that gives you a hint as to what's wrong (most likely a problem with the boot volume). It should also give hints on how to fix the problem using fsck.

  • Simple GUI - Help

    Hi, for my Java class, we have to write a simple GUI for a program that we wrote last week. This is what I have so far:
    import javax.swing.*;
    import java.awt.*;
    import java.util.Random;
    /* Class Kozyra which contains main method */
    public class Kozyra {     
        /* Method question: gets the user to enter whether or not he/she wants to continue
         * running the program */
        public static String question(){
              String s, answer;
              boolean valid;
              do{
                   s = JOptionPane.showInputDialog("Continue? (Y/N or P to Pause)");
                 answer = s.toUpperCase();
                 valid = answer.equals("Y") || answer.equals("N") || answer.equals("P");
                 if(!valid){
                        JOptionPane.showMessageDialog(null, answer + " is not a valid response. Please retype.");
                 } // end if
                 if(answer.equals("P")){
                      JOptionPane.showMessageDialog(null, "Game Paused.  Press OK to continue.");
              }while (!valid); // end do-while
              return answer;
        } // end method question
        public static void frame(){
             Homework3GUI frame = new Homework3GUI();
              frame.setTitle("CRAPS");
              frame.setLocationRelativeTo(null);
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(600,400);
              frame.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
              frame.setVisible(true);
        } // end method frame
        /* Main method: creates new object called player and determines whether or not the game
         * continues running*/
        public static void main(String[] args){     
            frame();
            String answer = "Y";
              Dice player = new Dice(100, "");
              JOptionPane.showMessageDialog(null,"Welcome to CRAPS, " + player.getName());
              while(!player.busted() && !player.reachedGoal() && answer.equals("Y")){           
                player.begin();
                if(!player.busted() && !player.reachedGoal()){
                        answer = question();
                   } // end if
                   else{
                        answer = "N";
                   } // end if
              } // end while                 
        } // end main
    } // end class Homework3
    /* Beginning of class Dice (driver) */
    class Dice extends JPanel{
         // Declare variables
         private int amount, betValue;
         private int roll = 0;
        private String name;
            private boolean win, lose;
            private JTextField text1, text2, text3, text4, text5, text6;
         /* Constructor */
        public Dice(int amount, String name){
            this.name = name; // this refers to instance variabls
            this.amount = amount;
        } // end method Dice
        public void layout(){
             setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
             text1 = new JTextField();
             text2 = new JTextField();
             text3 = new JTextField();
             text4 = new JTextField();
             text5 = new JTextField();
             text6 = new JTextField();
             add(text1, null);
             add(text2, null);
             add(text3, null);
             add(text4, null);
             add(text5, null);
             add(text6, null);
             text1.setSize(15,25);
             text2.setSize(15,25);
             text3.setSize(15,25);
             text4.setSize(15,25);
             text5.setSize(15,25);
             text6.setSize(15,25);
             text1.setLocation(10,10);
             text2.setLocation(10,40);
             text3.setLocation(10,70);
             text4.setLocation(10,100);
             text5.setLocation(10,130);
             text6.setLocation(10,160);
             setVisible(true);
        } // end method layout
        /* Prompts the user to enter his/her name using the scanner class and returns it as a string */
        public String getName(){
             String name = JOptionPane.showInputDialog("Please enter your name: ");
            return name;
        } // end method getName
        /* Asks the user to input his/her bet and determines if it is valid */
         private void getBet(){
              String betValueString = JOptionPane.showInputDialog("You have $" + amount +
                   ".  Please enter your bet: $");
              betValue = Integer.parseInt(betValueString);
              if(betValue > amount){
                      betValueString = JOptionPane.showInputDialog("You only have $" + amount +
                           ".  Please enter a bet that is less than or equal to $" + amount + ":  $");
                      betValue = Integer.parseInt(betValueString);
              } // end if
              if(betValue < 1){
                   betValueString = JOptionPane.showInputDialog("You have $" + amount +
                        ".  Please enter an amount greater than $1:  $");
                      betValue = Integer.parseInt(betValueString);
              } // end if
         } // end getBet
         /* Simulates the craps game and returns win */
         private boolean playGame(){
               int answer = roll();
               text1.setText("Your roll is: " + answer);
               win = answer == 11 || answer == 7;
               lose = answer == 2 || answer == 12;
               if(!(win || lose)){
                    int point = answer;
                    text2.setText("Your point value is: "+ point);
                    while(!(win||lose)){
                         answer = roll();
                         text3.setText("Your total is: " + answer);
                         win = answer == point;
                         lose = answer == 7;
                    } // end while
               } // end if
               return win;
          } // end method game
         /* Simulates the rolling of the die */
         public int roll(){
               int die1 = (int)(6*Math.random() + 1);
               int die2 = (int)(6*Math.random() + 1);
               text4.setText("You rolled " + die1 + " and " + die2 + ".  ");
               return die1 + die2;
          } // end method roll
         /* Informs the user of the result of his/her game and updates the amount of "money" */
         private void displayMessage(boolean win){
              if(win == true){
                   text5.setText("Congratulations, you won that round.  You bet $" + betValue +
                        " so you won $" + betValue + ". You now have $" + (amount += betValue));
              } // end if
              else{
                   text5.setText("Sorry, you lost that round.  You bet $" + betValue +
                        " so you lost $" + betValue + ".  You now have $" + (amount -= betValue));
              } // end else if
         } // end method displayMessage
        /* Determines if the user has busted or won and will or will not continue playing */
        public boolean terminate(){
             boolean go;
             if(busted() == true){
                  text6.setText("Sorry, you have lost. :( Somewhere, the world's tiniest violin is " +
                       "playing you a sad song.");
                  go = false;
             } // end if
             else if(reachedGoal() == true){
                  text6.setText("CONGRATULATIONS!  YOU HAVE BEAT THE ODDS AND WON!" +
                       " THE COSMOS SALUTES YOU! GO SPEND YOUR WINNINGS");
                  go = false;
             } // end else if
             else
                  go = true;
             return go;
        } // end method terminate
        /* Determines of goal of amount greater than or equal to $300 has been reached */
        public boolean reachedGoal(){
             return amount >= 300;
        } // end method reachedGoal
        /* Determines if the user has run out of money to play with */
        public boolean busted(){
            return amount <= 0;
        } // end method busted
        /* Calls other methods in order to play game */
        public void begin(){
            getBet();
            playGame();
            displayMessage(win);
            terminate();
        } // end begin
    } // end DiceI'm sure it's simple and terrible and all but I really don't know what I'm doing, and this is my first time writing a GUI (plus my professor's teaching consisted of him telling us to go look online). Firstly I can't get anything to show up on the frame. Secondly, it compiles but does not run and I am getting the following two errors:
    Exception in thread "main" java.lang.NullPointerException
    at Dice.roll(Kozyra.java:182)
    at Dice.playGame(Kozyra.java:155)
    at Dice.begin(Kozyra.java:238)
    at Kozyra.main(Kozyra.java:56)
    Note: C:\Program Files\Xinox Software\JCreatorV4LE\MyProjects\Honors2\Kozyra.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Any help would be appreciated, as I am becoming increasingly frustrated (I can't find where the pointer exception is and I have no idea what the "note" one is...). Thanks.

    Thanks, Corlett.
    The Homework3GUI thing was a vestige from something else that I missed correcting. However, I still cannot get anything to show up on the JFrame...Also, what does private static final long serialVersionUID = 54645635L; do?
    This is how the code reads now:
    import javax.swing.*;
    import java.awt.*;
    import java.util.Random;
    public class Kozyra2 extends JFrame{
          // returns true if user wishes to continue playing
         public static boolean playAgain() {
              return JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null,
                   "Play again ?", "Do you wish to continue playing?", JOptionPane.YES_NO_OPTION);
          } // end method playAgain
          // builds and shows a GUI.
         public static void buildAndShowGUI(){
              Kozyra2 frame = new Kozyra2();
                 frame.setTitle("CRAPS");
                 frame.setLocationRelativeTo(null);
                 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                 frame.setSize(600,400);
                frame.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
                 frame.setVisible(true);
          } // end buildAndShowGUI
         // Main method: gets this show on the road.
         public static void main(String[] args){
                buildAndShowGUI();
                Player player = new Player(100, enterName());
              JOptionPane.showMessageDialog(null,"Welcome to CRAPS, " + player.getName());
              while(player.play() && playAgain());
         } // end main method
         // returns the name entered by the user
         private static String enterName() {
              return JOptionPane.showInputDialog("Please enter your name: ");
         } // end method enterName
    } // end class
    class Player extends JPanel{
         private static final long serialVersionUID = 54645635L;
         private static final int TARGET_BALANCE = 300;
         private int balance;
         private String name;
         private JTextField[] text = null;
         public Player(int stake, String name){
              this.name = name;
                 this.balance = stake;
                 this.layoutPanel();
         } // end constructor
         public String getName() {
              return this.name;
         } // end method getName
         private void layoutPanel() {
                setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
                 text = new JTextField[6];
                 for (int i=0; i<6; i++) {
                   text[i] = newTextField(10+i*30);
                   add(text, null);
              } // end for loop
              setVisible(true);
         } // end method layoutPanel
         private JTextField newTextField(int y) {
              JTextField t = new JTextField();
              t.setSize(15,25);
              setLocation(10,y);
              return t;
         } // end method newTextField
         // returns the users bet balance
         private int getBet(){
              while (true) {
                   try {
                        String response = JOptionPane.showInputDialog("You have " + balance + ". Your bet ? ");
                        int bet = Integer.parseInt(response);
                        if(bet>=1 && bet<=balance)
                             return bet;
                        JOptionPane.showMessageDialog(null, "Oops: An integer between 1 and " + balance + " is required.");
              } catch (NumberFormatException E) {
                   JOptionPane.showMessageDialog(null, "Oops: An integer value is required.");
              } // end try-catch
              } // end while loop
         } // end method getBet
         // returns true of the user wins this round.
         private boolean playRound(int bet){
              int score = roll();
              text[1].setText("Your score is: " + score);
              boolean win = (score == 11 || score == 7);
              boolean lose = (score == 2 || score == 12);
              int previousScore = score;
              while ( !(win||lose) ) {
                   score = roll();
                   text[3].setText("Your score is: " + score);
              win = (score == previousScore);
              lose = (score == 7);
              previousScore = score;
              } // end while loop
              if (win) {
                   balance += bet;
                   text[5].setText("You won. You won $" + bet + ". You now have $" + balance);
              } // end if statement
              else {
                   balance -= bet;
                   text[5].setText("You lost. You now have $" + balance);
              } // end else
              return win;
         } // end method playRoung
         // returns the total of rolling a pair of dice.
         public int roll(){
              int die1 = (int)(6*Math.random() + 1);
              int die2 = (int)(6*Math.random() + 1);
              int total = die1 + die2;
              text[4].setText("You rolled " + die1 + " and " + die2 + " = " + total);
              return total;
         } // end method roll
    // are we there yet?
         public boolean checkBalance(){
              if (balance <= 0) {
                   text[6].setText("Busted!");
              return true;
              } // end if statement
              if (balance >= TARGET_BALANCE) {
                   text[6].setText("Congratulations! Go spend your winnings.");
                   return true;
              } // end if statement
              return false;
         } // end method checkBalance
         public boolean play(){
              int bet = getBet();
              playRound(bet);
              return checkBalance();
         } // end method play
    } // end class Player

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

  • GUI Help Needed

    *////The declaration*
    Entry [] entries  - array of entries
    Int eno      - number of Entrys in entries
    Int MAXE = 100; maximum number of entrys in entries
    Int current ? index in entries of entry *///////I have few Jtextfields in a GUI where when I click ?new? Jbutton it would put the Jtextfields in entries[eno] can I know how to write this code .*
    Public void actionPerformed (ActionEvent E) {
    If (e.getSource==new) ;
    Sorry not sure how to write plz help
    }

    What is an Entry? What is an Int?
    I have few Jtextfields in a GUI where when I click ?new? Jbutton it would put the Jtextfields in entries[eno] can I know how to write this code .If you want to put the JTextFields in entries[], then entries has to be of type JTextField[]. Or do you want to put the strings that were entered into the JTextFields into entries[]?
    Here is my attempt:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    class MyWindow extends JFrame implements ActionListener
      private ArrayList<JTextField> textBoxes;
      private ArrayList<String> entries;
      public MyWindow()
        //Initialize frame:
        super("Testing");
        setBounds(20, 100, 500, 500);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        textBoxes = new ArrayList<JTextField>();
        entries = new ArrayList<String>();
        //Create textboxes:
        textBoxes.add(new JTextField("", 20));
        textBoxes.add(new JTextField("", 30));
        //Create button:
        JButton newButton = new JButton("new");
        newButton.addActionListener(this);
        //'this'-->look in this class for actionPerformed() method
        //Create panel:
        JPanel panel = new JPanel();
        for(JTextField textBox: textBoxes)
          panel.add(textBox);
        panel.add(newButton);
        //Add panel to window:
        Container cpane = getContentPane();
        cpane.add(panel);
      public void actionPerformed(ActionEvent ev)
        for(JTextField textBox: textBoxes)
          entries.add(textBox.getText());
        for(String str: entries)
          System.out.println(str);
    public class WindowTest
      public static void createAndShowGui()
        MyWindow win = new MyWindow();
        win.setVisible(true);
      public static void main(String args[])
        //The proper way to launch a java gui:
        Runnable runner = new Runnable()
          public void run()
            createAndShowGui();
        SwingUtilities.invokeLater(runner);
    }Or maybe you don't know how many JTextFields there are in the window? Is the user adding them dynamically?
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    class MyWindow extends JFrame implements ActionListener
      private ArrayList<JTextField> entries;
      JPanel panel;
      public MyWindow()
        //Initialize frame:
        super("Testing");
        setBounds(20, 100, 500, 500);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        entries = new ArrayList<JTextField>();
        //Create textboxes:
        //Create button:
        JButton newButton = new JButton("new");
        newButton.addActionListener(this);
        //'this'-->look in this class for actionPerformed() method
        //Create panel:
        panel = new JPanel();
        panel.add(new JTextField("", 20));
        panel.add(new JTextField("", 20));
        panel.add(newButton);
        //Add panel to window:
        Container cpane = getContentPane();
        cpane.add(panel);
      public void actionPerformed(ActionEvent ev)
        int count = panel.getComponentCount();
        System.out.println(count);
        Component comp = null;
        for(int i=0; i<count; ++i)
          comp = panel.getComponent(i);
          if(comp.getClass() == JTextField.class)
            entries.add((JTextField)comp);
        for(JTextField tf: entries)
          System.out.println(tf.getText());
    public class WindowTest
      public static void createAndShowGui()
        MyWindow win = new MyWindow();
        win.setVisible(true);
      public static void main(String args[])
        Runnable runner = new Runnable()
          public void run()
            createAndShowGui();
        SwingUtilities.invokeLater(runner);
    }

  • Gui Help *URGENT*

    Hey guys I'm looking at working on java games further on down the track so I've just started working with java and some TCP clients and servers, I've come here to find some very useful information and now switched to Eclipse rather then Jcreator because I read somewhere it has a plugin for a GUi.
    I'm working on a TCP client gui and at the moment this is my client's java code which works with the current server I have, As I said before I'm only just starting on java and this has been giving me a head ache for a couple of days now and I'm hoping someone can help me. The problem is with the line NetworkClient nc = new NetworkClient(args[0]); any answer as to whats wrong and a example of how to fix it would be great. Cheers in advance.
    NetworkClient Code
    import java.io.OutputStream;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.BufferedReader;
    import java.io.PrintStream;
    import java.net.Socket;
    import java.util.Scanner;
    import java.io.File;
    public class NetworkClient {
       private final int PORT = 2008;
       private Socket sock;
       private BufferedReader reader;
       private Scanner console;
       private PrintStream writer;
       public static void main (String[]args)throws Exception {
          new NetworkClient();
    public NetworkClient()throws Exception {
       sock = new Socket("localhost",PORT);
       InputStream in = sock.getInputStream();
       OutputStream out = sock.getOutputStream();
       reader = new BufferedReader(new InputStreamReader(in));
       writer = new PrintStream(out);
       console = new Scanner(System.in);
       System.out.println("Enter a line of text");
       while(console.hasNext()) {
          String line = console.nextLine();
          writer.println(line);
          if(line.matches("QUIT")) {
             writer.close();
             System.exit(0);
          String response = reader.readLine();
          System.out.println("Response from server was: " + response);
          if(line.matches("LIST"))  {
             int number = new Integer(response);
             for (int n = 0; n <number;n++) {
                response = reader.readLine();
                System.out.println("Response from server was: " + response);
                System.out.println("Enter a line of text");
    public String doEcho(String line)throws Exception {
       writer.println("Response from server was: " + line);
       String response = reader.readLine();
       return response;
    UserInterface Code
    import java.util.Scanner;
    public class UserInterface {
        private Scanner console;
        private NetworkClient netClient;
        public static void main(String[] args) throws Exception {
       if (args.length != 1) {
           System.err.println("Usage: Client address");
           System.exit(1);
       NetworkClient nc = new NetworkClient(args[0]);
       new UserInterface(nc);
        public UserInterface(NetworkClient client) throws Exception {
       netClient = client;
       console = new Scanner(System.in);
       System.out.println("Enter a line of text");
       while (console.hasNext()) {
           String line = console.nextLine();
           System.out.println("Request was: " + line);
           String response = netClient.doEcho(line);
           System.out.println("Response from server was: " + response);
           System.out.println("Enter a line of text");
    GUI Code
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import javax.swing.JTextArea;
    import java.awt.BorderLayout;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class GraphicalUserInterface extends JFrame
                                        implements ActionListener {
        private final int HEIGHT = 10;
        private final int WIDTH = 40;
        private NetworkClient netClient;
        JTextField textField = new JTextField(WIDTH);
        JTextArea textArea = new JTextArea(HEIGHT, WIDTH);
        public static void main(String[] args) throws Exception {
       if (args.length != 1) {
           System.err.println("Usage: Client address");
           System.exit(1);
       NetworkClient nc = new NetworkClient(args[0]);
       new GraphicalUserInterface(nc);
        public GraphicalUserInterface(NetworkClient client) throws Exception {
       netClient = client;
       setLayout(new BorderLayout());
       add(textField, BorderLayout.NORTH);
       add(textArea, BorderLayout.CENTER);
       textField.addActionListener(this);
       pack();
       setVisible(true);
        public void actionPerformed(ActionEvent evt) {
       String text = textField.getText();
       if (textArea.getLineCount() > HEIGHT) {
           textArea.setText("");
       try {
           textArea.append(netClient.doEcho(text) + '\n');
            } catch(Exception e) {
           // ignore
       textField.setText("");
    }

    Some tips to help you get better help next time:
    XxXAncientXxX wrote:
    No not yet but I'm wanting to hand this in before the exam which is quite close, But you must realize that this is your urgency, not ours. None of the volunteers here like to be pressured, and so something marked ** urgent ** is actually often marked for flames and has the exact opposite effect: many here will simply refuse to answer anything labeled this way. Just something to remember next time.
    and to put it quite blunty our teacher anit great and really doesn't give examples or anything in fact we asked him something simple and he just said "oh I forgot" with that we ended up working it out ourselves.Oh, don't go there. We've heard this all the time, and regardless if it's true or not, your education is ultimately your responsibility. No one will accept your passing blame to someone else, period. Accept your own responsibility and get to work, show your effort, and possibly someone here will put in the effort to help you.
    My client works with the server I have thats for sure they problem is getting the GUI and the UserInterface to work with my client now these two were given to us by the teacher so I've been trying to work it our for sometime as I'm not good at java at all and just want to get a example and get it finished so I may continue on with my exams.What specific question do you have? Broad questions and claims of misunderstanding often get ignored. Specific questions are often answered. Requests for code are often flamed.
    The error resides in NetworkClient nc = new NetworkClient(args[0]); in both the UserInterface and in the GUI but I believe the problem is public NetworkClient()throws Exception with a little help of a friend so the error is the Constructor for my NetworkClient class, You appear to be calling a constructor that simply doesn't exist. I don't see a constructor in the NetworkClient class that accepts and array of Strings as a parameter. If there isn't one in another version of this class that wasn't posted, then you have one of two choices: either use a correct constructor (my bet) or create a new constructor for the class. Why are you trying to pass this parameter in the first place? Especially in the GUI program?
    Sorry if you believe its not urgent but it is to me.We believe that it's urgent to you, but you must believe that this means little to us. Sorry, but that's how it is.
    Good luck.

  • I have lost my " file, edit view, favurites, edit, help" toolbar, where is it please

    I am not technical. When I use internet explorer I have a line
    file, edit view, favourites, edit help
    & I used to have this in firefox, I don't anymore.
    What can I do to get it back please

    See [[menu bar is missing]].

  • GUI Help

    Hi Guys,
    I am struggling with the code below When I run this code I cannot c the scrollbar even when I change the color. Can anyone make this look good please and can any one also tell me how to make the quit button close the frame. Thanks
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Scrollbar;
    public class fr extends Frame
        final fr dis=this;
        public fr(){
            setTitle("Predator Prey Simulation");
            setBounds(1,1,800,550);
            setBackground(new Color(15,190,110));
            addWindowListener(
            new WindowAdapter(){
                public void windowClosing(WindowEvent e){
                    dis.dispose();
            class Act implements ActionListener
                public void actionPerformed(ActionEvent e){
                System.out.println(e);
            Scrollbar S = new Scrollbar(Scrollbar.HORIZONTAL,340,340,100,160);
            add(S);
            Button B=new Button("Start");
            B.setBounds(40,380,100,45);
            B.setBackground(Color.red);
            Act a = new Act();
            B.addActionListener(a);
            add(B);
            Button C=new Button("Stop");
            C.setBounds(200,380,100,45);
            C.setBackground(Color.blue);
            Act b = new Act();
            C.addActionListener(b);
            add(C);
            setLayout(null);
          TextField N = new TextField();
          N.setBounds(400,380,100,45);
          N.setEditable(true);
          add(N,"South");
            MenuBar menuBar = new MenuBar();
            Menu menu = new Menu("File");
                menuBar.add(menu);
                PopupMenu popupMenu=new PopupMenu("Run");
                menu.add(popupMenu);
            MenuItem anotherMenuItem=new MenuItem("Run Simulation");
                popupMenu.add(anotherMenuItem);
                  setMenuBar(menuBar);
                  MenuItem menuItem1=new MenuItem("Reset");
             menu.add(menuItem1);
                  MenuItem menuItem=new MenuItem("Quit");
                   menu.add(menuItem);
                   Label Z = new Label("Simulation Here");
                   Z.setBounds(95,45,42,40);
                   add(Z);
                   Label Q = new Label("Graph Here");
                   Q.setBounds(120,320,50,50);
                Label A = new Label();
                A.setBackground(new Color(25,90,10));
                A.setBounds(40,90,300,250);
                add(A);
                 Label X = new Label();
                 X.setBackground(new Color(4,50,60));
                X.setBounds(400,90,300,250);
                add(X);
                setResizable(true);
                setVisible(true);
      

    Hi! I posted the same question just the other day so I am glad to help.
    To make it exit the window the command is System.exit(0) so it could look like this.
    public void actionPerformed(ActionEvent evt) {
    System.exit(0);
    p.s. Maybe the scrollbar problem is with the size of the frame? Im not sure I was just looking through for Duke Dollar questions to answer an found u. If you need help DDs do work by the way.(lotsa people just make a nu account tho)
    Ty!

  • InDesign CS4 Help--Toolbar not showing, can't type or do anything.

    So I downloaded the trial version of Indesign CS4 on my computer, and when I opened it there was no toolbar, and I basically cannot type anything on it etc. . .
    I looked through some older posts on the forums and people suggested uninstalling it and then reinstalling.  My only fear is that since this is a trial version I thought that after uninstalling the program it wouldn't let me reinstall the program since I already had my free trial.
    Does anyone have any other suggest on how to fix this or know if uninstalling it will still let me use the trial version when I reinstall it.
    Thank you very much!

    kirklande wrote:
    This may sound stupid, but I couldn't find the TAB key?
    The Tab key is on the upper left side if the keyboard. That's the key you use for indenting a line in Word, or aligning columns in a free-typed table, or switching fields in a spreadsheet or your browser.
    Unfortunatley, that isn't likely to be the issue given the rest of your description. It sounds like you have a failed installation, and I wish I could tell you that you can try again, but I honestly don't know. For previous versions that was not possible without reformattinig the hard drive.
    There were some issues of this type that popped up on some older hardware that didn't support certain instructions. Those probelms were fixed, I think, with the 6.0.2 or 6.0.3 patch. You could try downloading the update and see if it will run.
    What OS are you using? Do you have a way, such as System Restore on Windows, to go back to before you installed the trial? If so that would be a possibility for trying to reinstall. make sure you disable any anti-virus or other security software before do a new installation, and though I haven't seen any problems personally installing CS4 with other stuff running, you might want to diable anything else that isn't strictly required for you system to operate. Lots of things, like the add-on browser toolbars adn instant messengers were know to interfere with CS3 installations, but I don't use that stuff on my systems so I have no experience one way or the other withthem in CS4.
    Peter

  • Smartform GUI Help

    Hi,
    I have a requirement like if i execute the print program for smartforms printer window will appear.in printer window if i choose print preview in next layout preview window print icon and menu is coming.
    I want to disable the print icon and print menu.
    And If print option choosen by user from printr window.I have to update some records to database. Is it possible?
    Thanks
    Regards,
    Nandha

    Using these strucutres 'SSFCTRLOP' 'SSFCRESOP' 'SSFCRESCL' 'SSFCOMPOP' you can do modifications to ur print icon, etc.., try to implement them.
    Regarding when u click the print window you can update the records also. generally when u print the smartform or download it in pdf form the 'nast' table is updated to know whether the file has been printed or not. like that you can do the same for updating various records.
    Reward points if its helps.
    Cheers,

  • Powershell Toolbar GUI "Docking" toolbar

    Hi Guys,
    I have created a powershell script, that is a Toolbar with quick links to programs and to run admin tasks for the network (IE remote assistance, MSTSC, remotely log off etc). I have worked out how to make the Toolbar on top of all other windows. But I was
    wondering if it was possible to make this toolbar 'Dock" to the top of screen? So when the toolbar is open and a window is maximized the top of the window is not cut off.
    I dont know if this possible in powershell or not
    Thank you

    It probably is, but I am not sure just yet on how to accomplish it (will need to research). In the meantime, you could set the TopMost property of the control to 'True' and this will ensure that it always remains in front of all other windows if you have
    other things being displayed.
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

Maybe you are looking for

  • A quad and a 22 inch cinema display

    The latest surprise in my journey to the quad is that the video card port doesn't support my old 22" cinema display. Is there any kind of adapter that works with this display? TIA, Jay

  • Template not reflecting the change.

    Hi All, I am working on Adobe output Designer5.5 version. I am now trying to modify an existing template. The changes done to the template design are not getting reflected in the printed output. Also additional lines which are not visible on the temp

  • Hi , I want help in copy control

    Hi,    I am creating each time consignment Issue(consider for many issue order) with reference through consignment fillup(consider from only one fillup order ) . I want only copy line Item which I don't copy in the previous Issue order while copy fro

  • Partition Transport Mechanismm...

    What could be the ideal & best Ways for Partition Transport Mechanism?? I.e. To move a partition onto other storage location or other table of same/different tablespace or onto different storage locationn... --> How should the partitions be designed

  • Flashplayer wont work and web sites are weird

    i have a really old mac from my moms work and i cant down load flashplayer is says somthing about damaged or incompleat