[Solved] How to construct a button on runtime (Android) [closed]

you can create button from code. you can find all the alternative methods of setting attribute in the doc. for example Button button = new Button(this); button.setText(“hi”); button.setId(Id); button.setTextColor(Color.Red); button.setBackgroundResource(R.drawable.icon); buttonlayout.addView(button); 1 solved How to construct a button on runtime (Android) [closed]

[Solved] Improving my guessing game [closed]

one of 2 things could be done here either replacing the exception throwing with something else which would be something like this: inside Game.main() change this: try{ jar.guess(); } catch(IllegalArgumentException iae){ System.out.println(“Please choose a valid number”); } to this: jar.guess(); simply eliminating the try catch check and inside Jar.guess() change this: if(guess>maxNumberOfItems){ throw new IllegalArgumentException(); … Read more

[Solved] Image dont appear

Try this public void onClick(View v) { // TODO Auto-generated method stub contatore++; display.setText(“Il totale รจ: “+ contatore); if (contatore > 10) { immagine.setVisibility(View.VISIBLE); } } solved Image dont appear

[Solved] jdbc-hsqldb exception for text table

As the OP found out, following these simple steps help find the problem in the CSV file: Look at the error message: bad TEXT table source file – line number: 1196 The line number is the line number of the CSV file. Using a text editor, go to that line. Lines are numbered from 1. … Read more

[Solved] I keep getting java.lang.ArrayIndexOutOfBoundsException: 5! How do I fix this? [closed]

Based on what you’ve shown: testNum is greater than scores.length. This means that when you traverse the array by comparing your iterator (i) to testNum rather than its actual length, you will hit indexes which don’t exist. For example, let’s say testNum = 8 and scores.length = 5. Then in your code, you will get … Read more

[Solved] creating pdf file for download in java web [closed]

Why not just use DownloadLink with a Model that will generate the file? IModel fileModel = new LoadableDetachableModel (){ protected Object load() { // A hello world PDF File f = File.createTempFile(“tempFile”, null); Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(f)); document.open(); document.add(new Paragraph(“Hello World!”)); document.close(); return f; } }; DownloadLink link = new DownloadLink(linkId, … Read more

[Solved] How to use the JComponent [closed]

This is a rather perplexing way to start programming in Java. Even so, in this instance why would you not use a JLabel rather than creating your own JComponent? In any case, as some of the comments already said, you need to add your JComponent to a JFrame. An example below: Example JFrame class This … Read more

[Solved] How to do object.getClass().getName() in Java

Looks like you are practicing some OO with Java . It’s better if you ask a doubt instead the full scenario. However I will paste a sample here and you can ask any doubt you have. FoodFactory class below, note that for a name you will get the right Object. public class FoodFactory { public … Read more

[Solved] Retrieve long from a version string

Well – It’s not a Long – You can extract it as a string and parse it to a Double; Pattern p = Pattern.compile((“(\\d\\.\\d)”)); Matcher m = p.matcher(“0.1.0.2 RELEASE”); if (m.find()){ System.out.println(Double.parseDouble(m.group(0))); } PS: Check http://regexr.com/3d9uj to practice regular expressions 2 solved Retrieve long from a version string