LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-15-2004, 08:46 PM   #1
husniteja
LQ Newbie
 
Registered: Jun 2004
Location: South Korea
Distribution: redhat
Posts: 14

Rep: Reputation: 0
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 ?
 
Old 09-17-2004, 08:30 PM   #2
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
try
Code:
javac -classpath 'CommLibrary.jar:.' _TvSample2.java
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'sort' fn. in C++ standard library frankie_DJ Programming 2 12-14-2004 02:27 PM
Standard C and C++ Library Documentation elluva Programming 12 10-25-2004 04:28 AM
standard library for graphics jpostma Programming 3 07-19-2004 06:13 AM
Sockets and standard I/O library failure_to Programming 0 05-22-2004 11:55 AM
C++ standard library. Thetargos Programming 8 10-09-2003 03:01 PM


All times are GMT -5. The time now is 04:53 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration