This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MultipartRequest request = new MultipartRequest(); | |
request.setUrl(url); | |
request.addData("myFileName", fullPathToFile, "text/plain") | |
NetworkManager.getInstance().addToQueue(request); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Form hi = new Form("CSV Parsing", new BorderLayout()); | |
CSVParser parser = new CSVParser(); | |
try(Reader r = new com.codename1.io.CharArrayReader("1997,Ford,E350,\"Super, \"\"luxurious\"\" truck\"".toCharArray())) { | |
String[][] data = parser.parse(r); | |
String[] columnNames = new String[data[0].length]; | |
for(int iter= 0 ; iter < columnNames.length ; iter++) { | |
columnNames[iter] = "Col " + (iter + 1); | |
} | |
TableModel tm = new DefaultTableModel(columnNames, data); | |
hi.add(BorderLayout.CENTER, new Table(tm)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// save a token to storage | |
Preferences.set("token", myToken); | |
// get the token from storage or null if it isn't there | |
String token = Preferences.get("token", null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void showForm() { | |
Toolbar.setGlobalToolbar(true); | |
Form hi = new Form("Storage", new BoxLayout(BoxLayout.Y_AXIS)); | |
hi.getToolbar().addCommandToRightBar("+", null, (e) -> { | |
TextField tf = new TextField("", "File Name", 20, TextField.ANY); | |
TextArea body = new TextArea(5, 20); | |
body.setHint("File Body"); | |
Command ok = new Command("OK"); | |
Command cancel = new Command("Cancel"); | |
Command result = Dialog.show("File Name", BorderLayout.north(tf).add(BorderLayout.CENTER, body), ok, cancel); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Main { | |
public void init(Object o) { | |
theme = UIManager.initFirstTheme("/theme"); | |
// IMPORTANT: Notice we don't use MyClass.class.getName()! This won't work due to obfuscation! | |
Util.register("MyClass", MyClass.class); | |
} | |
public void start() { | |
//... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final EventDispatcher listeners = new EventDispatcher(); | |
public void addActionListener(ActionListener a) { | |
listeners.addListener(a); | |
} | |
public void removeActionListener(ActionListener a) { | |
listeners.removeListener(a); | |
} | |
private void fireEvent(ActionEvent ev) { | |
listeners.fireActionEvent(ev); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Image roundMask = Image.createImage(placeholder.getWidth(), placeholder.getHeight(), 0xff000000); | |
Graphics gr = roundMask.getGraphics(); | |
gr.setColor(0xffffff); | |
gr.fillArc(0, 0, placeholder.getWidth(), placeholder.getHeight(), 0, 360); | |
URLImage.ImageAdapter ada = URLImage.createMaskAdapter(roundMask); | |
Image i = URLImage.createToStorage(placeholder, "fileNameInStorage", "http://xxx/myurl.jpg", ada); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Toolbar.setGlobalToolbar(true); | |
Form hi = new Form("Rounder", new BorderLayout()); | |
Label picture = new Label("", "Container"); | |
hi.add(BorderLayout.CENTER, picture); | |
hi.getUnselectedStyle().setBgColor(0xff0000); | |
hi.getUnselectedStyle().setBgTransparency(255); | |
Style s = UIManager.getInstance().getComponentStyle("TitleCommand"); | |
Image camera = FontImage.createMaterial(FontImage.MATERIAL_CAMERA, s); | |
hi.getToolbar().addCommandToRightBar("", camera, (ev) -> { | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Form hi = new Form("Icon Font"); | |
Button myButton = new Button("Save"); | |
FontImage.setMaterialIcon(myButton, FontImage.MATERIAL_SAVE); | |
hi.add(myButton); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Form hi = new Form("Icon Font"); | |
Button myButton = new Button("Save"); | |
myButton.setIcon(FontImage.createMaterial(FontImage.MATERIAL_SAVE, myButton.getUnselectedStyle())); | |
hi.add(myButton); |