Extended Help on Gui

Dear Experts,
We are searching for a solution to extend the Help option for the user.
For example start the transaction NE21N for creat purchase order and press on one of the F buttons to get more help on the transaction to a file in the server ( PDF file  or AVI file for explanations).
Please advise if you have done it in your system.
Regards,
Moshe

Moshe,
Are you saying that the standard contextual online help is inadequate?  Normally, from any screen, when you select Help > Application help, you will be taken to the standard SAP Library entry for that transaction.  In most cases, this is adequate for the users.
IMG > General Settings > Variants to adjust help.  If there are no entries here, speak to your basis group.  SAP help files can be installed on a local server, and made available to users on your SAP system.
Best Regards,
DB49

Similar Messages

  • Extend Enterprise Manager GUI with a new widget

    Is it possible to extend the EM gui with a new widget on the home screen?
    I want to add some custom code where i can change some mbeans during runtime. I can always write a custom gui outside the EM that connects to it, but it would be nice to have all those things in the same place. Something similar to deploying a new Portlet.
    I know there is a MBean tree, but changing a process AqAdapter throttling, threads etc is not very user friendly.

    Mariana,
    If you have access to Service Market place , as part of  Work Manger 6.0 ->documentation there is document  with title "SAP-WM-6.0-EnhancementsGuide.pdf" which gives overview of how to do enhancement at  Agentry/Java/SAP layer.  Even though document is related to Work Manager but still  relevant good for Inventory Manager.  You will similar document available when new Inventory Manager product is released.
    Check out  documents  available on SCN.
    Agentry - Build your own Apps
    Customization Guide for Sales Manager 2.5
    Alternatively SAP also  offers MOB310  course if you want learn more about Mobile application enhancement.
    Thanks
    Manju

  • Help with GUI (calling one class from other class)

    Hi everybody,
    I am new at GUI and I need your help..
    I have a JPanel, named "holdAll", layout of which is set to BorderLayout. I have implemented all other JPanels in different class files. For example, I have TopPanel, LeftPanel, etc. as shown below
    LeftPanel myLeft = new LeftPanel();
    holdAll.add(myLeft, BorderLayout.WEST);
    RightPanel myRight = new RightPanel();
    holdAll.add(myRight, BorderLayout.EAST);
    TopPanel myTop = new TopPanel();
    holdAll.add(myTop, BorderLayout.NORTH);
    MiddlePanel myMiddle = new MiddlePanel();
    holdAll.add(myMiddle, BorderLayout.CENTER);
    BottomPanel myBottom = new BottomPanel();
    holdAll.add(myBottom, BorderLayout.SOUTH);
    That works well but I have difficulties in ActionListeners.. For example, in my TopPanel class I have the code below:
    public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnInsert) {
    int returnVal = fc.showOpenDialog(fc);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
    myImage newImage = new myImage(file);
    System.out.println(newImage.myHashCode());
    Here, if I have upload new image, then I have to update the listImage in the LeftPanel class.. But, I could not access the lstImage object in the LeftPanel class from the actionListener event in the TopPanel class.
    What should I do? Is my design poor?

    public class TopPanel extends JPanel implements ActionListener { //it doesn't allow "extends JPanel, Observable"
    JFileChooser fc;
    JButton btnInsert;
    JButton btnDelete;
    public TopPanel() {
    setLayout(new FlowLayout());
    setBorder(BorderFactory.createBevelBorder(1, Color.WHITE, Color.GRAY));
    btnInsert = new JButton("Insert");
    btnDelete = new JButton("Delete");
    JLabel myLabel = new JLabel(" Search : ");
    JTextField txtSearch = new JTextField();
    txtSearch.setColumns(20);
    JToolBar searchToolBar = new JToolBar();
    fc = new JFileChooser();
    btnInsert.addActionListener(this);
    searchToolBar.add(btnInsert);
    searchToolBar.add(btnDelete);
    searchToolBar.add(myLabel);
    searchToolBar.add(txtSearch);
    add(searchToolBar);
    public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnInsert) {
    int returnVal = fc.showOpenDialog(fc);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
    *//Here I want to send fc.GetName() to the JList in the LeftPanel*
    my LeftPanel class is below:
    public class LeftPanel extends JPanel{
    public LeftPanel(){
    this.setLayout(new BorderLayout());
    setBorder(BorderFactory.createBevelBorder(1, Color.WHITE, Color.GRAY));
    JPanel pnlButtons = new JPanel();
    JButton btnName = new JButton("Name");
    JButton btnSize = new JButton("Size");
    JButton btnDate = new JButton("Date");
    pnlButtons.add(btnName);
    pnlButtons.add(btnSize);
    pnlButtons.add(btnDate);
    pnlButtons.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    JPanel pnlImage = new JPanel();
    JList lstImage = new JList();
    lstImage.setVisible(true);
    pnlImage.add(new JScrollPane(lstImage));
    add(pnlButtons, BorderLayout.NORTH);
    add(pnlImage, BorderLayout.CENTER);
    Is there any simple way?

  • Need help in GUI

    I need help in coding for GUI
    I have created 4 classes which are car, car4sale,dealer and the GUI.
    in dealer class I have created a hash table and I want my data to be stored in this hash table can any one help me plz
    my GUI should be build on text field.
    But I don't know how can I link the GUI to the classes.
    this is the GUI but not complete.
    package Carsale;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    class Button extends JFrame implements ActionListener {
    private JButton button;
    private JTextField textField;
    public static void main(String[] args){
    Button frame = new Button();
    frame.setSize(400,300);
    frame.createGUI();
    frame.show();
    private void createGUI(){
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    Container window = getContentPane();
    window.setLayout(new FlowLayout());
    button = new JButton("VRN");
    window.add(button);
    button.addActionListener(this);
    textField = new JTextField(10);
    window.add(textField);
    public void actionPerformed(ActionEvent event) {
    textField.setText("Button clicked");
    }

    In the future, Swing related questions should be posted in the Swing forum.
    Your question does not have enough information to help you. We can't write a GUI for you. You need to write your own and then ask a specific question when you have a problem.
    Start by reading the [url http://java.sun.com/docs/books/tutorial/uiswing/TOC.html]Swing Tutorial which has lots of examples of creating simple GUIs.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.

  • I need help in GUI

    Hi every one..
    I need help in this class. I want to do a modification to the project AddGUI so that it will do subtraction, multiplication and division of two integre numbers, in addition to addition.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class GUIAddition extends JFrame {
       private String output;
       private int number1, number2, sum;
       private JLabel number1Label, number2Label, sumLabel;
       private JTextField number1TextField, number2TextField;
       private JButton addButton, exitButton;
       private JTextArea textArea;
       public GUIAddition()   {
       super("Sum of Two Integer Numbers");
    // Create an instance of inner class ActionEventHandler
       ActionEventHandler handler = new ActionEventHandler();
    // set up GUI
       Container container = getContentPane();
       container.setLayout( new FlowLayout() );
       // set up Label Fields and Text Fields for number1
       number1Label = new JLabel( "Number1" );
       number1TextField = new JTextField( 10 );
       number1TextField.addActionListener( handler );
       container.add( number1TextField );
       container.add( number1Label );
       // for number2
       number2Label = new JLabel( "Number2" );
       number2TextField = new JTextField( 10 );
       number2TextField.addActionListener( handler );
       container.add( number2TextField );
       container.add( number2Label );
       // for sum
       sumLabel = new JLabel( "Sum" );
       textArea = new JTextArea( 1,10 );  // only output, no addAction
       textArea.setEditable( false );
       container.add( textArea );
       container.add( sumLabel );
       // set up Add Button
       addButton = new JButton( "Add" );
       addButton.addActionListener( handler );
       container.add( addButton );
       // set up Exit Button
       exitButton = new JButton( "Exit" );
       exitButton.addActionListener( handler );
       container.add( exitButton );
      }// end constructor
    // Display The Sum of the Two Numbers in displayfield
       public void displayAddition() {
           textArea.setText(output);
      }// end display method
       public static void main( String args[] )   {
          GUIAddition window = new GUIAddition();
          window.setSize(500, 100);
          window.setVisible( true );
      }// end main
       private class ActionEventHandler implements ActionListener {
         public void actionPerformed(ActionEvent event) {
           // process Text Fields: number1 and number2 as well as Add Button events
           if (event.getSource() == number1TextField)
               number1 = Integer.parseInt(event.getActionCommand());
           else if (event.getSource() == number2TextField)
               number2 = Integer.parseInt(event.getActionCommand());
           else if (event.getSource() == addButton){
                   sum = number1 + number2;
                   output = "" + sum;
                   System.out.println("The Result of adding number1: " + number1 +
                   " and number2: " + number2 + " is: " + sum);
           // process Exit Button event
           else if (event.getSource() == exitButton) System.exit(0);
    // Display Information
           displayAddition();
         } // end method actionPerformed
       }// end inner class ActionEventHandler
    }  // end Class GUIAddition

    I try to do it for subtraction, but it didn't work correctly.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class GUIAddition extends JFrame {
       private String output;
       private int number1, number2, sum, sub;
       private JLabel number1Label, number2Label, sumLabel, subLabel;
       private JTextField number1TextField, number2TextField;
       private JButton addButton, subButton, exitButton;
       private JTextArea textArea;
       public GUIAddition()   {
       super("Sum of Two Integer Numbers");
    // Create an instance of inner class ActionEventHandler
       ActionEventHandler handler = new ActionEventHandler();
    // set up GUI
       Container container = getContentPane();
       container.setLayout( new FlowLayout() );
       // set up Label Fields and Text Fields for number1
       number1Label = new JLabel( "Number1" );
       number1TextField = new JTextField( 10 );
       number1TextField.addActionListener( handler );
       container.add( number1TextField );
       container.add( number1Label );
       // for number2
       number2Label = new JLabel( "Number2" );
       number2TextField = new JTextField( 10 );
       number2TextField.addActionListener( handler );
       container.add( number2TextField );
       container.add( number2Label );
       // for sum
       sumLabel = new JLabel( "Sum" );
       textArea = new JTextArea( 1,10 );  // only output, no addAction
       textArea.setEditable( false );
       container.add( textArea );
       container.add( sumLabel );
       // for sub
       subLabel = new JLabel( "Subtraction" );
       textArea = new JTextArea( 1,10 );  // only output, no addAction
       textArea.setEditable( false );
       container.add( textArea );
       container.add( subLabel );
       // set up Add Button
       addButton = new JButton( "Add" );
       addButton.addActionListener( handler );
       container.add( addButton );
       // set up Sub Button
        subButton = new JButton( "Subtraction" );
       subButton.addActionListener( handler );
       container.add( subButton );
       // set up Exit Button
       exitButton = new JButton( "Exit" );
       exitButton.addActionListener( handler );
       container.add( exitButton );
      }// end constructor
    // Display The Sum of the Two Numbers in displayfield
       public void displayAddition() {
           textArea.setText(output);
      }// end display method
       public static void main( String args[] )   {
          GUIAddition window = new GUIAddition();
          window.setSize(500, 100);
          window.setVisible( true );
      }// end main
       private class ActionEventHandler implements ActionListener {
         public void actionPerformed(ActionEvent event) {
           // process Text Fields: number1 and number2 as well as Add Button events
           if (event.getSource() == number1TextField)
               number1 = Integer.parseInt(event.getActionCommand());
           else if (event.getSource() == number2TextField)
               number2 = Integer.parseInt(event.getActionCommand());
           else if (event.getSource() == addButton){
                   sum = number1 + number2;
                   output = "" + sum;
                   System.out.println("The Result of adding number1: " + number1 +
                   " and number2: " + number2 + " is: " + sum);
           else if (event.getSource() == subButton){
                   sub = number1 - number2;
                   output = "" + sub;
                   System.out.println("The Result of subtraction number1: " + number1 +
                   " and number2: " + number2 + " is: " + sub);
           // process Exit Button event
           else if (event.getSource() == exitButton) System.exit(0);
    // Display Information
           displayAddition();
         } // end method actionPerformed
       }// end inner class ActionEventHandler
    }  // end Class GUIAddition

  • Help with GUI project.

    I need help with JcomboBox when I select the Exit in the File box it will open
    //inner class
    class exitListener implements ActionListener {
    I have the part of the parts of statement but I don't know how to assign the Keystoke. here is that part of the code
    filemenu.setMnemonic(KeyEvent.VK_X);Here is my code...
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class MyFrame extends JFrame {
         String[] file = { "New", "Open", "Exit" };//items for file
        String[] edit = { "Cut", "Copy", "Paste" };//items for edit
        JComboBox filemenu = new JComboBox();
        JComboBox editmenu = new JComboBox();
         public MyFrame(String title) {
              super(title);
              this.setSize(250, 250); //sets the size for the frame
              this.setLocation(200, 200);//location where frame is at
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              // setup contents
              makeComponents();
              initComponents();
              buildGUI();
              // display
              this.setVisible(true);
         private void makeComponents() {
              JPanel pane = new JPanel();
    //          file menu section
              filemenu = new JComboBox();
            JLabel fileLabel = new JLabel();
            pane.add(fileLabel);
            for (int i = 0; i < file.length; i++)
                 filemenu.addItem(file);
    pane.add(filemenu);
    add(pane);
    setVisible(true);
    //edit menu section
    editmenu = new JComboBox();
    JLabel editLabel = new JLabel();
    pane.add(editLabel);
    for (int i = 0; i < edit.length; i++)
         editmenu.addItem(edit[i]);
    pane.add(editmenu);
    add(pane);
    setVisible(true);
         private void initComponents() {
              filemenu.addActionListener(new exitListener());
         //inner class
    class exitListener implements ActionListener {
    public void actionPerformed(ActionEvent arg0) {
    int x = JOptionPane.showOptionDialog(MyFrame.this, "Exit Program?",
    "Exit Request", JOptionPane.YES_NO_OPTION,
    JOptionPane.QUESTION_MESSAGE, null, null,
    JOptionPane.NO_OPTION);
    if (x == JOptionPane.YES_OPTION) {
    MyFrame.this.dispose();
         private void buildGUI() {
              Container cont = this.getContentPane();// set gui components into the frame
              this.setLayout(new FlowLayout(FlowLayout.LEFT));// Comp are added to the frame
              cont.add(filemenu);
              cont.add(editmenu);
         // / inner classes
    public class ButtonFrame {
         public static void main(String[] args) {
              MyFrame f1 = new MyFrame("This is my Project for GUI");
    Thanks
    SandyR.

    One way is to
    1) pass a reference of the Window object to the USDListener class, and set a local Window variable say call it window, to this reference.
    2) Give the Window class a public method that returns a String and allows you to get the text from USDField. Same to allow you to set text on the euroField.
    3) Give the Listener class a Converter object.

  • Help whit GUI and code separeted files !

    Hi.. i have a problem...
    i wanna have two classes one that has the code.. and the other that as the GUI formating... so they have to comunicate..
    Example :
    Code Class
    public class EFClient   
        EFClientGUI gui;
        public EFClient(){ 
        public void dosomething(){
             gui = new EFClientGUI ();
             gui.Label1.getText(); ---> i get a nullpointexception here
    }GUI CLASS :
    public class EFClientGUI extends javax.swing.JFrame {
        public EFClient efClient;
        public EFClientGUI(String teste){      
            efClient=new EFClient();---> this will call the "code"
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
         try{
            efClient.dologin("Duarte","Rui");---- calls code class
         }catch(Exception ex){
             System.out.println(ex);
    }here a littel explanation :
    I run EFClientGUI ..... it calls EFClient... and designs.... tem i click the button and i trie to do the login.... the te login writes something to GUI...
    can someone help ?

    problem solved

  • Urgent! Need help in GUI!

    Hi, I am doing a small java project and I am expected to code all the GUI I need in just one class file. Can someone help me? My GUI consists of 2 JButtons, 2 JLabels and 1 JTextField. Also I need to have ActionListener for both of the buttons all in just 1 class file. Anyone please help. It is better if you can provide me with some sample coding to view

    That sounds like a very arbitrarily cooked-up requirement. Homework?
    Assuming your class needs to be a component itself, simply add the buttons, labels and fields into it, typically within the constructor.
    If you mean "one source file" then I would advise using an inner class as your ActionListener; you may even want two. You may like to use anonymous classes which, for instance, call methods in your outer class. All of these solutions will produce more than one class file from the single source file.
    If you really do mean "one class file" then you will need your outer class to implement ActionListener and determine from the getActionCommand() or getSource() methods which of the two buttons the event emanated from. It's a less clean way of going about it, but you get your single class file.
    No sample code - if you need further explanation of the above then just Google for the underlined terms.

  • Help with GUI program

    Writing a program that uses menu options of ADD, SUBTRACT, MULTIPLY, and DIVIDE.
    The user enters a number in a field labeled "Number 1" then enters a number in a field labeled "Number 2". The final field is labeled "Result"
    Each of the menu options has an ActionEvent.
    I'm having trouble with how to get the fields for Number 1 and Number 2 to display in the Result field when the user selects one of the menu options.
    Here is the code with an ActionEvent started for "Add" but not finished since I neeed some advice from this point on....
    Please disregard the other menu options, at this point I am just working on the math portion...
    Cheers!
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Brown7 extends JFrame implements ActionListener
    public static final int WIDTH = 400;
    public static final int HEIGHT = 200;
    private JTextField inputField, inputsecondField, resultField;
    private double sum = 0;
    private double difference = 0;
    private double product = 0;
    private double quotient = 0;
    public Brown7()
    setSize (WIDTH, HEIGHT);
    addWindowListener(new WindowDestroyer());
    setTitle ("Menu Demo");
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());
    JButton sumbutton = new JButton("Add");
    sumbutton.addActionListener(this);
    buttonPanel.add(sumbutton);
    JButton subbutton = new JButton("Subtraction");
    subbutton.addActionListener(this);
    buttonPanel.add(subbutton);
    JButton multbutton = new JButton("Multiply");
    multbutton.addActionListener(this);
    buttonPanel.add(multbutton);
    JButton divbutton = new JButton("Divide");
    divbutton.addActionListener(this);
    buttonPanel.add(divbutton);
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new FlowLayout());
    JLabel nameLabel = new JLabel("Number 1");
    infoPanel.add(nameLabel);
    inputField = new JTextField("", 3);
    infoPanel.add(inputField);
    JLabel secondnameLabel = new JLabel("Number 2");
    infoPanel.add(secondnameLabel);
    inputsecondField = new JTextField("", 3);
    infoPanel.add(inputsecondField);
    JLabel resultLabel = new JLabel("Result");
    infoPanel.add(resultLabel);
    resultField = new JTextField("", 5);
    infoPanel.add(resultField);
    contentPane.add(infoPanel);
    JMenuBar mBar = new JMenuBar();
    setJMenuBar(mBar);
    JMenu operationsMenu = new JMenu("Operations");
    mBar.add(operationsMenu);
    JMenuItem o;
    o = new JMenuItem("Add");
    o.addActionListener(this);
    operationsMenu.add(o);
    o = new JMenuItem("Subtract");
    o.addActionListener(this);
    operationsMenu.add(o);
    o = new JMenuItem("Multiply");
    o.addActionListener(this);
    operationsMenu.add(o);
    o = new JMenuItem("Divide");
    o.addActionListener(this);
    operationsMenu.add(o);
    JMenu viewMenu = new JMenu("View");
    mBar.add(viewMenu);
    JMenuItem v;
    v = new JMenuItem("Metal");
    v.addActionListener(this);
    viewMenu.add(v);
    v = new JMenuItem("Motif");
    v.addActionListener(this);
    viewMenu.add(v);
    v = new JMenuItem("Windows");
    v.addActionListener(this);
    viewMenu.add(v);
    JMenu exitMenu = new JMenu("Exit");
    mBar.add(exitMenu);
    JMenuItem e;
    e = new JMenuItem("Close");
    e.addActionListener(this);
    exitMenu.add(e);
    public void actionPerformed(ActionEvent e)
    if (e.getActionCommand().equals("Close"))
    System.exit(0);
    else if (e.getActionCommand().equals("Add"))
    else
    System.out.println("Error in Brown7 interface.");
    public static void main(String[] args)
    Brown7 gui = new Brown7();
    gui.setVisible(true);

    You can use a JOptionPane for the textfield input. Here I used a DocumentFilter (new in JDK1.4). It allows only specified characters to be entered and beeps for illegal characters. If you still want a message dialog you can add it in the document filter class with (or in place of) the Toolkit..beep call.
    I also changed the variable result to a double and added a NumberFormat to allow formatting to only one decimal place for fractions (as a result of division) in resultField.
    I gave a choice of YES_NO vs. YES_NO_CANCEL options in the exit dialog.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.NumberFormat;    // new
    import javax.swing.text.*;        // new
    public class BrownTest extends JFrame implements ActionListener
        public static final int WIDTH = 400;
        public static final int HEIGHT = 200;
        private JTextField inputField, inputsecondField, resultField;
        private double sum = 0;
        private double difference = 0;
        private double product = 0;
        private double quotient = 0;
        NumberFormat nf;
        JFrame frame = this;
        public BrownTest()
            nf = NumberFormat.getInstance();
            nf.setMaximumFractionDigits(1);
            setSize (WIDTH, HEIGHT);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setTitle ("Menu Demo");
            Container contentPane = getContentPane();
            contentPane.setLayout(new BorderLayout());
            JPanel buttonPanel = new JPanel();
            buttonPanel.setLayout(new FlowLayout());
            JButton sumbutton = new JButton("Add");
            sumbutton.addActionListener(this);
            buttonPanel.add(sumbutton);
            JButton subbutton = new JButton("Subtract");
            subbutton.addActionListener(this);
            buttonPanel.add(subbutton);
            JButton multbutton = new JButton("Multiply");
            multbutton.addActionListener(this);
            buttonPanel.add(multbutton);
            JButton divbutton = new JButton("Divide");
            divbutton.addActionListener(this);
            buttonPanel.add(divbutton);
            contentPane.add(buttonPanel, BorderLayout.SOUTH);
            JPanel infoPanel = new JPanel();
            infoPanel.setLayout(new FlowLayout());
            JLabel nameLabel = new JLabel("Number 1");
            infoPanel.add(nameLabel);
            inputField = new JTextField("", 3);
            infoPanel.add(inputField);
            JLabel secondnameLabel = new JLabel("Number 2");
            infoPanel.add(secondnameLabel);
            inputsecondField = new JTextField("", 3);
            infoPanel.add(inputsecondField);
            JLabel resultLabel = new JLabel("Result");
            infoPanel.add(resultLabel);
            resultField = new JTextField("", 5);
            infoPanel.add(resultField);
            // set document filter on textfield documents
            String integerDomain = "-.0123456789";
            FieldNumberFilter filter = new FieldNumberFilter(integerDomain);
            AbstractDocument doc = (AbstractDocument)inputField.getDocument();
            doc.setDocumentFilter(filter);
            doc = (AbstractDocument)inputsecondField.getDocument();
            doc.setDocumentFilter(filter);
            doc = (AbstractDocument)resultField.getDocument();
            doc.setDocumentFilter(filter);
            contentPane.add(infoPanel);
            JMenuBar mBar = new JMenuBar();
            setJMenuBar(mBar);
            JMenu operationsMenu = new JMenu("Operations");
            mBar.add(operationsMenu);
            JMenuItem o;
            o = new JMenuItem("Add");
            o.addActionListener(this);
            operationsMenu.add(o);
            o = new JMenuItem("Subtract");
            o.addActionListener(this);
            operationsMenu.add(o);
            o = new JMenuItem("Multiply");
            o.addActionListener(this);
            operationsMenu.add(o);
            o = new JMenuItem("Divide");
            o.addActionListener(this);
            operationsMenu.add(o);
            JMenu viewMenu = new JMenu("View");
            mBar.add(viewMenu);
            ViewMenuListener viewMenuListener = new ViewMenuListener();
            JMenuItem v;
            v = new JMenuItem("Metal");
            v.addActionListener(viewMenuListener);
            viewMenu.add(v);
            v = new JMenuItem("Motif");
            v.addActionListener(viewMenuListener);
            viewMenu.add(v);
            v = new JMenuItem("Windows");
            v.addActionListener(viewMenuListener);
            viewMenu.add(v);
            JMenu exitMenu = new JMenu("Exit");
            mBar.add(exitMenu);
            JMenuItem e;
            e = new JMenuItem("Close");
            e.addActionListener(this);
            exitMenu.add(e);
         * Listener for the Operations and Close menu items
        public void actionPerformed(ActionEvent e)
            String ac = e.getActionCommand();
            if (ac.equals("Close"))
                String message = "Are you sure you want to exit this program?";
                int returnVal = JOptionPane.showConfirmDialog(frame,
                                                              message,
                                                              "Exit Dialog",
                // either this */                             JOptionPane.YES_NO_OPTION,
                /* or this */                                 JOptionPane.YES_NO_CANCEL_OPTION,
                                                              JOptionPane.QUESTION_MESSAGE);
                if(returnVal == JOptionPane.CANCEL_OPTION ||
                   returnVal == JOptionPane.CLOSED_OPTION)
                    return;
                if(returnVal == JOptionPane.YES_OPTION)
                    System.exit(0);
                if(returnVal == JOptionPane.NO_OPTION);
                    frame.dispose();
            // read entered data
            String one = inputField.getText();
            String two = inputsecondField.getText();
            // if no entry, return
            if(one.equals("") || two.equals(""))
                return;
            // attempt to parse data
            double first, second;
            try
                first  = Double.parseDouble(one);
                second = Double.parseDouble(two);
            catch(NumberFormatException nfe)
                System.out.println(nfe.getMessage());
                return;
            // now we have good data, do calculations
            double result = 0;
            if (ac.equals("Add"))
                result = first + second;
            else if(ac.equals("Subtract"))
                result = first - second;
            else if(ac.equals("Multiply"))
                result = first * second;
            else if(ac.equals("Divide"))
                result = first / second;
            else
                System.out.println("Error in Brown7 interface.");
            resultField.setText(nf.format(result));
         * Listener for the View menu items
        private class ViewMenuListener implements ActionListener
            UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
            public void actionPerformed(ActionEvent e)
                JMenuItem item = (JMenuItem)e.getSource();
                String ac = item.getActionCommand();
                String name = null;
                for(int i = 0; i < info.length; i++)
                    if(info.getName().indexOf(ac) != -1)
    name = info[i].getClassName();
    if(name == null)
    return;
    try
    UIManager.setLookAndFeel(name);
    catch(ClassNotFoundException cnfe)
    System.out.println(cnfe.getMessage());
    catch(InstantiationException ie)
    System.out.println(ie.getMessage());
    catch(IllegalAccessException iae)
    System.out.println(iae.getMessage());
    catch(UnsupportedLookAndFeelException ulafe)
    System.out.println(ulafe.getMessage());
    SwingUtilities.updateComponentTreeUI(BrownTest.this);
    public static void main(String[] args)
    BrownTest gui = new BrownTest();
    gui.setVisible(true);
    * Document filter for input validation in textfields
    class FieldNumberFilter extends DocumentFilter
    String allowables;
    public FieldNumberFilter(String legalCharacters) {
    allowables = legalCharacters;
    public void insertString(DocumentFilter.FilterBypass fb,
    int offset,
    String str,
    AttributeSet attr) throws BadLocationException {
    replace(fb, offset, 0, str, attr);
    public void replace(DocumentFilter.FilterBypass fb,
    int offset,
    int length,
    String str,
    AttributeSet attrs) throws BadLocationException {
    char[] source = str.toCharArray();
    char[] result = new char[source.length];
    int j = 0;
    for(int i = 0; i < result.length; i++)
    if(allowables.indexOf(source[i]) != -1)
    result[j++] = source[i];
    else
    Toolkit.getDefaultToolkit().beep();
    fb.replace(offset, length, new String(result, 0, j), attrs);

  • Help on GUI calculator

    I'm making a calculator on netbeans and so far i have been able to get the interface and an the function of the number buttons. Also I got the plus button to work but it does not work after using it once. I have tried, but im stuck and can't firgure out what to do next plz help. This is the code i have:
    * Calulator.java
    * Created on April 3, 2008, 11:30 AM
    package me;
    * @author period4
    public class Calulator extends javax.swing.JFrame {
    /** Creates new form Calulator */
    public Calulator() {
    initComponents();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
    jButton17 = new javax.swing.JButton();
    Input = new javax.swing.JTextField();
    Button1 = new javax.swing.JButton();
    Button4 = new javax.swing.JButton();
    Button7 = new javax.swing.JButton();
    Button2 = new javax.swing.JButton();
    Button5 = new javax.swing.JButton();
    Button8 = new javax.swing.JButton();
    Button3 = new javax.swing.JButton();
    Button6 = new javax.swing.JButton();
    Button9 = new javax.swing.JButton();
    Button0 = new javax.swing.JButton();
    ButtonPlus = new javax.swing.JButton();
    ButtonMinus = new javax.swing.JButton();
    ButtonMultiply = new javax.swing.JButton();
    ButtonDecimal = new javax.swing.JButton();
    ButtonPositiveNegative = new javax.swing.JButton();
    ButtonDivide = new javax.swing.JButton();
    ButtonEquals = new javax.swing.JButton();
    jButton17.setText("jButton17");
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Calculator");
    Button1.setText("1");
    Button1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    Button1ActionPerformed(evt);
    Button4.setText("4");
    Button4.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    Button4ActionPerformed(evt);
    Button7.setText("7");
    Button7.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    Button7ActionPerformed(evt);
    Button2.setText("2");
    Button2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    Button2ActionPerformed(evt);
    Button5.setText("5");
    Button5.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    Button5ActionPerformed(evt);
    Button8.setText("8");
    Button8.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    Button8ActionPerformed(evt);
    Button3.setText("3");
    Button3.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    Button3ActionPerformed(evt);
    Button6.setText("6");
    Button6.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    Button6ActionPerformed(evt);
    Button9.setText("9");
    Button9.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    Button9ActionPerformed(evt);
    Button0.setText("0");
    Button0.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    Button0ActionPerformed(evt);
    ButtonPlus.setText("+");
    ButtonPlus.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    ButtonPlusActionPerformed(evt);
    ButtonMinus.setText("-");
    ButtonMultiply.setText("*");
    ButtonDecimal.setText(".");
    ButtonDecimal.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    ButtonDecimalActionPerformed(evt);
    ButtonPositiveNegative.setText("+/-");
    ButtonDivide.setText("/");
    ButtonEquals.setText("=");
    ButtonEquals.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    ButtonEqualsActionPerformed(evt);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(Input, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
    .addComponent(Button7, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
    .addComponent(Button4, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
    .addComponent(Button1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
    .addComponent(Button2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(Button5, 0, 0, Short.MAX_VALUE)
    .addComponent(Button8, 0, 0, Short.MAX_VALUE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addComponent(Button3)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(ButtonPlus))
    .addGroup(layout.createSequentialGroup()
    .addComponent(Button6)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(ButtonMinus))
    .addGroup(layout.createSequentialGroup()
    .addComponent(Button9)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(ButtonMultiply))))
    .addGroup(layout.createSequentialGroup()
    .addComponent(ButtonDecimal)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(Button0)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(ButtonPositiveNegative)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(ButtonDivide)))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(ButtonEquals)))
    .addContainerGap())
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(22, 22, 22)
    .addComponent(Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(15, 15, 15)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(Button1)
    .addComponent(Button2)
    .addComponent(Button3)
    .addComponent(ButtonPlus))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(Button4)
    .addComponent(Button5)
    .addComponent(Button6)
    .addComponent(ButtonMinus))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(Button7)
    .addComponent(Button8)
    .addComponent(Button9)
    .addComponent(ButtonMultiply))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(ButtonDecimal)
    .addComponent(Button0)
    .addComponent(ButtonPositiveNegative)
    .addComponent(ButtonDivide)))
    .addGroup(layout.createSequentialGroup()
    .addGap(17, 17, 17)
    .addComponent(ButtonEquals, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addContainerGap(44, Short.MAX_VALUE))
    pack();
    }// </editor-fold>//GEN-END:initComponents
    private void ButtonEqualsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonEqualsActionPerformed
    if(operator.equals("+"))
    solution = Double.parseDouble(integer1) + Double.parseDouble(integer2);
    Input.setText(Double.toString(solution));
    operator = null;
    integer1 = "";
    integer2 = "";
    //Input.setText(Double.toString(solution));
    solution = 0;
    // TODO add your handling code here:
    }//GEN-LAST:event_ButtonEqualsActionPerformed
    private void ButtonPlusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonPlusActionPerformed
    operator = "+";
    // TODO add your handling code here:
    }//GEN-LAST:event_ButtonPlusActionPerformed
    private void ButtonDecimalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonDecimalActionPerformed
    Input.setText(".");// TODO add your handling code here:
    }//GEN-LAST:event_ButtonDecimalActionPerformed
    private void Button0ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button0ActionPerformed
    if(operator == null)
    integer1 = integer1.concat("0");
    Input.setText(integer1);
    else
    integer2 = integer2.concat("0");
    Input.setText(integer2);
    // TODO add your handling code here:
    }//GEN-LAST:event_Button0ActionPerformed
    private void Button9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button9ActionPerformed
    if(operator == null)
    integer1 = integer1.concat("9");
    Input.setText(integer1);
    else
    integer2 = integer2.concat("9");
    Input.setText(integer2);
    // TODO add your handling code here:
    }//GEN-LAST:event_Button9ActionPerformed
    private void Button6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button6ActionPerformed
    if(operator == null)
    integer1 = integer1.concat("6");
    Input.setText(integer1);
    else
    integer2 = integer2.concat("6");
    Input.setText(integer2);
    // TODO add your handling code here:
    }//GEN-LAST:event_Button6ActionPerformed
    private void Button3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button3ActionPerformed
    if(operator == null)
    integer1 = integer1.concat("3");
    Input.setText(integer1);
    else
    integer2 = integer2.concat("3");
    Input.setText(integer2);
    // TODO add your handling code here:
    }//GEN-LAST:event_Button3ActionPerformed
    private void Button8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button8ActionPerformed
    if(operator == null)
    integer1 = integer1.concat("8");
    Input.setText(integer1);
    else
    integer2 = integer2.concat("8");
    Input.setText(integer2);
    // TODO add your handling code here:
    }//GEN-LAST:event_Button8ActionPerformed
    private void Button5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button5ActionPerformed
    if(operator == null)
    integer1 = integer1.concat("5");
    Input.setText(integer1);
    else
    integer2 = integer2.concat("5");
    Input.setText(integer2);
    // TODO and your handling code here:
    }//GEN-LAST:event_Button5ActionPerformed
    private void Button7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button7ActionPerformed
    if(operator == null)
    integer1 = integer1.concat("7");
    Input.setText(integer1);
    else
    integer2 = integer2.concat("7");
    Input.setText(integer2);
    // TODO add your handling code here:
    }//GEN-LAST:event_Button7ActionPerformed
    private void Button4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button4ActionPerformed
    if(operator == null)
    integer1 = integer1.concat("4");
    Input.setText(integer1);
    else
    integer2 = integer2.concat("4");
    Input.setText(integer2);
    // TODO add your handling code here:
    }//GEN-LAST:event_Button4ActionPerformed
    private void Button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button1ActionPerformed
    if(operator == null)
    integer1 = integer1.concat("1");
    Input.setText(integer1);
    else
    integer2 = integer2.concat("1");
    Input.setText(integer2);
    // TODO add your handling code here:
    }//GEN-LAST:event_Button1ActionPerformed
    private void Button2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button2ActionPerformed
    if(operator == null)
    integer1 = integer1.concat("2");
    Input.setText(integer1);
    else
    integer2 = integer2.concat("2");
    Input.setText(integer2);
    // TODO add your handling code here:
    }//GEN-LAST:event_Button2ActionPerformed
    * @param args the command line arguments
    double solution;
    String integer1 = "";
    String integer2 = "";
    String operator;
    public static void main(String args[])
    java.awt.EventQueue.invokeLater(new Runnable()
    public void run()
    new Calulator().setVisible(true);
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Button0;
    private javax.swing.JButton Button1;
    private javax.swing.JButton Button2;
    private javax.swing.JButton Button3;
    private javax.swing.JButton Button4;
    private javax.swing.JButton Button5;
    private javax.swing.JButton Button6;
    private javax.swing.JButton Button7;
    private javax.swing.JButton Button8;
    private javax.swing.JButton Button9;
    private javax.swing.JButton ButtonDecimal;
    private javax.swing.JButton ButtonDivide;
    private javax.swing.JButton ButtonEquals;
    private javax.swing.JButton ButtonMinus;
    private javax.swing.JButton ButtonMultiply;
    private javax.swing.JButton ButtonPlus;
    private javax.swing.JButton ButtonPositiveNegative;
    private javax.swing.JTextField Input;
    private javax.swing.JButton jButton17;
    // End of variables declaration//GEN-END:variables
    }

    Yeah. Seriously. I don't think anybody wants to wade through a whole bunch of IDE generated crap that you didn't bother to format with code tags.
    I know I don't.
    So maybe post some formatted relevent code (10 lines or less).

  • F4 help for GUI

    Hi,
    I need to store a file on the presentation server. For this purpose, I have an icon on the GUI , to download the file from the output screen to the PS.
    I have used the FM 'GUI_DOWNLOAD' for this.
    I need an F4 help, so that when i click on the download icon the menu bar, a popup should come asking for the path on the PS where i want to store the file.
    Can anyone tell me which FM should I call for the popup?

    At the AT SELECTION_SCREEN ON VALUE-REQUEST FOR p_path and code your value help.
      DATA:
        zz_folder   TYPE string.
      CALL METHOD cl_gui_frontend_services=>directory_browse
         CHANGING
           selected_folder = zz_folder
         EXCEPTIONS
           OTHERS          = 0.
    p_path = zz_folder.
    <b>file from application server</b>
    1. F4_DXFILENAME_TOPRECURSION
    This is the FM.
    Reward points,if found useful

  • Need some help with GUI development

    Hi ppl.. I am new to labview and I am currently involved in a testing equipment development. I need some help. firstly I need to know if multi-screen GUI (with icons and stuff)is possible in Labview. Secondly I need to interface the measurements to a database. Would it be possible to create just small executable to perform the measurement part alone and do the rest of database operation using VB. (or would it be advisable to do the whole lot in labview)
    the final sft should look something like this
    screen1 :setup screen... interface with database
    screen2 :actual test and test results
    screen3 :log file creation
    measurement is via daq board and i also need to send some control signals and set up TCP/IP for data transfer.

    Hello.
    I am not completely sure what you mean by "multi-screen", but I am pretty sure that doing the user interface using a tab control will work for you. I have attached an example VI which is a state machine (which in LabVIEW you do with a case structure inside a while loop). Notice how the configuration controls are in the first page of the tab control, associated with state 0 of the state machine, but in the block diagram, they are actually used in state 1 of the state machine. Instead of writing a very long description, I will let you take a look at the code (which I saved in LV 7.0 version). Let me know if you have questions or comments
    Attachments:
    MultiScreenStateMachineExample.vi ‏50 KB

  • Need help with GUI lay out HELP PLEASE

    hi iam trying to design this GUI for an assignment i cant seem to post pictures so i uploaded the picture of how its suppose to look
    http://ca.geocities.com/shamtu4life2000/layout.jpg
    i believe i got the code down correct but the layout is messed up also my teacher specified that the open color area be set at 400x300 i believe i did that correct my problem is the layout i get is jumbled and i dont know if i got the open area panel set correctly
    this is my code
    import java.awt.*;
    import javax.swing.*;
    public class colorFrame extends JFrame{
         public colorFrame(){
              //get the content pane of the frame
              //JPanel radio = JPanel();
              Container container = getContentPane();
              //set flowlayout
              container.setLayout(new FlowLayout());
              //create panel p1 set grid
              JPanel p1 = new JPanel();
              p1.setLayout(new GridLayout(1,3)) ;
              //add check boxes
              p1.add(new JCheckBox("RED"));
              p1.add(new JCheckBox("GREEN"));
              p1.add(new JCheckBox("BLUE"));
              //Create panel p2 set grid
              JPanel p2 = new JPanel();
              p2.setLayout (new GridLayout(1,3));
              //Add radio buttons
              p2.add(new JRadioButton("Light"));
              p2.add(new JRadioButton("Normal"));
              p2.add(new JRadioButton("Dark"));
              //Create panel p3
              JPanel p3 = new JPanel();
              p3.setLayout (new GridLayout());
              //add button
              p3.add(new JButton("Show"));
              //Create panel p4
              JPanel p4 = new JPanel();
              p4.setLayout (new GridLayout());
              Dimension d = new Dimension(400,300);
              p4.setPreferredSize(d);
              //Add panels to frame
              container.add(p1, BorderLayout.SOUTH);
              container.add(p2, BorderLayout.SOUTH);
              container.add(p3, BorderLayout.EAST);
              container.add(p4, BorderLayout.NORTH);
         //Main Method
         public static void main(String[] args){
              colorFrame frame = new colorFrame();
              frame.setTitle("Color Frame");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(500,400);
              frame.setVisible(true);
    }if any one got anyideas please let me know below i posted the assignment as background information thanks
    The GUI has a JPanel in the center region that displays different colors. All of the other components (3 JCheckboxes, 3 JRadioButtons, and one JButton) are on a JPanel in the south region of the JFrame. We haven�t yet learned how to make a GUI do anything in response to user generated events, such as mouse clicks. For this question, we just want to practice controlling the appearance of the GUI using layout managers.
    In the constructor of your ColorFrame class, create three JCheckbox objects, three JRadioButtons, and one JButton. All you need to know about these classes is that each
    one has a constructor that takes one String argument:
    new JCheckbox(�Red�)
    new JRadioButton(�Light�)
    new JButton(�Show�)
    We want to use JPanels and layout managers to control the appearance of the GUI. We want the three JCheckboxes to remain together, so we put them on a JPanel. Similarly for the three JRadioButtons � put them on another JPanel. We want the JButton to retain its preferred size � not to grow to fill an entire region of the GUI --so put it on another JPanel.  These JPanels should use FlowLayout.
    We want to put all of these JPanels in the south region of the JFrame, but if we just add them to the frame, one will go on top of the other and we�ll only see the last one that was added. Instead, use one or more additional JPanels with GridLayout to hold the first set of JPanels, then add the JPanels holding all the other components to the JFrame.
    You also want to create another instance of JPanel to add to the center region of the JFrame. Unlike the other JPanels, this one won�t hold other components; it will display different colors. (You don�t have to implement this color display.) When you pack the JFrame, the other JPanels will become large enough to hold the other components they contain, but since this one holds no components, it would shrink to zero by default. To prevent this, you should set its preferred size to some non-zero value, say 400 x 300 pixels.
    Your class should have a main method that calls the constructor tocreate an instance of this class, sets its size using pack, sets its default close operation, and makes it visible.

    You have set the container layout to FlowLayout, but you then try to place panels using the BorderLayout constants, you should use BorderLayout on the container.

  • PLease help! GUI and Data Structure

    Hey guys,
    It's for my school project.
    I have to write codes for GUI program for a order form.
    I'm pretty much done with layout and stuff, but I couldn't figure out how to give some regulation(?) on some of the field.
    For instantce, I have to regulate a user to type only two letter abbreviation on state(address) field and the Zip field has to be either 5 digit form or XXXXX-XXXX.
    I Also have to include code to filter the user input and display error message if they enter wrong information.
    Second, how to use actoinevent stuff?
    There are three product type: a,b, and c. If "a" be chosen, then the product name associating the "a" product has to be shown on the product name field(I used ComboBox), and the price for that product(for instance a-1) has to be shown on the price field.
    Third, It sounds stupid question, but how to display current date on the java program using API?
    Fourth, I have to load some of the order from external files(maybe text files) and display into the screen.
    Here is the code
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.ListSelectionEvent;
    class orderFormGUI extends JFrame {
         private JButton bSave, bExit, bLoad;
         private JLabel labelTitle;
         private JTextField fieldFName, fieldLName, fieldStreet, fieldCity,
                   fieldState, fieldZip;
         private JLabel labelFName, labelLName, labelStreet, labelCity, labelState,
                   labelZip;
         private String[] st = { "CA", "TX", "OR", "UT", "NM", "NY", "NY", "GA",
                   "IL", "TN", "MN", "WY" };
         private JComboBox comboPType, comboPName;
         private JLabel labelComboPType, labelComboPName;
         private String[] ct = { "Copmuter", "Printer", "Monitor" };
         private String[] cn = { "CMP1100", "CMP1500" };
         private String[] pn = { "PR500", "PR1000" };
         private String[] mn = { "D4000", "D8000" };
         private String[] x;
         private JTextField fieldTotalPrice, fieldProductPrice;
         private JLabel labelTotalPrice, labelProductPrice;
         private JTextField filedQty;
         private JLabel labelQty;
         private JTextField fieldOrderDate, fieldDeliveryDate;
         private JComboBox comboDeliveryOptions;
         private String[] dO = { "5 Days", "10 Days" };
         private JLabel labelOrderDate, labelDeliveryOptions, labelDeliveryDate;
         private ArrayList orderArray;
         private DefaultListModel lmodel;
         public void initComponents() {
              bSave.setActionCommand("Save");
              bLoad.setActionCommand("Load");
              bExit.setActionCommand("Exit");
              bSave.addActionListener(new ButtonListener());
              bLoad.addActionListener(new ButtonListener());
              bExit.addActionListener(new ButtonListener());
         public void ClearFields() {
              // Set all text fields to blank
              fieldFName.setText("");
              fieldLName.setText("");
              fieldStreet.setText("");
              fieldCity.setText("");
              fieldState.setText("");
              fieldZip.setText("");
         public orderFormGUI() {
              orderArray = new ArrayList();
              bSave = new JButton("Save");
              bLoad = new JButton("Load");
              bExit = new JButton("Exit");
              // set up labels and field size for GUI
              labelTitle = new JLabel("Order Form");
              fieldFName = new JTextField("", 30);
              labelFName = new JLabel("First Name: ");
              fieldLName = new JTextField("", 30);
              labelLName = new JLabel("Last Name: ");
              fieldStreet = new JTextField("", 12);
              labelStreet = new JLabel("Street: ");
              fieldCity = new JTextField("", 12);
              labelCity = new JLabel("City: ");
              fieldState = new JTextField("", 2);
              labelState = new JLabel("State: ");
              fieldZip = new JTextField("", 9);
              labelZip = new JLabel("Zip Code: ");
              comboPType = new JComboBox(ct);
              chooseProductName();
              labelComboPType = new JLabel("Product Type");
              comboPName = new JComboBox();
              labelComboPName = new JLabel("Product Name");
              fieldProductPrice = new JTextField("");
              labelProductPrice = new JLabel("Product Price: ");
              fieldTotalPrice = new JTextField("", 12);
              labelTotalPrice = new JLabel("Total Price: ");
              filedQty = new JTextField("", 12);
              labelQty = new JLabel("Quantity: ");
              fieldOrderDate = new JTextField("", 12);
              labelOrderDate = new JLabel("Order Date: ");
              comboDeliveryOptions = new JComboBox(dO);
              labelDeliveryOptions = new JLabel("Delivery Options: ");
              fieldDeliveryDate = new JTextField("", 12);
              labelDeliveryDate = new JLabel("Delivery Date: ");
              TextFieldHandler handler = new TextFieldHandler();
              fieldState.addActionListener(handler);
              // Construct GUI and set layout
              JPanel mine = new JPanel();
              mine.setLayout(null);
              mine.add(labelTitle);
              labelTitle.setBounds(150, 30, 100, 15);
              mine.add(fieldFName);
              fieldFName.setBounds(88, 80, 220, 21);
              mine.add(labelFName);
              labelFName.setBounds(16, 80, 134, 21);
              mine.add(fieldLName);
              fieldLName.setBounds(88, 110, 220, 21);
              mine.add(labelLName);
              labelLName.setBounds(16, 110, 134, 21);
              mine.add(fieldStreet);
              fieldStreet.setBounds(88, 150, 220, 21);
              mine.add(labelStreet);
              labelStreet.setBounds(16, 150, 134, 21);
              mine.add(fieldCity);
              fieldCity.setBounds(88, 180, 220, 21);
              mine.add(labelCity);
              labelCity.setBounds(16, 180, 134, 21);
              mine.add(fieldState);
              fieldState.setBounds(88, 210, 220, 21);
              mine.add(labelState);
              labelState.setBounds(16, 210, 134, 21);
              mine.add(fieldZip);
              fieldZip.setBounds(88, 240, 220, 21);
              mine.add(labelZip);
              labelZip.setBounds(16, 240, 134, 21);
              mine.add(comboPType);
              comboPType.setBounds(120, 280, 220, 21);
              mine.add(labelComboPType);
              labelComboPType.setBounds(16, 280, 134, 21);
              mine.add(comboPName);
              comboPName.setBounds(120,310, 220, 21);
              mine.add(labelComboPName);
              labelComboPName.setBounds(16, 310, 134, 21);
              mine.add(fieldProductPrice);
              fieldProductPrice.setBounds(120, 340, 220, 21);
              fieldProductPrice.setEditable(false);
              mine.add(labelProductPrice);
              labelProductPrice.setBounds(16, 340, 134, 21);
              mine.add(filedQty);
              filedQty.setBounds(120, 370, 220, 21);
              mine.add(labelQty);
              labelQty.setBounds(16, 370, 134, 21);
              mine.add(fieldOrderDate);
              fieldOrderDate.setBounds(120, 430, 220, 21);
              fieldOrderDate.setEditable(false);
              mine.add(labelOrderDate);
              labelOrderDate.setBounds(16, 430, 134, 21);
              mine.add(comboDeliveryOptions);
              comboDeliveryOptions.setBounds(120, 460, 220, 21);
              mine.add(labelDeliveryOptions);
              labelDeliveryOptions.setBounds(16, 460, 134, 21);
              mine.add(fieldDeliveryDate);
              fieldDeliveryDate.setBounds(120, 490, 220, 21);
              fieldDeliveryDate.setEditable(false);
              mine.add(labelDeliveryDate);
              labelDeliveryDate.setBounds(16, 490, 134, 21);
              mine.add(fieldTotalPrice);
              fieldTotalPrice.setBounds(120, 520, 220, 21);
              fieldTotalPrice.setEditable(false);
              mine.add(labelTotalPrice);
              labelTotalPrice.setBounds(16, 520, 134, 21);
              mine.add(bSave);
              bSave.setBounds(16, 550, 100, 21);
              mine.add(bLoad);
              bLoad.setBounds(130, 550, 100, 21);
              mine.add(bExit);
              bExit.setBounds(250, 550, 100, 21);
              this.setContentPane(mine);
              this.pack();
              this.setTitle("Order Form);
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              setSize(380, 630);
         public void chooseProductName(){
              if ((ct).equals(ct[0])){
                   comboPName = new JComboBox(cn);
              }else if (ct.equals(ct[1])){
                   comboPName = new JComboBox(pn);
              }else if (ct.equals(ct[2])){
                   comboPName = new JComboBox(mn);
         public void comboPNameChanged(ItemEvent event){
              if (event.getStateChange() == ItemEvent.SELECTED);
         private void setTestData() {
              orderArray.add(makeOrder("1-100-1000"));
              orderArray.add(makeOrder("1-100-1001"));
              orderArray.add(makeOrder("1-100-1002"));
              for (Order temp : orderArray) {
                   if (temp.getOrder().equals("1-100-1000")) {
                        temp.setfName("a");
                        temp.setlName("s");
                        temp.setstreet("4802 Alaska Ave");
                        temp.setcity("Cypress");
                        temp.setzip("90630");
         private Order makeOrder(String order) {
              Order temp = new Order(order);
              return temp;
         private void loadDate(){
         String fn;
         JFileChooser fc = new JFileChooser();
         if(fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION){
              fn = fc.getSelectedFile().getName();
         if( !new File("objdata.dat").exist() ) {
              setTestData();
              for (Order temp: orderArray());
                   lmodel.addElement(temp.getOrder());)
         class Order {
              String orderid, fName, lName, street, city, state, zip;
              public Order(String order) {
                   orderid = order;
              public String getOrder() {
                   return orderid;
              public String getfName() {
                   return fName;
              public void setfName(String fName) {
                   this.fName = fName;
              public String getlName() {
                   return lName;
              public void setlName(String lName) {
                   this.lName = lName;
              public String getstreet() {
                   return street;
              public void setstreet(String street) {
                   this.street = street;
              public String getcity() {
                   return city;
              public void setcity(String city) {
                   this.city = city;
              public String getzip() {
                   return zip;
              public void setzip(String zip) {
                   this.zip = zip;
         private class TextFieldHandler implements ActionListener {
              public void actionPerformed(ActionEvent event) {
                   String string = " ";
                   if (event.getSource() == fieldState)
                        string = String.format("%s " + "is not correct form.", event
                                  .getActionCommand());
                   JOptionPane.showMessageDialog(null, string);
                   // System.out.println("Please use two letter abbreviation.");
    public class Main {
         public static void main(String[] args) {
              JFrame window = new orderFormGUI();
              window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              window.setVisible(true);
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Cross-posted:
    http://forum.java.sun.com/thread.jspa?messageID=10019967

  • Help!  GUI using two buttons

    Hello all:
    I have created a class for reading and writing to a text file on my hard drive. Also, I have created another class for a GUI to use for opening the text file with a button labeled Display. As you will see in the code below, I have created another button labeled Update. I seek to be able to edit and save the text directly in the text area with the Update button after opening the file with the Display button. Any help would be greatly appreciated. Thanks!
    /** Class TextFile */
    import java.io.*;
    public class TextFile
        public String read(String fileIn) throws IOException
            FileReader fr = new FileReader(fileIn);
            BufferedReader br = new BufferedReader(fr);
            String line;
            StringBuffer text = new StringBuffer();
            while((line = br.readLine()) != null)
              text.append(line+'\n');
            return text.toString();
        } //end read()
        public void write(String fileOut, String text, boolean append)
            throws IOException
            File file = new File(fileOut);
            FileWriter fw = new FileWriter(file, append);
            PrintWriter pw = new PrintWriter(fw);
            pw.println(text);
            fw.close();
        } // end write()
    } // end class TextFile
    /** Class TextFileGUI */
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class TextFileGUI implements ActionListener
        TextFile tf = new TextFile();
        JTextField filenameField = new JTextField (30);
        JTextArea fileTextArea = new JTextArea (10, 30);
        JButton displayButton = new JButton ("Display");
        JButton updateButton = new JButton ("Update");
        JPanel panel = new JPanel();
        JFrame frame = new JFrame("Text File GUI");
        public TextFileGUI()
            panel.add(new JLabel("Filename"));
            panel.add(filenameField);
            panel.add(fileTextArea);
            fileTextArea.setLineWrap(true);
            panel.add(displayButton);
            displayButton.addActionListener(this);
            panel.add(updateButton);
            updateButton.addActionListener(this);
            frame.setContentPane(panel);
            frame.setSize(400,400);
            frame.setVisible(true);
        } //end TextFileGUI()
        public void actionPerformed(ActionEvent e)
            String t;
            try
                t = tf.read(filenameField.getText());
                fileTextArea.setText(t);
            catch(Exception ex)
                fileTextArea.setText("Exception: "+ex);
            } //end try-catch
        } //end actionPerformed()
    } //end TextFileGUI

    Swing related questions should be posted in the Swing forum.
    You are using the same ActionListener for both buttons, so you need to be able to tell which button was pressed. There are a couple of ways to do this:
    a) use the getSource() method of the ActionEvent and compare the source against your two buttons to see which one was pressed and then invoke the appropriate code.
    Object source = e.getSource();
    if (source == displayButton)
        //  do display processing
    else if (source == updateButton)
        //  do update processingb) Check the action command to determine which button was clicked. This approach is demonstrated in the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/button.html]How to Use Buttons
    Another option is to create separate ActionListeners for each button so there is no confusion
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    class TextAreaLoad
         public static void main(String a[])
              final JTextArea edit = new JTextArea(5, 40);
              JButton read = new JButton("Read some.txt");
              read.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        try
                             FileReader reader = new FileReader( "some.txt" );
                             BufferedReader br = new BufferedReader(reader);
                             edit.read( br, null );
                             edit.requestFocus();
                        catch(Exception e2) { System.out.println(e2); }
              JButton write = new JButton("Write some.txt");
              write.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        try
                             FileWriter writer = new FileWriter( "some.txt" );
                             BufferedWriter bw = new BufferedWriter( writer );
                             edit.write( bw );
                             edit.setText("");
                             edit.requestFocus();
                        catch(Exception e2) {}
              JFrame frame = new JFrame("TextArea Load");
              frame.getContentPane().add( new JScrollPane(edit), BorderLayout.NORTH );
              frame.getContentPane().add(read, BorderLayout.WEST);
              frame.getContentPane().add(write, BorderLayout.EAST);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }

Maybe you are looking for

  • Smart quotes, M-dash, N-dash, etc. not showing up in pdf

    I am using InDesign CS4 on a Mac 10.6.3 and I noticed that when using HelveticaNeuv TT font there are certain type elements that don't show up when I export to pdf. The things that aren't showing up on the pdf are things like quotes, apostrophes, M-d

  • Yosemite slowed MacBook pro

    Ever since I updated to Yosemite, the MacBook Pro is very slow.  Did not have this problem with our desktop, but need to do something to recover speed we had on the MacBook.  Ideas?

  • Is it possible to create endnotes that restart with each section in Pages that will stay that way in epub?

    I can create section endnotes in Pages, no problem. When I export to epub, the notes are all there and the links work perfectly, but the numbers run continuously throughout the document. Is it possible to create section endnotes in Pages that will su

  • Proceed with hanging Patch (IMPORT_PROPER)

    Hi SAP-basis experts! I have currently the following problem: in tcode SPAM I would like to patch SAP_BASIS component from SPS 13 to 14 (SAPKB70014). Unfortunately the patch is hanging in phase IMPORT_PROPER and I cannot neither delete them from queu

  • Defining Mainteanance planner groups

    Dear EAM Experts, We have maintained the maintenance planner group for the general maintenance task list in the following Maintenance Plans, Work Centers, Task Lists and PRTs - > Basic Settings - > Define Maintenance Planner Groups. But when creating