Add an entry to a JList ?
What is the simplest way to add another item, in my case a string, to a jlist? Thanks!
It was a pain in the rump trying to figure this one out, so I sympathize with your quest to figure out how to add things to JLists.
Try this:
( (DefaultListModel) myList.getModel() ).add(new String("hello, this is a new entry!"));This assums that your JList uses DefaultListModel as its ListModel, and automatically class-casts it to that, because the original JList getModel() method does not return a DefaultListModel - even though it IS the default list model. Just a quick tip!
Also, be sure to remember that you can add ANY Object to your JList. How it is "shown" in the JList depends on your Object's toString() method.
So if I have an Object called Entry...
public class Entry {
private String textualRepresentation = "AnEntry";
public Entry() { }
public String toString() {
return textualRepresentation;
}And add it to my JList via...
Entry entry = new Entry();
( (DefaultListModel) myList.getModel() ).add(entry);The JList will now have an item listed as "AnEntry", which is actually our Entry object.
Note that the JList will not update its display when you add the new Object.
To do this, you can either manually click on the list to change its selection, forcing a repaint, or resizing the window (accomplishing the same goal), or doing this:
SwingUtilities.updateComponentTreeUI(myList);Best of luck!
Similar Messages
-
How to add the entries and how to delete the entries from custom Z-table?
Hi Experts,
My requirement is I need to add the entries from program to three custom z-tables . Assume as zabc1,zabc2,zabc3.
Here how to add the entries from program to Z-table.???
And one more requirement is I want to provide a deletion checkbox in selection screen . Initial it was unchecked. If I am giving tick mark then the entries should be deleted from above custom Z-tables. this all will done in backgroung job?
Could you please guide me the logic how to crack this???
Let me know if you need more Info
Thanks
SanjuHi Sanjana,
What you can do is to use the ABAP keyword INSERT or MODIFY to add or modify records to a given database table. Here are the syntax taken from SAP documentation:
*Insert Statement
INSERT dbtab
Syntax
INSERT { {INTO target VALUES source }
| { target FROM source } }.
Effect
The INSERT statement inserts one or more rows specified in source in the database table specified in target. The two variants with INTO and VALUES or without INTO with FROM behave identically, with the exception that you cannot specify any internal tables in source after VALUES.
System Fields
The INSERT statement sets the values of the system fields sy-subrc and sy-dbcnt.
sy-subrc Meaning
0 At least one row was inserted.
4 At least one row could not be inserted, because the database table already contains a row with the same primary key or a unique secondary index.
The INSERT statement sets sy-dbcnt to the number of rows inserted.
Note
The inserted rows are finally included in the table in the next database commit. Up until this point, they can still be removed by a database rollback.
*Modify Statement
MODIFY dbtab
Syntax
MODIFY target FROM source.
Effect
The MODIFY statement inserts one or several lines specified in source in the database table specified in target, or overwrites existing lines.
System fields
The MODIFY statement sets the values of the sy-subrc and sy-dbcnt system fields.
sy-subrc Meaning
0 At least one line is inserted or changed.
4 At least one line could not be processed since there is already a line with the same unique name secondary index in the database table.
The MODIFY statement sets sy-dbcnt to the number of processed lines.
Note
The changes are transferred finally to the database table with the next database commit. Up to that point, they can be reversed using a database rollback.
Hope it helps...
P.S. Please award points if it helps... -
A function module to add an entry to the change log of the ODS needed
Hi all,
I want to add an entry to the change log table of the ODS .
Is there a Function module available for this or a work around for this.
Regards
AkshayHi Kiran,
You can directly add days to the date.
Eg:
DATA date LIKE sy-datum.
DATA days TYPE i.
date = sy-datum.
days = 100.
date = date + days.
WRITE date.
Regards
Wenceslaus -
How to Add multiple entry to the group policy security filtering
How to Add multiple entry to the group policy security filtering
Is there any way we can add multiple entry to the Domain group policy Security filtering tab.Currently its not allowing to add more then one entry at a time.
Getting Error like "only one name can be entered,and the name cannot contain a semicolon.Enter a valid name"Hi
Are you trying to add more users or groups through Group Policy Management Security Filtering tab?
Try right clicking on the policy and then edit
Then in Editor Right click on the name of the policy and Properties
Security tab and add user or group from this tab. Just make sure if you are adding user or groups "Select this object type" has
the correct option also "From this Location" is set to your entire directory not the local server.
Update us with the above.
Thanks -
How do I add an entry to the auto correct spell check dictionary?
How do I add an entry to the auto-correct dictionary for spell check?
The suggestion from Encrypted11 is for adding a keyboard shortcut, if that is what you want to do. If you want to add a custom word to the keyboard dictionary ....
The iPad Dictionary
The iPad has a dictionary built in. As you type, it compares what you've typed against the words in that dictionary. If it finds a partial match, it displays a suggestion just beneath what you have typed.
If you accept the suggestion by tapping the Space or full stop, great.
If you allow the 'mistake' to stand, the second time you type the same word and reject the correction, iPad adds the new word to its custom, dynamic dictionary. From now on, it will accept the new word and will even suggest it the next time you type something like it.
That is copied from here.
http://www.my-iguru.com/ipad/ipad-hints-tips/ipad-keyboard-tips-tricks.php -
Hi folks
I'm trying to simulate an LDIF file into JNDI attribute set but cant make it
dn: dc=fifa,dc=com
objectclass: dcObject
objectclass: organization
o: Football Org
dc: fifa
dn: cn=Manager,dc=fifa,dc=com
objectclass: organizationalRole
cn: Manager
This LDIF works fine on the command line ldapadd. Highly appreciate your help if anyone can tell me how to simulate these LDIF entries in JNDI way. I'm using openldap on solaris. I can add other entries if this entry is already created using command line ldapadd.
Thanks in advanceOk i made it... there we go...
import javax.naming.directory.*;
import javax.naming.*;
import java.util.*;
public class AddEntry {
final static String ldapServerName = "localhost";
final static String rootdn = "cn=Manager,dc=fifa,dc=com";
final static String rootpass = "secret";
final static String rootContext = "dc=fifa,dc=com";
// obtain initial directory context using the environment
public DirContext createContext(String name)
Properties env = new Properties();
DirContext ctx = null;
env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
env.put( Context.PROVIDER_URL, "ldap://" + ldapServerName + "/" + name);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put( Context.SECURITY_PRINCIPAL, rootdn );
env.put( Context.SECURITY_CREDENTIALS, rootpass );
try
ctx = new InitialDirContext( env );
catch(Exception ex)
ex.printStackTrace();
return ctx;
public static void main( String[] args )
AddEntry ae = new AddEntry();
try
DirContext ctx = ae.createContext(rootContext);
Attributes root_Dn = null;
Attributes cn_Dn = null;
Attribute root_objclass = null;
Attribute oAttr = null;
Attribute cn_objclass = null;
Attribute cnAttr = null;
root_Dn = new BasicAttributes();
root_objclass = new BasicAttribute("objectclass");
root_objclass.add("dcObject");
root_objclass.add("organization");
root_Dn.put(root_objclass);
oAttr = new BasicAttribute("o");
oAttr.add("Fifa Company");
root_Dn.put(oAttr);
ctx.createSubcontext("", root_Dn);
cn_Dn = new BasicAttributes();
cn_objclass = new BasicAttribute("objectclass");
cn_objclass.add("organizationalRole");
cn_Dn.put(cn_objclass);
cnAttr = new BasicAttribute("cn");
cnAttr.add("Manager");
cn_Dn.put(cnAttr);
DirContext ctx1 = ae.createContext(rootdn);
ctx1.createSubcontext("", cn_Dn);
catch ( NameAlreadyBoundException nabe )
System.err.println( rootContext + " has already been bound!" );
} catch ( Exception e )
System.err.println( e );
} -
hi,
can any one please help me how to add an entry in transp.table.
in the table TVARV table i need to add an entry .
please any one help me how to add and what are neccessary steps to be followed while adding an entry.
for eg
NAME TYPE NUMB LOW HIGH
ZSAMPLE P 001 /FILE/
ZSAMPLE P 002 /EXTRACT/
NOW I NEED TO ADD AN ENTRY LIKE
ZSAMPLE P 003 /TEST/
please help me its urgent.
thanks in advance.Hi ,
Pls fellow this Steps :
1 ) Go to se 11 u type the table name then press the display .
2) in that screen u click utilities , here u click the table contents .
3) In that table contents u click the create entires ..
4) now u enter the values in that screen .
5) then press save .
now this entires are stored in TVARV table .
<REMOVED BY MODERATOR>
Regards ,
Shankar GJ
Edited by: Alvaro Tejada Galindo on Apr 11, 2008 5:44 PM -
How to add backdated entry to calender
I am trying to add an entry in the past and it just disappear from the screen after a couple of seconds, i have just updated my ipad and iphone could the new update have caused this clich!!
thank you
SimoneSettings>Mail, Contacts, Calendar>Calendars>Sync>All Events
-
How to add environment entry in EJB3 ejb-jar.xml
Hi,
Is that a build in way of add environment entries in JDev for EJB 3 beans? For EJB 2 beans you can do that using properties. But the bean properties is not available in EJB 3. Please help.
Thanks
KennyThank you for the reply. But I need a way to enter env-entry value in ejb-jar.xml for EJB 3 in Jdev. In EJB 2, Jdev generate ejb-jar.xml for the bean and also let you add env-entry through bean's properties menu. But in there in no properties menu for EJB 3, also generated ejb-jar.xml is only a empty file doesn't contain any EJB depolyment information. That means you have to code ejb-jar.xml all manually.
If I am wrong, can someone show me how to do this right? -
How to add tns entry in names server
Hi,
Can anyone tell us, How to add tns entry in names server
ThanksIn the Net Manager utility, in the left-hand pane left click Oracle Names Servers, left click on your nameserver.
Click the "+" button in the upper left, that should be enough to get you started- sorry, all our 9i installs have gone away, can't exactly recall the nix X gui version of client program, but I think* its netmgr, should be in OH/bin.
If you're running a java OEM console that cames with 9i clients, Net Manager is available on that little Butler tab.
And for the command line version, running the namesctl utility- you can save a tns entry with the connect string and run it in a file, just like sqlplus, with an @filename:
vi newtns.txt
register newtns -d (DESCRIPTION=(ADDRESS_LIST=...(SERVICE_NAME=NEWTNS.MYCO)))
$ namesctl
@newtns.txt
query newtns *
reload -- nameserver sync
query newtns *
exit
$ Edited by: clcarter on Jul 7, 2011 3:26 PM
added cmdline version -
After recently updating to 7.1.2, all of my past calendar entries for 22014 disappeared and I cannot add new entries??
What account were you using to sync your Calendar? Make sure that account is added to the device, and make sure that Calendars is turned on for that account.
Then, go to Settings > Mail, Contacts, Calendars, and make sure that under the Calendar section that 'Sync' is set to 'All Events'.
Then go to the Calendar app, go to Calendars, and make sure that you have that account enabled.
Then, close out all the running apps on your device, and restart it.
Open up your Calendar app. Are your entries back? -
I Can't create and add en entry in Ldap using Java
Hello there,
I'm pretty new to LDAP programming, and I have been trying to create and add an entry to a directory using the code sample provided in the JNDI tutorial, but for some reasons, I didn't manage.
the configuration file is well set up because I can't create, add, delete and modify just about anything I want from openLDAP command lines, but my real problem is to do it with java.
here is my code:
import java.util.Hashtable;
import javax.naming.ldap.*;
import javax.naming.directory.*;
import javax.naming.*;
import javax.net.ssl.*;
import java.io.*;
public class Newuser
public static void main (String[] args)
//LDAPEntry myEntry = new LDAPEntry();
Hashtable<String, String> env = new Hashtable<String, String>(11);
String adminName = "CN=ldap_admin,o=JNDITutorial,dc=img,dc=org";
String adminPassword = "xxxxxx";
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
//set security credentials, note using simple cleartext authentication
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL,adminName);
env.put(Context.SECURITY_CREDENTIALS,adminPassword);
//connect to my domain controller
env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial,dc=img,dc=org");
// Create the initial directory context
//JNDILDAPConnectionManager jndiManager = new JNDILDAPConnectionManagerImpl();
try{
DirContext ctx = new InitialDirContext(env);
System.out.println("Connection to LDAP server done" );
final String groupDN ="ou=people,o=JNDITutorial,dc=img,dc=org";
//DirContext dirCtx = jndiManager.getLDAPDirContext();
People people = new People("Thiru","Thiru","Thiru Ganesh","Ramalingam","ou=people","[email protected]");
// The Common name must be equal in Attributes common Name
ctx.bind("cn=Thiru," + groupDN, people);
System.out.println("** Entry added **");
//jndiManager.disConnectLDAPConnection(ctx);
}catch(NamingException exception){
System.out.println("**** Error ****");
exception.printStackTrace();
System.exit(0);
}adn this is the class People that i want to instantiate
import java.util.Hashtable;
import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.*;
public class People implements DirContext {
public People(String uid,String cn,String givenname,String sn,String ou,String mail) {
BasicAttributes myAttrs = new BasicAttributes(true); //Basic Attributes
Attribute objectClass = new BasicAttribute("objectclass"); //Adding Object Classes
objectClass.add("inetOrgPerson");
/*objectClass.add("organizationalPerson");
objectClass.add("person");
objectClass.add("top");*/
Attribute ouSet = new BasicAttribute("ou");
ouSet.add("people");
ouSet.add(ou);
myAttrs.put(objectClass);
myAttrs.put(ouSet);
myAttrs.put("cn",cn);
myAttrs.put("sn",sn);
myAttrs.put("mail",mail);
}as I said, I can add the new entry using an LDIF file "new.txt" that looks like this:
dn:cn=Hamido Saddo,ou=People,o=JNDITutorial,dc=img,dc=org
cn:Hamido Saddo
mail:[email protected]
telephonenumber:3838393038703
sn:hamido
objectclass:top
objectclass:person
objectclass:organizationalPerson
objectclass:inetOrgPersonusing the following command:
ldapadd -D "cn=ldap_admin,o=JNDITutorial,dc=org,dc=img" -W -f new.txtand eveything works
but when i try with the java, i get the following error:
javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - entry has no objectClass attribute]
so, can anyone help me please !!!uncomment these lines
/*objectClass.add("organizationalPerson");
objectClass.add("person");
objectClass.add("top");*/
you need all of them to add successfully
your LDIF has all the four lines
objectclass:top
objectclass:person
objectclass:organizationalPerson
objectclass:inetOrgPerson
hope this helps -
Cannot add journal entries programmatically
Hi everyone
I'm not able to insert Journal entries in the database.
I'm using SAP Business One DI API Version 2007 and a copy of the database SBODemoUS. The code I'm using is inspired by the example in the SDK Help.
I'm trying to add journal entries to the company database. When I execute the code, I get a System Message:
[JDT1.Account][line:1],'Tax account has not been defined for the selected tax code', even though I'm not using a tax code. But when I assign a value to the property .TaxCode, I get a System Message: You can edit VAT fields only in Automatic VAT mode [JDT1.TaxCode][line: 1].
I'm able to create journal entries manually in SAP B1 using the same information that I'm using in my code. But I cannot create journal entries programmatically.
Here is the code that I'm using:
Private Sub ImportJournalEntry()
Dim rt As Long
Dim errCode As Long
Dim errMsg As String
oCompany.Server = "PERSONNE-6D3DBE"
oCompany.CompanyDB = "MYSBODEMO"
oCompany.UserName = "manager"
oCompany.Password = "manager"
oCompany.language = 3
oCompany.UseTrusted = False
oCompany.DbServerType = BoDataServerTypes.dst_MSSQL2005
oCompany.DbPassword = "sapwd"
oCompany.DbUserName = "sa"
rt = oCompany.Connect()
If rt <> 0 Then
oCompany.GetLastError(errCode, errMsg)
Else
Dim entries As SAPbobsCOM.JournalEntries = DirectCast(Me.oCompany.GetBusinessObject(BoObjectTypes.oJournalEntries), JournalEntries)
Dim str2 As String
Try
entries.TaxDate = DateTime.Now.ToShortDateString
entries.StornoDate = DateTime.Now.ToShortDateString
entries.ReferenceDate = DateTime.Now.ToShortDateString
'First line
'entries.Lines.TaxCode = "CA"
entries.Lines.AccountCode = "112200000100101"
entries.Lines.ShortName = "Cash at Bank "
entries.Lines.Debit = 0
entries.Lines.Credit = 125
entries.Lines.Add() 'Add
'Second line
'entries.Lines.TaxCode = "CA"
entries.Lines.AccountCode = "611000000100101"
entries.Lines.ShortName = "Travel Expense"
entries.Lines.Debit = 125
entries.Lines.Credit = 0
entries.Lines.Add() 'Add
If entries.Add <> 0 Then
Dim num As Integer
Me.oCompany.GetLastError(num, str2)
SBO_Application.MessageBox(str2)
Else
SBO_Application.MessageBox("Import was successful!")
End If
oCompany.Disconnect()
Catch exception1 As Exception
SBO_Application.MessageBox(exception1.Message.ToString & _
" Source = " & exception1.Source.ToString & _
" TargetSite = " & exception1.TargetSite.ToString & _
" StackTrace = " & exception1.StackTrace.ToString)
oCompany.Disconnect()
End Try
End If
End Sub
Thanks for any helpHello Vitor
Thanks, I got the code to work. You were right about debit or credit, not both. I also removed the tax code.
But the main reason I think it didn't work is because the account code I was using was incorrect. Since the company is using segmentation for their account code, we are suppose to use the account key, not the account code. In order to get the account key I found this function:
Private Function GetAccountKey(ByVal v_sAccountCode As String) As String
Dim oSBObob As SAPbobsCOM.SBObob
Dim oRecordSet As SAPbobsCOM.Recordset
Dim oChartOfAccounts As SAPbobsCOM.ChartOfAccounts
Dim sStr As String
'// Get an initialized SBObob object
oSBObob = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge)
'// Get an initialized Recordset object
oRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
'// Get an initialized oChartOfAccounts object
oChartOfAccounts = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oChartOfAccounts)
'// Execute the SBObob GetObjectKeyBySingleValue method
oRecordSet = oSBObob.GetObjectKeyBySingleValue(SAPbobsCOM.BoObjectTypes.oChartOfAccounts, "FormatCode", v_sAccountCode, SAPbobsCOM.BoQueryConditions.bqc_Equal)
sStr = oRecordSet.Fields.Item(0).Value
GetAccountKey = sStr
End Function
So the final code looks like this. Although I don't pretend to have perfect code, I'm able to add journal entries.
Private Sub ImportTitan2()
Dim rt As Long
Dim errCode As Long
Dim errMsg As String
Dim sAccountKey As String
oCompany.Server = "PERSONNE-6D3DBE"
oCompany.CompanyDB = "MYSBODEMO"
oCompany.UserName = "manager"
oCompany.Password = "manager"
oCompany.language = 3
oCompany.UseTrusted = False
oCompany.DbServerType = BoDataServerTypes.dst_MSSQL2005
oCompany.DbPassword = "sapwd"
oCompany.DbUserName = "sa"
rt = oCompany.Connect()
If rt <> 0 Then
oCompany.GetLastError(errCode, errMsg)
Else
Dim entries As SAPbobsCOM.JournalEntries = DirectCast(Me.oCompany.GetBusinessObject(BoObjectTypes.oJournalEntries), JournalEntries)
Dim str2 As String
Try
entries.TaxDate = DateTime.Now.ToShortDateString
entries.StornoDate = DateTime.Now.ToShortDateString
entries.ReferenceDate = DateTime.Now.ToShortDateString
'First line
entries.Lines.SetCurrentLine(0)
sAccountKey = GetAccountKey("112200000100101")
entries.Lines.AccountCode = sAccountKey 'Account code
entries.Lines.ShortName = sAccountKey
entries.Lines.Credit = 300
entries.Lines.Add() 'Add
'Second line
entries.Lines.SetCurrentLine(1)
sAccountKey = GetAccountKey("611000000100101")
entries.Lines.AccountCode = sAccountKey 'Account code
entries.Lines.ShortName = sAccountKey
entries.Lines.Debit = 300
entries.Lines.Add() 'Add
If entries.Add <> 0 Then
Dim num As Integer
Me.oCompany.GetLastError(num, str2)
SBO_Application.MessageBox(str2)
Else
SBO_Application.MessageBox("Import was successful!")
End If
oCompany.Disconnect()
Catch exception1 As Exception
SBO_Application.MessageBox(exception1.Message.ToString & _
" Source = " & exception1.Source.ToString & _
" TargetSite = " & exception1.TargetSite.ToString & _
" StackTrace = " & exception1.StackTrace.ToString)
oCompany.Disconnect()
End Try
End If
End Sub
Thank you for your help. You put me in the right direction. -
when i add an entry in my NOTES app, they appear on my sister's ipad NOTES app. This happens even when she's at home. What is happening?
how do i find out if we are sharing the same userid. when i enter the settings and go to the icloud app, my userid is different from my sister's. however, she is somehow picking up my password. And each time I change my password---it changes hers---although our user id's are different. how can i set our id's and passwords to be different. what do i go to?
-
Getting Siri to add an entry to a reminder list
Is there a way to get Siri to add an entry to a Reminder list (Shopping in my case) which isn't the default set up in Settings? Obviously normally I want to use the standard 'Reminders' list but not every time.
Yes she can!
"Add milk to my shopping list"
Also
"Show me my shopping list"
Maybe you are looking for
-
I have Captivate v1.01.1418. I have created several quizzes. When created the quizzes worked perfectly. I'm getting ready to publish to Breeze and reviewing the quizzes one last time and now the Submit button will not allow the user to move to the ne
-
New Camera and pictures don't load on Photoshop Elements 11
I just purchased a Nikon D7100 and after taking some pictures I tried to load them on Photoshop Elements 11. When doing so I got an error message stating "Nothing was imported. The files or folders selected for importing did not contain any supported
-
IMovie 09 Crashes Before I Can Even Choose Something To Import
IMovie has a massive problem with importing video (not from a camera). As soon as I choose to import video it shows the finder as it should, but I get the wheel of death which doesn't stop. It has kind of developed this problem over time, I used to b
-
Hi I am running DPM 2012 R2 UR4 in production environment. Protecting 7 non-clustered Hyper-V hosts with around 60 VMs on top. DPM repeatedly crashes with error 902 just after the start of consistency check on all protection groups. It is followed by
-
What is a price of iphone4 tell me
And i want free iphone4 pls i can unlocked iphone4 in pakistan dont get any charges i want free iphone please give me