LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to initialize the non standard Library in Java (https://www.linuxquestions.org/questions/programming-9/how-to-initialize-the-non-standard-library-in-java-231121/)

husniteja 09-15-2004 08:46 PM

how to initialize the non standard Library in Java
 
Hi all

i have problem while insert the non standard API for communication between C and Java. this is my code :

Code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import CommLibrary.*;

public class _TvSample2 {

        //////////////////////////////
        CommunicationManager cm;

        CommunicationOutputStream volume_status;
        CommunicationOutputStream color_status;

        public static void main(String[] args) {
               
                JPanel cp = new JPanel(new GridLayout(0,1));
                cp.add(createRadioButtonPanel());
                JFrame f = new JFrame("ButtonExample");
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.setContentPane(cp);
                f.pack();
                f.setLocationRelativeTo(null);
                f.setVisible(true);
                cp.initCommLibrary();
        }
       
                         
        static JPanel createRadioButtonPanel(){
               
                AbstractButton hemp = configure(new JRadioButton("Hemp"));
                AbstractButton shreddies = configure(new JRadioButton("Shreddies"));
                AbstractButton donuts = configure(new JRadioButton("Donuts"));
                JButton btn = new JButton("go");
                JButton btn2 = new JButton("down");
                btn.setActionCommand("btnGo");
                btn2.setActionCommand("btnDown");
                final ButtonGroup bg = new ButtonGroup();
                bg.add(hemp);
                bg.add(shreddies);
                bg.add(donuts);
                btn.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent evt) {
                                ButtonModel model = bg.getSelection();
                                if (model != null){
                                        System.out.println(model.getActionCommand());
                                        System.out.println("positif");
                                }
                                else
                                        System.out.println("no selection");
                        }
                }
                );

                btn2.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent evt) {
                                ButtonModel model = bg.getSelection();
                                if (model != null){
                                        System.out.println(model.getActionCommand());
                                        System.out.println("negatif");
                                }
                                else
                                        System.out.println("no selection");
                        }
                }
                );
               
                JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
                p.setBorder(BorderFactory.createTitledBorder("JRadioButton"));
                p.add(hemp);
                p.add(shreddies);
                p.add(donuts);
                p.add(btn);
                p.add(btn2);
                return p;
        }
       
        //The actioncommand of the model is not automatically copied from the button   
       
        static AbstractButton configure(AbstractButton btn) {
                btn.getModel().setActionCommand(btn.getActionCommand());
                return btn;
        }


        public void initCommLibrary() {
                //////////////////////////////////////////////////////
                CommunicationManager cm = new CommunicationManager();

                volume_status = cm.createOutputStream("volume_status");
                color_status = cm.createOutputStream("color_status");

                cm.init("127.0.0.1");
                System.out.println("Initialization completed");
                ///////////////////////////////////////////////////////
        }

        public void termCommLibrary() {
                ///////////////////////////////////////////////////////
                cm.term();
                ///////////////////////////////////////////////////////
        }

}

the error is while i initialize the initCommLibrary in the main Class
Quote:

$ javac -classpath 'CommLibrary.jar;.' _TvSample2.java
_TvSample2.java:38: cannot resolve symbol
symbol : method initCommLibrary ()
location: class javax.swing.JPanel
cp.initCommLibrary();
^
1 error
any body can help ?

ToniT 09-17-2004 08:30 PM

try
Code:

javac -classpath 'CommLibrary.jar:.' _TvSample2.java


All times are GMT -5. The time now is 11:52 AM.