Skip to content

Instantly share code, notes, and snippets.

Button button;
hi.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
//natural height, maximum width
c.fill = GridBagConstraints.HORIZONTAL;
button = new Button("Button 1");
c.weightx = 0.5;
c.fill = GridBagConstraints.HORIZONTAL;
Form test = new Form("Complete");
test.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
AutoCompleteTextField at = new AutoCompleteTextField(new String[] {"Common", "Code", "Codename One", "Correct", "Correlation", "Co-location", "Corporate"} );
test.addComponent(at);
test.show();
final Form test = new Form("Infinite");
test.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
InfiniteScrollAdapter.createInfiniteScroll(test.getContentPane(), new Runnable() {
private int counter = 1;
public void run() {
// simulate network latency
Display.getInstance().invokeAndBlock(new Runnable() {
public void run() {
try {
@codenameone
codenameone / MyApplication.java
Created September 18, 2013 15:07
Hamburger side menu command placement demo
package com.mycompany.myapp;
import com.codename1.ui.Command;
import com.codename1.ui.Display;
import com.codename1.ui.Form;
import com.codename1.ui.SideMenuBar;
import com.codename1.ui.events.ActionEvent;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
Component customCmp = ...;
Command cmd = ...;
cmd.putClientProperty("SideComponent", customCmp);
Button b = ((GenericListCellRenderer)list.getRenderer()).extractLastClickedComponent();
if(b != null && "X".equals(b.getName())) {
// handle button click event and return
return;
}
// handle standard list action event
x.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
// notice we do nothing, this is an event on a stateless component of the renderer
xWasClicked = true;
}
});
list.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
if(xWasClicked) {
@codenameone
codenameone / MyApplication.java
Created January 8, 2014 08:36
Socket demo application
public class MyApplication {
private Form current;
public void init(Object context) {
try {
Resources theme = Resources.openLayered("/theme");
UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
} catch(IOException e){
e.printStackTrace();
ios.objC=true
android.xapplication=<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="YOUR_ANDROID_API_KEY"/>
ios.add_libs=libc++.dylib;libicucore.dylib;libz.dylib;CoreData.framework;CoreText.framework;GLKit.framework;ImageIO.framework;SystemConfiguration.framework
ios.glAppDelegateHeader=#import "GoogleMaps.h"
android.includeGPlayServices=true
ios.afterFinishLaunching=[GMSServices provideAPIKey:@"YOUR_IOS_API_KEY"];
android.xpermissions=<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/><uses-feature android:glEsVersion="0x00020000" android:required="true"/>
import com.codename1.googlemaps.MapContainer;
import com.codename1.maps.Coord;
import com.codename1.ui.Command;
import com.codename1.ui.Dialog;
import com.codename1.ui.Display;
import com.codename1.ui.EncodedImage;
import com.codename1.ui.Form;
import com.codename1.ui.events.ActionEvent;
import com.codename1.ui.events.ActionListener;
import com.codename1.ui.layouts.BorderLayout;