[GUI programming] How do two JPanels interact?

Hi, all
I've been looking if there is a standard/mostly-used way implementing GUI applications. e.g.,
under a JFrame, there are 2 MyPanel exntending JPanel, one placed on the leftside, the other on the rightside. they both have got a bunch of JButtons, JLabels, JList, etc. this is the view.
but for the control part, here comes the question: I'd would like PanelA to change background color if a Button on PanelB is pressed. where should I place this part of code that controls what happen. I've considered some possibilites, but not sure which one is the best.
1. implement it in main() like: if PanelA.Button.isPressed(), then PanelB.setBackground(Green)
pros: centrailized control
cons: could lead to long & messy code if there are many Panels needed to control
2. PanelA as Observer, PanelB Observable
pros: doable
cons: not very convenient
3. PanelA & PanelB both singleton, so they can reference to each other directly
pros: easy implementing
cons: less flexibility
if none of them is the way you do, how do you do it then?
any help will be appreciated.
thanks.

You missed the obvious one, just let the controlling panel have a reference to the color panel. In your frame:
ColoredPanel coloredPanel = new ColoredPanel();
ControlPanel control = new ControlPanel(coloredPanel);
// add to conten pane, etcThough ultimately your option two is the best one.

Similar Messages

  • Inserting a Gui program using JFrames and JPanel

    I'm trying to insert a chat program into a game that I've created! The chat program is using JFrames and JPanels. I want to insert this into a GridLayout and Panel. How can I go about doing this?

    whatever is in the frame's contentPane now, you add to a separate JPanel.
    you also add your chat stuff to the separate panel
    the separate panel is added to the frame as the content pane

  • Setting Up a GUI - FlowLayout - Using Two JPanels

    Hello:
    I am getting confused with setting up a GUI with two JPanels one that would be on top and the other middlePanel having a FlowLayout.
    I set up two JPanels but obviously have something wrong because my northPanel has "disappeared" when I added a middlePanel. My componets are all over the place and again my northPanel is no longer showing.
    Idea of what I'm doing.
    1) Enter total number of diners
    2)Confirm that diners # is correct.
    3)Enter name of Diner
    4)Take order - Entree (Pull-Down)
    5)Two sides (CheckBox)
    6)Display Completed Order of diners.
    P.S. I hope my question is not too stupid I am new and has justed started Java Programming. I have tried to look through the Documentation but am getting confused with GUI relating to FlowLayout, GridLayout. etc. I'm just not sure which one I should use to set up my GUI in an organized manner. Am I on the right track or is my code completely screwed. Thanks.
    ** My Code **
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Menu extends JFrame {
    private JTextField partyNumField, dinerName;
    private JComboBox orderComboBox;
    private int partyNum;
    private JButton getParty, continueOrder;
    private JLabel party, companyLogo, dinerLabel, entreeOrder;
    private String dinnerEntree[] = {"Filet Mignon", "Chicken Cheese Steak", "Tacos", "Ribs"};
    private JCheckBox mashed, cole, baked, french;
    public Menu() {
    super("O'Brien Caterer - Where we make good Eats!");
    Container container = getContentPane();
    JPanel northPanel = new JPanel();
    northPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 80, 5));
    companyLogo = new JLabel("Welcome to O'Brien's Caterer's");
    northPanel.add(companyLogo);
    party = new JLabel("Enter the Total Number in Party Please");
    partyNumField = new JTextField(5);
    northPanel.add(party);
    northPanel.add(partyNumField);
    getParty = new JButton("GO - Continue with Order");
    getParty.addActionListener(
    new ActionListener(){
    public void actionPerformed(ActionEvent actionEvent)
    partyNum = Integer.parseInt(partyNumField.getText());
    String ans=JOptionPane.showInputDialog(null, "Total Number is party is: "
    + partyNum + " is this correct?\n\n" + "Enter 1 to continue\n"
    + "Enter 2 to cancel\n");
    if (ans.equals("1")) {
    System.out.println(ans+"=continue"); // handle continue
    } else { // assume to be 2 for cancel
    System.out.println(ans+"=cancel"); // handle cancel
    ); // end Listener
    northPanel.add(getParty);
    JPanel middlePanel = new JPanel();
    middlePanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    dinerLabel = new JLabel("Please enter Diner's name");
    dinerName = new JTextField(30);
    continueOrder = new JButton("continue");
    middlePanel.add(dinerLabel);
    middlePanel.add(continueOrder);
    middlePanel.add(dinerName);
    entreeOrder = new JLabel("Please choose an entree");
    orderComboBox = new JComboBox(dinnerEntree);
    orderComboBox.setMaximumRowCount(4);
    //orderComboBox.addItemListener(
    // new ItemListener(){
    // public void itemsStateChanged(ItemEvent event)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // add entree order to Person
    // continue ** enable the two sides order
    mashed = new JCheckBox("Mashed Potatoes");
    middlePanel.add(mashed);
    cole = new JCheckBox("Cole Slaw");
    middlePanel.add(cole);
    baked = new JCheckBox("Baked Beans");
    middlePanel.add(baked);
    french = new JCheckBox("FrenchFries");
    middlePanel.add(french);
    // CheckBoxHandler handler = new CheckBoxHandler();
    // mashed.addItemListener(handler);
    // cole.addItemListener(handler);
    // baked.addItemListener(handler);
    // french.addItemListener(handler);
    middlePanel.add(entreeOrder);
    middlePanel.add(orderComboBox);
    container.add(northPanel);
    container.add(middlePanel);
    middlePanel.setEnabled(true);
    setSize(500, 500);
    show();
    // private class to handle event of choosing Check BOx Item
    // private class CheckBoxHandler implements ItemListener{
    // private int count = 0;
    // public void itemStateChanged(ItemEvent event){
    // if (event.getsource() == mashed)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // count++;
    // add mashed choice to person's order
    // if (event.getsource() == cole)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // count++;
    //add cole slaw to person's order
    // if (event.getsource() == baked)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // count++;
    //add baked beans to person's order
    // if (event.getsource() == french)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // count++;
    //add french to person's order
    public static void main(String args[])
    Menu application = new Menu();
    application.addWindowListener(
    new WindowAdapter(){
    public void windowClosing(WindowEvent windowEvent)
    System.exit(0);
    }

    This looks better, i myself don't like the flow layout
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Menu1 extends JFrame
         private JTextField partyNumField, dinerName;
         private JComboBox orderComboBox;
         private int partyNum;
         private JButton getParty, continueOrder;
         private JLabel party, companyLogo, dinerLabel, entreeOrder;
         private String dinnerEntree[] = {"Filet Mignon", "Chicken Cheese Steak", "Tacos", "Ribs"};
         private JCheckBox mashed, cole, baked, french;
    public Menu1()
         super("O'Brien Caterer - Where we make good Eats!");
         addWindowListener(new WindowAdapter()
             public void windowClosing(WindowEvent ev)
                   dispose();
                   System.exit(0);
         Container container = getContentPane();
         JPanel northPanel = new JPanel();
         northPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 120,15));
         companyLogo   = new JLabel("Welcome to O'Brien's Caterer's");
         northPanel.add(companyLogo);
         party         = new JLabel("Enter the Total Number in Party Please");
         partyNumField = new JTextField(5);
         northPanel.add(party);
         northPanel.add(partyNumField);
         getParty    = new JButton("GO - Continue with Order");
         northPanel.add(getParty);
         northPanel.setPreferredSize(new Dimension(700,150));
         getParty.addActionListener(new ActionListener()
              public void actionPerformed(ActionEvent actionEvent)
                   partyNum = Integer.parseInt(partyNumField.getText());
                   String ans=JOptionPane.showInputDialog(null, "Total Number is party is: "
                   + partyNum + " is this correct?\n\n" + "Enter 1 to continue\n"
                   + "Enter 2 to cancel\n");
                   if (ans.equals("1"))
                        System.out.println(ans+"=continue"); // handle continue
                   else { // assume to be 2 for cancel
                   System.out.println(ans+"=cancel"); // handle cancel
         }}); // end Listener
         JPanel middlePanel = new JPanel();
         middlePanel.setLayout(new FlowLayout(FlowLayout.CENTER));
         dinerLabel         = new JLabel("Please enter Diner's name");
         dinerName          = new JTextField(30);
         continueOrder      = new JButton("continue");
         middlePanel.add(dinerLabel);
         middlePanel.add(dinerName);
         middlePanel.add(continueOrder);
         entreeOrder   = new JLabel("Please choose an entree");
         orderComboBox = new JComboBox(dinnerEntree);
         orderComboBox.setMaximumRowCount(4);
    //orderComboBox.addItemListener(
    // new ItemListener(){
    // public void itemsStateChanged(ItemEvent event)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // add entree order to Person
    // continue ** enable the two sides order
         mashed = new JCheckBox("Mashed Potatoes");
         middlePanel.add(mashed);
         cole   = new JCheckBox("Cole Slaw");
         middlePanel.add(cole);
         baked  = new JCheckBox("Baked Beans");
         middlePanel.add(baked);
         french = new JCheckBox("FrenchFries");
         middlePanel.add(french);
    // CheckBoxHandler handler = new CheckBoxHandler();
    // mashed.addItemListener(handler);
    // cole.addItemListener(handler);
    // baked.addItemListener(handler);
    // french.addItemListener(handler);
         middlePanel.add(entreeOrder);
         middlePanel.add(orderComboBox);
    //container.add(northPanel);
    //container.add(middlePanel);
         container.add(northPanel, java.awt.BorderLayout.NORTH);
         container.add(middlePanel, java.awt.BorderLayout.CENTER);
         middlePanel.setEnabled(true);
         setSize(600, 500);
         show();
    // private class to handle event of choosing Check BOx Item
    // private class CheckBoxHandler implements ItemListener{
    // private int count = 0;
    // public void itemStateChanged(ItemEvent event){
    // if (event.getsource() == mashed)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // count++;
    // add mashed choice to person's order
    // if (event.getsource() == cole)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // count++;
    //add cole slaw to person's order
    // if (event.getsource() == baked)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // count++;
    //add baked beans to person's order
    // if (event.getsource() == french)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // count++;
    //add french to person's order
    public static void main(String args[])
         new Menu1();
    no edit
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Menu1 extends JFrame
         private JTextField partyNumField, dinerName;
         private JComboBox orderComboBox;
         private int partyNum;
         private JButton getParty, continueOrder;
         private JLabel party, companyLogo, dinerLabel, entreeOrder;
         private String dinnerEntree[] = {"Filet Mignon", "Chicken Cheese Steak", "Tacos", "Ribs"};
         private JCheckBox mashed, cole, baked, french;
    public Menu1()
         super("O'Brien Caterer - Where we make good Eats!");
         addWindowListener(new WindowAdapter()
         public void windowClosing(WindowEvent ev)
                   dispose();
                   System.exit(0);
         Container container = getContentPane();
         JPanel northPanel = new JPanel();
         northPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 120,15));
         companyLogo = new JLabel("Welcome to O'Brien's Caterer's");
         northPanel.add(companyLogo);
         party = new JLabel("Enter the Total Number in Party Please");
         partyNumField = new JTextField(5);
         northPanel.add(party);
         northPanel.add(partyNumField);
         getParty = new JButton("GO - Continue with Order");
         northPanel.add(getParty);
         northPanel.setPreferredSize(new Dimension(700,150));
         getParty.addActionListener(new ActionListener()
              public void actionPerformed(ActionEvent actionEvent)
                   partyNum = Integer.parseInt(partyNumField.getText());
                   String ans=JOptionPane.showInputDialog(null, "Total Number is party is: "
                   + partyNum + " is this correct?\n\n" + "Enter 1 to continue\n"
                   + "Enter 2 to cancel\n");
                   if (ans.equals("1"))
                        System.out.println(ans+"=continue"); // handle continue
                   else { // assume to be 2 for cancel
                   System.out.println(ans+"=cancel"); // handle cancel
         }}); // end Listener
         JPanel middlePanel = new JPanel();
         middlePanel.setLayout(new FlowLayout(FlowLayout.CENTER));
         dinerLabel = new JLabel("Please enter Diner's name");
         dinerName = new JTextField(30);
         continueOrder = new JButton("continue");
         middlePanel.add(dinerLabel);
         middlePanel.add(dinerName);
         middlePanel.add(continueOrder);
         entreeOrder = new JLabel("Please choose an entree");
         orderComboBox = new JComboBox(dinnerEntree);
         orderComboBox.setMaximumRowCount(4);
    //orderComboBox.addItemListener(
    // new ItemListener(){
    // public void itemsStateChanged(ItemEvent event)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // add entree order to Person
    // continue ** enable the two sides order
         mashed = new JCheckBox("Mashed Potatoes");
         middlePanel.add(mashed);
         cole = new JCheckBox("Cole Slaw");
         middlePanel.add(cole);
         baked = new JCheckBox("Baked Beans");
         middlePanel.add(baked);
         french = new JCheckBox("FrenchFries");
         middlePanel.add(french);
    // CheckBoxHandler handler = new CheckBoxHandler();
    // mashed.addItemListener(handler);
    // cole.addItemListener(handler);
    // baked.addItemListener(handler);
    // french.addItemListener(handler);
         middlePanel.add(entreeOrder);
         middlePanel.add(orderComboBox);
    //container.add(northPanel);
    //container.add(middlePanel);
         container.add(northPanel, java.awt.BorderLayout.NORTH);
         container.add(middlePanel, java.awt.BorderLayout.CENTER);
         middlePanel.setEnabled(true);
         setSize(600, 500);
         show();
    // private class to handle event of choosing Check BOx Item
    // private class CheckBoxHandler implements ItemListener{
    // private int count = 0;
    // public void itemStateChanged(ItemEvent event){
    // if (event.getsource() == mashed)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // count++;
    // add mashed choice to person's order
    // if (event.getsource() == cole)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // count++;
    //add cole slaw to person's order
    // if (event.getsource() == baked)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // count++;
    //add baked beans to person's order
    // if (event.getsource() == french)
    // if (event.getStateChange() == ItemEvent.SELECTED)
    // count++;
    //add french to person's order
    public static void main(String args[])
         new Menu1();
    }

  • How to start a Web GUI program from a Web Dynpro application

    I know the program name , and it is a Web GUI program ,is anybody know how to start it from a Web Dynpro application

    hi,
    I use the following program to call a SAP GUI program :
    DATA: l_componentcontroller TYPE REF TO ig_componentcontroller.
      DATA: l_api_componentcontroller type ref to if_wd_component.
      DATA: l_sapgui_manager type ref to cl_wdr_sapgui_integration.
      DATA: lt_parameters    TYPE wdr_name_value_list.
      l_componentcontroller = wd_this->get_componentcontroller_ctr( ).
      l_api_componentcontroller = l_componentcontroller->wd_get_api( ).
      l_sapgui_manager = l_api_componentcontroller->get_sapgui_manager( ).
      IF l_sapgui_manager IS NOT INITIAL.
        l_sapgui_manager->fire( EXPORTING name = 'PROGRAM_NAME 'parameters = lt_parameters ).
    But the l_sapgui_manager is always initial , what can I do ?
    ENDIF.

  • Overlapping two JPanels on a JLayeredPane

    I am having some problems overlapping two JPanels on a JLayeredPane for some reason only one of them shows when I compile the program! Any help would be greatly appreciated
    The code is the following:
    import java.lang.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class SpaceBall
    //To do the background just draw a JPanel inside another //JPanel just set the opacity of the outside one
    //to false and let
    //it hold all the components of the game
    public static void main(String[] args)
    //declaring the buttons
    JButton test=new JButton("test");
    JButton test1=new JButton("test1");
    JButton test2=new JButton("test2");
    //declaring and setting the properties of the frame
    JFrame SpaceBall= new JFrame("Space Ball");
    SpaceBall.setSize(700,650);
    //declaring the Panels
    JLayeredPane bgPanel= new JLayeredPane();
    JPanel fgPanel= new JPanel();
    JPanel topPanel= new JPanel();
    JPanel sidePanel= new JPanel();
    JPanel lowPanel= new JPanel();
    JPanel masterPanel= new JPanel();
    //adding the buttons to the corresponding panels
    fgPanel.add(test1);
    sidePanel.add(test2);
    topPanel.add(test);
    ImageIcon background= new ImageIcon("images/background.jpg");
    JLabel backlabel = new JLabel(background);
    backlabel.setBounds(0,0,background.getIconWidth(),background.getIconHeight());
    backlabel.add(test1);
    bgPanel.add(backlabel, new Integer(0));
    fgPanel.setOpaque(false);
    bgPanel.add(fgPanel, new Integer(100));
    bgPanel.moveToFront(fgPanel);
    //adding bgPanel and sidePanel to lowPanel
    lowPanel.setLayout(new GridLayout(1,2));
    lowPanel.add(bgPanel);
    lowPanel.add(sidePanel);
    //adding the Panels to the masterPanel
    masterPanel.setLayout(new GridLayout(2,1));
    masterPanel.add(topPanel);
    masterPanel.add(lowPanel);
    //getting the container of SpaceBall and adding the Panels to it
    Container cp=SpaceBall.getContentPane();
    cp.add(masterPanel);
    //displaying everything
    SpaceBall.show();
    WindowListener ClosingTheWindow=new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    SpaceBall.addWindowListener(ClosingTheWindow);

    Take a look at the section from the Swing tutorial titled "How to Use Layered Panes". It has a sample program:
    http://java.sun.com/docs/books/tutorial/uiswing/components/layeredpane.html

  • GUI program help

    I'm writing a GUI program that involves drawing several shapes, lines, and images to a JPanel. Some of the shapes need to be dragged around the screen by the user, while others will remain stationary. I can't figure out the overall organization of how the drawing should be done. Some questions are:
    1. what type of code should go in the paintComponent method of JPanel?
    2. Should the JFrame class implement MouseListener and MouseMotionListener, or should some other class implement these?
    3. Will I have to use inner classes? (In my current design, the class that extends JPanel is an inner class of the JFrame class.)
    4. How can I minimize flicker when shapes are repainted?

    1. what type of code should go in the paintComponent
    method of JPanel?Let's say you have a List of all your Shapes:
    private List shapes;
    public void paintComponent(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;
        Iterator i = this.shapes.iterator();
        while (i.hasNext()) {
            //Draw your Shape
    2. Should the JFrame class implement MouseListener and
    MouseMotionListener, or should some other class
    implement these?Your pick. I'd have the listeners on your JPanel.
    3. Will I have to use inner classes? (In my current
    design, the class that extends JPanel is an inner
    class of the JFrame class.)Your pick. I prefer using inner classes instead of anonymous classes, but others will say the opposite.
    4. How can I minimize flicker when shapes are
    repainted?yourPanel.setDoubleBuffered(true);

  • Best way for gui programming? swing awt jfc swt ....

    hi,
    i have been programming java for some time but exclusively for web, servlets, jsp etc..
    but now i have to do some �real� gui�s. I have no gui experience , (ok I did some basic examples just to see how things work) but/and I�m not able to determine which way I should go.
    So I did some google search and read some threads here im forum on topics swing vs. awt (or so) and found lot of topics with lot of different opinions(some of them also a little bit out of date) so now im CONFUSED more then ever.
    I read people asking questions like :what is better awt or swing and then getting the perfect technical answers like :
    AWT components are NOT native components. AWT components are Java objects. Particular instances of AWT componets (Button, Label, etc.) MAY use peers to handle the rendering and event handling. Those peers do NOT have to be native components. And AWT components are NOT required to use peers for themselves at all.
    Or
    There are some significant differences between lightweight and heavyweight components. And, since all AWT components are heavyweight and all Swing components are lightweight (except for the top-level ones: JWindow, JFrame, JDialog, and JApplet), these differences become painfully apparent when you start mixing Swing components with AWT components.
    But I don�t care that much(at least not now) about this detail answers.
    I would simply like to know from some experienced gui guru, (due to the fact that we have 2005 and java 1.5) if u would like to learn gui in java quickly and know everything u know now which way would u choose:
    AWT
    JFC
    SWING
    SWT
    And which IDE would u use.
    I simply want to get quickly started and do some basic gui programming ,nothing special, but I would like to avoid that after weeks of doing one, then find out the was the wrong one and again learn the another one.
    TIA Nermin

    try swt vs swing and see what you think, its not really a decision someone else can make for you. as long as you don't try and mix the two, it should be a similar learning curve either way.

  • HOW TO DEVELOP AN INTERACTIVE REPORT

    HI,
         How to Develop  an interactive report to display sales orders for particular customer, items for particular order.

    Hi,
    Look at the below sample Program for the Interactive ALV report.
    *& Report  Z_INTERACTIVE_ALV3                                          *
    report  z_interactive_alv4    no standard page heading line-size 650
    message-id zz_9838                      .
    type-pools: slis.
    *type declaration for values from ekko
    types: begin of i_ekko,
           ebeln like ekko-ebeln,
           aedat like ekko-aedat,
           bukrs like ekko-bukrs,
           bsart like ekko-bsart,
           lifnr like ekko-lifnr,
           end of i_ekko.
    data: it_ekko type standard table of i_ekko initial size 0,
          wa_ekko type i_ekko.
    *type declaration for values from ekpo
    types: begin of i_ekpo,
           ebeln like ekpo-ebeln,
           ebelp like ekpo-ebelp,
           matnr like ekpo-matnr,
           menge like ekpo-menge,
           meins like ekpo-meins,
           netpr like ekpo-netpr,
           end of i_ekpo.
    data: it_ekpo type standard table of i_ekpo initial size 0,
          wa_ekpo type i_ekpo .
    *variable for Report ID
    data: v_repid like sy-repid .
    *declaration for fieldcatalog
    data: i_fieldcat type slis_t_fieldcat_alv,
          wa_fieldcat type slis_fieldcat_alv.
    data: it_listheader type slis_t_listheader.
    declaration for events table where user comand or set PF status will
    be defined
    data: v_events type slis_t_event,
          wa_event type slis_alv_event.
    declartion for layout
    data: alv_layout type slis_layout_alv.
    declaration for variant(type of display we want)
    data: i_variant type disvariant,
          i_variant1 type disvariant,
          i_save(1) type c.
    *PARAMETERS : p_var TYPE disvariant-variant.
    *Title displayed when the alv list is displayed
    data:  i_title_ekko type lvc_title value 'FIRST LIST DISPLAYED'.
    data:  i_title_ekpo type lvc_title value 'SECONDRY LIST DISPLAYED'.
    initialization.
      v_repid = sy-repid.
      perform build_fieldcatlog.
      perform event_call.
      perform populate_event.
    start-of-selection.
      perform data_retrieval.
      perform build_listheader using it_listheader.
      perform display_alv_report.
    *&      Form  BUILD_FIELDCATLOG
          Fieldcatalog has all the field details from ekko
    form build_fieldcatlog.
      wa_fieldcat-tabname = 'IT_EKKO'.
      wa_fieldcat-fieldname = 'EBELN'.
      wa_fieldcat-seltext_m = 'PO NO.'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-tabname = 'IT_EKKO'.
      wa_fieldcat-fieldname = 'AEDAT'.
      wa_fieldcat-seltext_m = 'DATE.'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-tabname = 'IT_EKKO'.
      wa_fieldcat-fieldname = 'BUKRS'.
      wa_fieldcat-seltext_m = 'COMPANY CODE'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
    wa_fieldcat-tabname = 'IT_EKKO'.
      wa_fieldcat-fieldname = 'BUKRS'.
      wa_fieldcat-seltext_m = 'DOCMENT TYPE'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
    wa_fieldcat-tabname = 'IT_EKKO'.
      wa_fieldcat-fieldname = 'LIFNR'.
      wa_fieldcat-no_out    = 'X'.
      wa_fieldcat-seltext_m = 'VENDOR CODE'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
    endform.                    "BUILD_FIELDCATLOG
    *&      Form  EVENT_CALL
      we get all events - TOP OF PAGE or USER COMMAND in table v_events
    form event_call.
      call function 'REUSE_ALV_EVENTS_GET'
       exporting
         i_list_type           = 0
       importing
         et_events             = v_events
    EXCEPTIONS
       LIST_TYPE_WRONG       = 1
       OTHERS                = 2
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    "EVENT_CALL
    *&      Form  POPULATE_EVENT
         Events populated for TOP OF PAGE & USER COMAND
    form populate_event.
      read table v_events into wa_event with key name = 'TOP_OF_PAGE'.
      if sy-subrc eq 0.
        wa_event-form = 'TOP_OF_PAGE'.
        modify v_events from wa_event transporting form where name =
    wa_event-form.
      endif.
      read table v_events into wa_event with key name = 'USER_COMMAND'.
      if sy-subrc eq 0.
        wa_event-form = 'USER_COMMAND'.
        modify v_events from wa_event transporting form where name =
    wa_event-name.
      endif.
    endform.                    "POPULATE_EVENT
    *&      Form  data_retrieval
      retreiving values from the database table ekko
    form data_retrieval.
      select ebeln aedat bukrs bsart lifnr from ekko into table it_ekko.
    endform.                    "data_retrieval
    *&      Form  bUild_listheader
          text
         -->I_LISTHEADEtext
    form build_listheader using i_listheader type slis_t_listheader.
      data hline type slis_listheader.
      hline-info = 'this is my first alv pgm'.
      hline-typ = 'H'.
    endform.                    "build_listheader
    *&      Form  display_alv_report
          text
    form display_alv_report.
      v_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
         i_callback_program                = v_repid
      I_CALLBACK_PF_STATUS_SET          = ' '
         i_callback_user_command           = 'USER_COMMAND'
         i_callback_top_of_page            = 'TOP_OF_PAGE'
         i_grid_title                      = i_title_ekko
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         = ALV_LAYOUT
         it_fieldcat                       = i_fieldcat[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
        i_default                         = 'ZLAY1'
         i_save                            = 'A'
        is_variant                        = i_variant
         it_events                         = v_events
        tables
          t_outtab                          = it_ekko
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    "display_alv_report
    *&      Form  TOP_OF_PAGE
          text
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary       = it_listheader
       i_logo                   =
       I_END_OF_LIST_GRID       =
    endform.                    "TOP_OF_PAGE
    *&      Form  USER_COMMAND
          text
         -->R_UCOMM    text
         -->,          text
         -->RS_SLEFIELDtext
    form user_command using r_ucomm like sy-ucomm
    rs_selfield type slis_selfield.
      case r_ucomm.
        when '&IC1'.
          read table it_ekko into wa_ekko index rs_selfield-tabindex.
          perform build_fieldcatlog_ekpo.
          perform event_call_ekpo.
          perform populate_event_ekpo.
          perform data_retrieval_ekpo.
          perform build_listheader_ekpo using it_listheader.
          perform display_alv_ekpo.
      endcase.
    endform.                    "user_command
    *&      Form  BUILD_FIELDCATLOG_EKPO
          text
    form build_fieldcatlog_ekpo.
      wa_fieldcat-tabname = 'IT_EKPO'.
      wa_fieldcat-fieldname = 'EBELN'.
      wa_fieldcat-seltext_m = 'PO NO.'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-tabname = 'IT_EKPO'.
      wa_fieldcat-fieldname = 'EBELP'.
      wa_fieldcat-seltext_m = 'LINE NO'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-tabname = 'I_EKPO'.
      wa_fieldcat-fieldname = 'MATNR'.
      wa_fieldcat-seltext_m = 'MATERIAL NO.'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
    wa_fieldcat-tabname = 'I_EKPO'.
      wa_fieldcat-fieldname = 'MENGE'.
      wa_fieldcat-seltext_m = 'QUANTITY'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
    wa_fieldcat-tabname = 'I_EKPO'.
      wa_fieldcat-fieldname = 'MEINS'.
      wa_fieldcat-seltext_m = 'UOM'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
    wa_fieldcat-tabname = 'I_EKPO'.
      wa_fieldcat-fieldname = 'NETPR'.
      wa_fieldcat-seltext_m = 'PRICE'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
    endform.                    "BUILD_FIELDCATLOG_EKPO
    *&      Form  event_call_ekpo
      we get all events - TOP OF PAGE or USER COMMAND in table v_events
    form event_call_ekpo.
      call function 'REUSE_ALV_EVENTS_GET'
       exporting
         i_list_type           = 0
       importing
         et_events             = v_events
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    "event_call_ekpo
    *&      Form  POPULATE_EVENT
           Events populated for TOP OF PAGE & USER COMAND
    form populate_event_ekpo.
      read table v_events into wa_event with key name = 'TOP_OF_PAGE'.
      if sy-subrc eq 0.
        wa_event-form = 'TOP_OF_PAGE'.
        modify v_events from wa_event transporting form where name =
    wa_event-form.
      endif.
      endform.                    "POPULATE_EVENT
    *&      Form  TOP_OF_PAGE
          text
    form f_top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary       = it_listheader
       i_logo                   =
       I_END_OF_LIST_GRID       =
    endform.                    "TOP_OF_PAGE
    *&      Form  USER_COMMAND
          text
         -->R_UCOMM    text
         -->,          text
         -->RS_SLEFIELDtext
    *retreiving values from the database table ekko
    form data_retrieval_ekpo.
    select ebeln ebelp matnr menge meins netpr from ekpo into table it_ekpo.
    endform.
    form build_listheader_ekpo using i_listheader type slis_t_listheader.
    data: hline1 type slis_listheader.
    hline1-typ = 'H'.
    hline1-info = 'CHECKING PGM'.
    endform.
    form display_alv_ekpo.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = v_repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = 'F_USER_COMMAND'
       i_callback_top_of_page            = 'TOP_OF_PAGE'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
       i_grid_title                      = i_title_ekpo
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       it_fieldcat                       = i_fieldcat[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         =
       i_save                            = 'A'
      IS_VARIANT                        =
       it_events                         = v_events
      tables
        t_outtab                          = it_ekpo
    exceptions
       program_error                     = 1
       others                            = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform.
    Regards,
    Ram
    Reward points if helpful

  • From SharePoint2013 list item data how to create Google Interactive Chart?

    HI All,
    From SharePoint2013 list item data how to create Google Interactive Chart?
    Thanks in advance!

    Hi,
    To push data from list items to Google Chart, we can use JavaScript Client Object Model or REST API to retrieve the data needed.
    Here are two links about using JavaScript Client Object Model to access list items:
    http://msdn.microsoft.com/en-us/library/office/hh185006(v=office.14).aspx
    http://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx
    From the links from the official site of the Google Chart, we can find out the method to populate data into Chart:
    https://developers.google.com/chart/interactive/docs/quick_start
    https://developers.google.com/chart/interactive/docs/examples#gauge_example
    Best regards
    Patrick Liang
    TechNet Community Support

  • Gui programming Python

    Hi All,
    I'm looking to improve / learn more on gui programming within python.
    I'm not sure if i should be writing the code manualy or using the libglade / glade designer to produce results.
    My main aim with most of my programming is to keep things slim. i use openbox so i don't want to pull in loads of gnome crap to make something work.
    How do you guys go about it etc?
    Regards
    Matthew

    I guess your options are pyQt, pyGtk, Tkinter (included with python), and wxPython.
    I've been playing around with wxpython for a little while now and I quite like it. I really enjoy that it is fairly cross platform (without requiring gtk, qt, or tk/tcl on Windows or Mac) and the wxpython demo program is just fantastic.
    IIRC, the demo isn't packaged with wxpython in Arch, but you can download it separately and extract it to a folder in your home directory with no problems.

  • Client-Server side GUI programming

    I want to create a client-server side gui programming with java
    i read this web adress
    http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html
    for information but there are some parts that i didnt understand and wait for your help
    i m trying to build an online-help(live chat) system so when people press the start chat button a java page will appear but i wonder how this will connect to the person who is on server side
    i mean is it possible to 2 users connect the same port and chat with each other
    I mean when user press the chat button the online help supporter will be informed somebody wants to speak with him and they will start a chat
    how can i do something like that
    any help would be usefull thanks

    Below is an example of a client/server program.
    It shows how the server listens for multiple clients.
    * TriviaServerMulti.java
    * Created on May 12, 2005
    package server;
    * @author johnz
    import java.io.*;
    import java.net.*;
    import java.util.Random;
    * This TriviaServer can handle multiple clientSockets simultaneously
    * This is accomplished by:
    * - listening for incoming clientSocket request in endless loop
    * - spawning a new TriviaServer for each incoming request
    * Client connects to server with:
    * telnet <ip_address> <port>
    *     <ip_address> = IP address of server
    *  <port> = port of server
    * In this case the port is 4413 , but server can listen on any port
    * If server runs on the same PC as client use IP_addess = localhost
    * The server reads file
    * Note: a production server needs to handle start, stop and status commands
    public class TriviaServerMulti implements Runnable {
        // Class variables
        private static final int WAIT_FOR_CLIENT = 0;
        private static final int WAIT_FOR_ANSWER = 1;
        private static final int WAIT_FOR_CONFIRM = 2;
        private static String[] questions;
        private static String[] answers;
        private static int numQuestions;
        // Instance variables
        private int num = 0;
        private int state = WAIT_FOR_CLIENT;
        private Random rand = new Random();
        private Socket clientSocket = null;
        public TriviaServerMulti(Socket clientSocket) {
            //super("TriviaServer");
            this.clientSocket = clientSocket;
        public void run() {
            // Ask trivia questions until client replies "N"
            while (true) {
                // Process questions and answers
                try {
                    InputStreamReader isr = new InputStreamReader(clientSocket.getInputStream());
                    BufferedReader is = new BufferedReader(isr);
    //                PrintWriter os = new PrintWriter(new
    //                   BufferedOutputStream(clientSocket.getOutputStream()), false);
                    PrintWriter os = new PrintWriter(clientSocket.getOutputStream());
                    String outLine;
                    // Output server request
                    outLine = processInput(null);
                    os.println(outLine);
                    os.flush();
                    // Process and output user input
                    while (true) {
                        String inLine = is.readLine();
                        if (inLine.length() > 0)
                            outLine = processInput(inLine);
                        else
                            outLine = processInput("");
                        os.println(outLine);
                        os.flush();
                        if (outLine.equals("Bye."))
                            break;
                    // Clean up
                    os.close();
                    is.close();
                    clientSocket.close();
                    return;
                } catch (Exception e) {
                    System.err.println("Error: " + e);
                    e.printStackTrace();
        private String processInput(String inStr) {
            String outStr = null;
            switch (state) {
                case WAIT_FOR_CLIENT:
                    // Ask a question
                    outStr = questions[num];
                    state = WAIT_FOR_ANSWER;
                    break;
                case WAIT_FOR_ANSWER:
                    // Check the answer
                    if (inStr.equalsIgnoreCase(answers[num]))
                        outStr="\015\012That's correct! Want another (y/n)?";
                    else
                        outStr="\015\012Wrong, the correct answer is "
                            + answers[num] +". Want another (y/n)?";
                    state = WAIT_FOR_CONFIRM;
                    break;
                case WAIT_FOR_CONFIRM:
                    // See if they want another question
                    if (!inStr.equalsIgnoreCase("N")) {
                        num = Math.abs(rand.nextInt()) % questions.length;
                        outStr = questions[num];
                        state = WAIT_FOR_ANSWER;
                    } else {
                        outStr = "Bye.";
                        state = WAIT_FOR_CLIENT;
                    break;
            return outStr;
        private static boolean loadData() {
            try {
                //File inFile = new File("qna.txt");
                File inFile = new File("data/qna.txt");
                FileInputStream inStream = new FileInputStream(inFile);
                byte[] data = new byte[(int)inFile.length()];
                // Read questions and answers into a byte array
                if (inStream.read(data) <= 0) {
                    System.err.println("Error: couldn't read q&a.");
                    return false;
                // See how many question/answer pairs there are
                for (int i = 0; i < data.length; i++)
                    if (data[i] == (byte)'#')
                        numQuestions++;
                numQuestions /= 2;
                questions = new String[numQuestions];
                answers = new String[numQuestions];
                // Parse questions and answers into String arrays
                int start = 0, index = 0;
                   String LineDelimiter = System.getProperty("line.separator");
                   int len = 1 + LineDelimiter.length(); // # + line delimiter
                boolean isQuestion = true;
                for (int i = 0; i < data.length; i++)
                    if (data[i] == (byte)'#') {
                        if (isQuestion) {
                            questions[index] = new String(data, start, i - start);
                            isQuestion = false;
                        } else {
                            answers[index] = new String(data, start, i - start);
                            isQuestion = true;
                            index++;
                    start = i + len;
            } catch (FileNotFoundException e) {
                System.err.println("Exception: couldn't find the Q&A file.");
                return false;
            } catch (IOException e) {
                System.err.println("Exception: couldn't read the Q&A file.");
                return false;
            return true;
        public static void main(String[] arguments) {
            // Initialize the question and answer data
            if (!loadData()) {
                System.err.println("Error: couldn't initialize Q&A data.");
                return;
            ServerSocket serverSocket = null;
            try {
                serverSocket = new ServerSocket(4413);
                System.out.println("TriviaServer up and running ...");
            } catch (IOException e) {
                System.err.println("Error: couldn't create ServerSocket.");
                System.exit(1);
            Socket clientSocket = null;
            // Endless loop: waiting for incoming client request
            while (true) {
                // Wait for a clientSocket
                try {
                    clientSocket = serverSocket.accept();   // ServerSocket returns a client socket when client connects
                } catch (IOException e) {
                    System.err.println("Error: couldn't connect to clientSocket.");
                    System.exit(1);
                // Create a thread for each incoming request
                TriviaServerMulti server = new TriviaServerMulti(clientSocket);
                Thread thread = new Thread(server);
                thread.start(); // Starts new thread. Thread invokes run() method of server.
    }This is the text file:
    Which one of the Smothers Brothers did Bill Cosby once punch out?
    (a) Dick
    (b) Tommy
    (c) both#
    b#
    What's the nickname of Dallas Cowboys fullback Daryl Johnston?
    (a) caribou
    (b) moose
    (c) elk#
    b#
    What is triskaidekaphobia?
    (a) fear of tricycles
    (b) fear of the number 13
    (c) fear of kaleidoscopes#
    b#
    What southern state is most likely to have an earthquake?
    (a) Florida
    (b) Arkansas
    (c) South Carolina#
    c#
    Which person at Sun Microsystems came up with the name Java in early 1995?
    (a) James Gosling
    (b) Kim Polese
    (c) Alan Baratz#
    b#
    Which figure skater is the sister of Growing Pains star Joanna Kerns?
    (a) Dorothy Hamill
    (b) Katarina Witt
    (c) Donna De Varona#
    c#
    When this Old Man plays four, what does he play knick-knack on?
    (a) His shoe
    (b) His door
    (c) His knee#
    b#
    What National Hockey League team once played as the Winnipeg Jets?
    (a) The Phoenix Coyotes
    (b) The Florida Panthers
    (c) The Colorado Avalanche#
    a#
    David Letterman uses the stage name "Earl Hofert" when he appears in movies. Who is Earl?
    (a) A crew member on his show
    (b) His grandfather
    (c) A character on Green Acres#
    b#
    Who created Superman?
    (a) Bob Kane
    (b) Jerome Siegel and Joe Shuster
    (c) Stan Lee and Jack Kirby#
    b#

  • How to create an interactive 3D model? Which software should we need to do that?

    How to create an interactive 3D model? Which software should we need to do that?

    you can crate 3d models in any number of graphics programs.  swift3d is especially designed to use with flash.
    i'm not sure what kind of interaction you want but that would probably be coded in flash.

  • I need to program Striomx for two Toshiba Satellite l645-s4055

    I need to program Striomx for two Toshiba Satellite l645-s4055
    Is there a Toshiba Satellite l645-s4055 Estreomaks program searched for the download link compatible Estreomaks program with two you can not find I want Estreomaks download link is compatible with computer Thank you
    Device Information
    Windows 7
    toshiba satellite l645-s4055
    modl no. psk0GU-034026

    tot1429 wrote:
    I need to program Striomx for two Toshiba Satellite l645-s4055
    ... compatible Estreomaks program 
    Did you misspell a couple of words “Striomx” and “Estreomaks”?  I did not find those words when I Google them.  Do you mean stereo mix?   I did find your model though and I see that it has a Conextant sound card.  Here are 2 methods presented by posters on this forum to incorporate stereo mix with Conextant sound card.
    http://forums.toshiba.com/t5/Audio-Sound/How-to-ge​t-stereo-mix-on-a-Conexant-sound-card/td-p/448001
    http://forums.toshiba.com/t5/Audio-Sound/How-get-S​tereo-Mix-on-Conexant-sound-card-SOLUTION/m-p/1746​...

  • Two JPanels inside another panel should be equal in width

    Hi everybody,
    I have two JPanels which both have a titledborder. I want them to have the same with, but I can not get it done. You can see how it looks here: http://jborsje.nl/jpanels.png. As you can see the JPanels are not equal in width. Here is the code I used (please note that p_hopsControl = true).
         * Initialize the sidebar of the graph panel.
         * @param p_hopsControl Indicates whether or not a widget for controlling the
         * hops in the graph should be added to the panel.
        private JPanel getSideBar(boolean p_hopsControl)
            // Create the panel.
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints constraints = new GridBagConstraints();
            constraints.anchor = GridBagConstraints.FIRST_LINE_START;
            // Add the label and the spinner to the panel.
            constraints.gridx = 0;
            if (!p_hopsControl) constraints.weighty = 1;
            constraints.gridy = 0;
            panel.add(getLegend(), constraints);
            if (p_hopsControl)
                constraints.gridy = 1;
                constraints.weighty = 1;
                constraints.weightx = 1;
                panel.add(getHopsWidgets(), constraints);
            // Set the background of the panel.
            panel.setBackground(m_display.getBackground());
            return panel;
        private JEditorPane getLegend()
            String content = "<html><body>" +
                    "<table>" +
                    "<tr><td bgcolor=\"" + Integer.toHexString(Constants.NODE_COLOR_CLASS & 0x00ffffff) + "\" width=\"20px\"></td><td>OWL class</td></tr>" +
                    "<tr><td bgcolor=\"" + Integer.toHexString(Constants.NODE_COLOR_INDIVIDUAL & 0x00ffffff) + "\"></td><td>OWL individual</td></tr>" +
                    "<tr><td bgcolor=\"" + Integer.toHexString(Constants.NODE_COLOR_SELECTED & 0x00ffffff) + "\"></td><td>Node selected</td></tr>" +
                    "<tr><td bgcolor=\"" + Integer.toHexString(Constants.NODE_COLOR_HIGHLIGHTED & 0x00ffffff) + "\"></td><td>Node highlighted</td></tr>" +
                    "<tr><td bgcolor=\"" + Integer.toHexString(Constants.NODE_COLOR_SEARCH & 0x00ffffff) + "\"></td><td>Node in search result set</td></tr>" +
                    "<tr><td bgcolor=\"" + Integer.toHexString(Constants.NODE_DEFAULT_COLOR & 0x00ffffff) + "\"></td><td>Node in search result set</td></tr>" +
                    "</body></html>";
            JEditorPane legend = new JEditorPane("text/html", content);
            legend.setEditable(false);
            legend.setBorder(new TitledBorder("Legend"));
            JPanel panel = new JPanel();
            panel.setBorder(new TitledBorder("Legend"));
            panel.add(legend);
            return legend;
         * Create a panel containing a JSpinner which can be used to set the number
         * of hops, used in the graph distance filter.
         * @return A JPanel containing the hops widgets.
        private JPanel getHopsWidgets()
            // Get the GraphDistanceFilter.
            GraphDistanceFilter filter = m_display.getDistanceFilter();
            // Create the panel.
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints constraints = new GridBagConstraints();
            constraints.anchor = GridBagConstraints.FIRST_LINE_START;
            // Create the label.
            JLabel label = new JLabel("Number of hops: ");
            // Create the spinner and its model.
            SpinnerNumberModel model = new SpinnerNumberModel(filter.getDistance(), 0, null, 1);
            m_spinner = new JSpinner();
            m_spinner.addChangeListener(this);
            m_spinner.setModel(model);
            // Add the label and the spinner to the panel.
            constraints.gridx = 0;
            constraints.gridy = 0;
            panel.add(label, constraints);
            constraints.gridx = 1;
            constraints.weighty = 1;
            panel.add(m_spinner, constraints);
            // Set the background of the panel.
            panel.setBackground(m_display.getBackground());
            // Add a titled border to the panel.
            panel.setBorder(new TitledBorder("Hops control"));
            return panel;
        }Does anybody know how this can be done?

    Thanks, that solved my issue for the width part. Now the content of the "hops control" panel is centered, althoug I explicitely said "constraints.anchor = GridBagConstraints.FIRST_LINE_START;".
    The update image can still be found here: http://www.jborsje.nl/jpanels.png.

  • NoSuchMethodError in GUI program

    Howdy, I have a GUI program that gets decimal input from the user and converts it to a binary string. It uses JButtons, JTextFields, and JLabels. When I compile and run the program, it says:
    java.lang.NoSuchMethodError: main
    Exception in thread "main"
    I really can't figure it out. I have asked everyone around me that knows anything about java to no avail. Thank you. Any help would be greatly appreciated.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.Integer;
    public class binConvertGUI extends JFrame implements ActionListener
           JButton enter = new JButton("Calculate");
           JLabel lbl1 = new JLabel("Enter decimal: ");
           JLabel lbl2 = new JLabel("Binary: ");
           JTextField txt1 = new JTextField(12);
           JTextField txt2 = new JTextField(12);
           JPanel panA = new JPanel();
           JPanel panB = new JPanel();
           String userInA;
           String num;
           int decnum;
           public binConvertGUI()
                  getContentPane().setLayout(
                        new FlowLayout());
                  panA.add(lbl1);
                  panA.add(txt1);
                  panB.add(lbl2);
                  panB.add(txt2);
                  getContentPane().setLayout(
                        new BoxLayout( getContentPane(), BoxLayout.Y_AXIS ));
                  getContentPane().add(panA);
                  getContentPane().add(panB);
                  getContentPane().add(enter);
                  enter.addActionListener(this);
                  txt1.addActionListener(this);
                  enter.setActionCommand("Calculate");
                  txt2.setEditable(false);
           public void actionPerformed(ActionEvent evt)
                  if(evt.getActionCommand().equals("Calculate"))
                        userInA = txt1.getText();
                        decnum = Integer.parseInt(userInA);
                        num = Integer.toBinaryString(decnum);
                        txt2.setText(num);
                  repaint();
           public void main (String[] args) throws NoSuchMethodError
                  binConvertGUI frm = new binConvertGUI();
                  WindowQuitter wquit = new WindowQuitter();
                  frm.addWindowListener( wquit );
                  frm.setSize( 300, 300 );
                  frm.setVisible( true );
    class WindowQuitter extends WindowAdapter
      public void windowClosing( WindowEvent e )
        System.exit( 0 );
    }

    You just forgot the fact that the main() method is always static:
       public static void main (String[] args) throws NoSuchMethodError {
       //...

Maybe you are looking for

  • Why is there text all mixed up at the bottom of my iTunes store on my ipad it's where it says audiobooks?

    hi all, when I open iTunes on my ipad when I look at the bottom of the iTunes Store there is all text messed up?

  • Send JMS message from a webapp in Tomcat to JMS queue in SJSAS

    Hi, everybody I have a web application. Is is a simple JMS message sender: 2 jsp files(User Interface) and a java helper class which in charge of the sending of jms messages) . It runs well on SJSAS 9 web container. After I have moved it to Tomcat5.5

  • Change in Currency in SAP

    Hi Mine is Indian Company. At present INR is the currency for the company code 1000. However as per IFRS, my company's functional currency is getting changed to USD from INR So please let me know if its possible to change the currency of the company

  • Bridge linksys BEFW11S4 and Airport

    I am trying to extend my home network by bridging my wireless network between two routers. Currently, the Linksys is plugged into the cable modem and the Airport is in another part of the house. My laptop with Airport can see both and I can configure

  • Delay Times in Auto Play

    Can the delay times vary from slide to slide once set in the Auto-Play mode or is the time put in the same for all delays between slides no matter what?