|
Please let me now how can I set value and text to compbobox
so that I can attach empid and empname both to single combobox, where I want display to empname and on selection I want to fetch other details of emp on empid where empid is FKEY in details datatable.
It is possible in VB by setting value and text, how it possible Java pls anybody have idea pls help me
|
|
|
|
|
|
Sorry Dear,
As per my knowledge there is no method exists JComboBox as setLable or setValue, could you please write a small code for me and help.
|
|
|
|
|
|
Both final class and a class with a private constructor cannot be inherited, so what is the difference?
Also both abstract class and a class with a private constructor cannot be instantiated, again what is the difference then?
|
|
|
|
|
Google for these class types and you will find full explanations.
|
|
|
|
|
I tried, but i am unable to understand. Please mail me the description. I mean i understand these classes but am not able to pinpoint the precise difference. Like in private constructor class object can be created using some static method but it is not possible in a abstract class. Likewise for the other case. So please provide me ur expertise. I am desperate for the answer.
|
|
|
|
|
I don't have anything to mail to you. This information is all available in any of the many Java study guides and online tutorials, which is all that I could offer to provide for you. I'm sorry if you find it difficult to understand but it is most unlikely that I could provide a better explanation than the many professional authors that write on the subject.
|
|
|
|
|
http://docs.oracle.com/javase/tutorial/index.html[^]
http://docs.oracle.com/javase/tutorial/java/javaOO/index.html[^]
Bookmark that page, it's the one source everyone should know.
The keyword "final" describes, that something is not to be changed. So one can define code that would not be changed. Good example are member variables for Screen solution or basic height/length values or also dialog titles.
A private constructor can not be seen from outside the class. It's private as the word private describes
Sometimes one wants to prohibit the use of the 0-args-constructor, which is there even if it's not explicit defined. That would be a classic use for a private constructor, where I make that one unseen by defining it "private".
An abstract class is an abstract description of something, has basic definition, but does not make the complete scope. Example: Animal. Could be anything and none. Can not be used as itself, needs to be extended to make it something.
regards Torsten
I never finish anyth...
|
|
|
|
|
Hi guys i get code named Txmodem,that sends sms and i'd like to add that code to a previous code made by someone else, using a MVC model,and makes it work like actionlistener, so that the USER just press button to send...but IT GENERATE ERROR when i add this field on previous code..(Note:it works cause i received sms on my phone)
package opti;
import java.io.*;
import java.util.*;
import javax.comm.*;
public class Txmodem implements SerialPortEventListener,
CommPortOwnershipListener {
static String comPort = "COM1";
private CommPortIdentifier portId = null;
private Enumeration portList;
private InputStream inputStream = null;
private OutputStream outputStream = null;
private SerialPort serialPort;
public Txmodem(String comm) {
this.comPort = comm;
}
public boolean init() {
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals(comPort)) {
return true;
}
}
}
return false;
}
public void send(String cmd) {
try {
outputStream.write(cmd.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
public void sendMessage(String phoneNumber, String message) {
send("AT+CMGS=\"" + phoneNumber + "\"\r\n");
send(message);
send("\032");
}
public void connect() throws NullPointerException {
if (portId != null) {
try {
portId.addPortOwnershipListener(this);
serialPort = (SerialPort) portId.open("Txmodem", 2000);
} catch (PortInUseException e) {
e.printStackTrace();
}
try {
inputStream = serialPort.getInputStream();
outputStream = serialPort.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
try {
serialPort.addEventListener(this);
serialPort.notifyOnDataAvailable(true);
} catch (TooManyListenersException e) {
e.printStackTrace();
}
} else {
throw new NullPointerException("COM Port non trouvé!!");
}
}
public void serialEvent(javax.comm.SerialPortEvent serialPortEvent) {
switch (serialPortEvent.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
case SerialPortEvent.DATA_AVAILABLE:
byte[] readBuffer = new byte[2048];
try {
while (inputStream.available() >
0)
{
int numBytes = inputStream.read(readBuffer);
}
System.out.print(new String(readBuffer));
} catch (IOException e) {
}
break;
}
}
public void ownershipChange(int type) {
switch (type) {
case CommPortOwnershipListener.PORT_UNOWNED:
System.out.println(portId.getName() + ": PORT_UNOWNED");
break;
case CommPortOwnershipListener.PORT_OWNED:
System.out.println(portId.getName() + ": PORT_OWNED");
break;
case CommPortOwnershipListener.PORT_OWNERSHIP_REQUESTED:
System.out.println(portId.getName() + ": PORT_INUSED");
break;
}
}
public static void main(String args[]) {
Txmodem gsm = new Txmodem(comPort);
if (gsm.init()) {
try {
gsm.connect();
Thread.sleep(5000);
gsm.sendMessage("PHONENUMBER", "HERETEHMESSAGE");
Thread.sleep(20000);
} catch (Exception e) {
e.printStackTrace();
}
} else {
System.out.println("ne peut initialiser la carte");
}
}
}
|
|
|
|
|
What error, where does it occur? Please do not expect people to guess what happens in your code.
|
|
|
|
|
Why the doGet() and doPost() methods hava protected modifier
|
|
|
|
|
|
Hi guys, Please tell me is it possible to link java with C# if so then pls tell me how to link C# code to java. Its very urgent for me pls reply as soon as possible. We are working on netbeans so pls let me know how to combine java and C# in netbeans to execute the code.
Thanks in advance.
|
|
|
|
|
You can't; at least, not easily - see How to wrap a C# library for use in Java[^]. Java runs in the Java Virtual Machine under Windows, and C# runs in the .NET framework, which are two distinct and separate environments.
|
|
|
|
|
k is there any tool to convert entire C# code to java code.
|
|
|
|
|
Search Google for "Convert C# to Java". I got this. CS2J[^]
|
|
|
|
|
hi,
try JavaOnet.
i tried it, is working fine, but you need license to use it.
|
|
|
|
|
am using spring MVC and jsp for developing the application. I have a scenario in which I can create or delete a record. index.jsp is the main page where users can see all the records, from there we can create or delete the record, once created or deleted the controller comes back to the same index.jsp with latest changes being shown on the page. Issue is its working fine in FF and chrome but in IE, if I want to see the latest added record or remove the deleted record from the list, I have to close the browser manually and reopen it. I have tried all possible response.setHeaders..to remove the cache in IE. The other approach I tried is to redirect the spring controller, but still IE is not refreshing and not showing the latest changes in index page. Code is as below:
<pre lang="java">@RequestMapping(value = "/createRequest", method = RequestMethod.GET)
public ModelAndView createRequest(final HttpServletRequest request,
final HttpServletResponse response,..)
//logic to create or delete record..
return new ModelAndView("redirect:myredirectPage.htm");
}
@RequestMapping(value="/myredirectPage", method=RequestMethod.GET)
public ModelAndView showMyRedirectPage(){
ModelAndView modelView = new ModelAndView("index");
return modelView;
}
I have added no cache tags in index.jsp as well as create.jsp where we will create the record. Below is the code i kept in jsp: index.jsp:
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", -1);
%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">
..
</html>
create.jsp:
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", -1);
%>
<!DOCTYPE HTML>
<head>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<%@page isELIgnored="false" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@page import="java.util.Date" %>
...
Thanks.
|
|
|
|
|
Hello,
If you are using BaseFormController or MultiActionControllers then in your XML configuration file set cacheSeconds to 0. This will force controller to automatically output the cache control headers. If you are using annotated controllers then you can use a bean post processor and in it for Bean of type WebContentGenerator set cacheSeconds to 0. Please find below the sample Bean Post Processor
package org.freeware.bizsutra.utils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
public class DefaultPostBeanProcessor implements BeanPostProcessor
{
int _intCacheSec = 0;
ConfigurableWebBindingInitializer _webBindingInitializer = null;
public int getCacheSeconds()
{
return _intCacheSec;
}
public void setCacheSeconds(int cacheSeconds)
{
_intCacheSec = cacheSeconds;
}
public ConfigurableWebBindingInitializer getWebBindingInitializer()
{
return _webBindingInitializer;
}
public void setWebBindingInitializer(ConfigurableWebBindingInitializer webBindingInitializer)
{
_webBindingInitializer = webBindingInitializer;
}
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
{
if (bean instanceof RequestMappingHandlerAdapter)
{
((RequestMappingHandlerAdapter) bean).setCacheSeconds(0);
((RequestMappingHandlerAdapter) bean).setWebBindingInitializer(webBindingInitializer);
}
return bean;
}
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
{
return bean;
}
}
Regards,
<div class="signature">Prasad P. Khandekar
Knowledge exists, man only discovers it.</div>
|
|
|
|
|
sir im using two different table table1 and table2
in table1 im storing user details and
table2 storing username and password .
when the user login with table2. he want to same person details only .
how it is passable please help me.
|
|
|
|
|
Does this have anything to do with Java? If so please explain exactly what the issue is.
|
|
|
|
|
Use appropriate forum to post your questions.Please see this[^] before posting another question
In both tables ,the common id will be USERID(assumption).Use INNERJOIN to join the tables by the common column(USERID).
Check these to know about joins:
Joining Tables in SQL[^]
Visual Representation of SQL Joins[^]
You have to learn to think like a computer or teach him to think like a human.
-Kornfeld Eliyahu Peter
|
|
|
|
|
Here is the question:
12-player are in a 6-day competition. The competition have 6 different games. the rule is:
1. Every player must participate all 6 games.
2. Each player can only play the same game ONCE.
3, Each player can only play with the same opponent ONCE.
right now I use two method "isPlayed()" and "isPlayedWith()" to set players in a loop, but it doesn't work. I guess I have to some other way. But right now I have no clue how to design the algorithm. please help me out. I can write code myself, I just need to learn HOW.
Thank you very much
|
|
|
|
|
There is a forum for Algorithm questions. Alternatively you could show the relevant parts of your code and explain what is meant by:
Member 10409221 wrote: but it doesn't work
|
|
|
|