388 Posted Topics
Re: It depends on the layout. What is layot of panel? //add the slider to the panel In which layouts the .setLocation-method is effective? | |
Re: [URL="http://mindprod.com/jgloss/codepoint.html"]http://mindprod.com/jgloss/codepoint.html[/URL] Look at the post:[URL="http://www.daniweb.com/forums/thread179741-2.html"]http://www.daniweb.com/forums/thread179741-2.html[/URL] and my utility DetectUnicodeBlocks.class | |
Re: 1. create new instance of ArrayList java.util.List<String> anList = new java.util.ArrayList<String>(); 2. add names to anList 3. convert anList to Object[] anArray: Object[] model = anList.toArray(); 4. create new instance of JList jList: jList = new JList(model); 5. read [URL="http://download.oracle.com/javase/tutorial/uiswing/components/list.html"]http://download.oracle.com/javase/tutorial/uiswing/components/list.html[/URL] | |
Re: Inside hexagon is "i=20". You interpret this as while(i<a){} loop. OK, I can consider with this assumption. [QUOTE]i dont know if it is true, i dont understand for the first if if its false how i want to proceed it?? can anyone tell me how the first if must be … | |
Re: minim package: based on ForwardFFT.pde example jingle = minim.loadFile("jingle.mp3", 2048); in this case bufferSize = 2048 and this size is also a size of Hamming window look at sources | |
Re: I like this! 2+2*2=6 OK (typical test for calculators) -5+1 NO -5 NO 5=5 OK (-5)+1 NO 1+(-5) NO +5 NO Wrong work with the sign of number (+-) (distinction between the operator and the sign) Program should show the first wrong positions in the input chain | |
Re: Here are two your methods simplified for testing purposes (without conditions) [CODE] public void paintVertically(Graphics gc) { int i0 = 0; int j0 = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 4; j++) { gc.setColor(Color.blue); gc.drawLine(dots[i0][j0].x, dots[i0][j0].y, dots[i][j].x, dots[i][j].y); … | |
Re: 1. when MouseEvent fires mousePressed(MouseEvent e) then get/append[CODE] Transferable trans = clipboard.getContents(null); String s1 = (String) trans.getTransferData(DataFlavor.stringFlavor); if (s1.equals(s)) { //nothing to do (avoid populate text in editor) //an alternative to clipboard clear (?) } else { TextEditor.editor.append(Color.red, s); s = s1; // store to compare }[/CODE] where in my … | |
Re: class reserveform extends JFrame implements ---???----{ - Which one interface implements? | |
Re: It seems that the use of the keyboard (missiles) affects the acceleration of foreign traffic. You can use your own game clock and sync with it. I recommend the book: [URL="http://www.brackeen.com/javagamebook/"]http://www.brackeen.com/javagamebook/[/URL] // With acceleration, the game also looks good and does not indicate an error, but a covert intelligence of … | |
Re: Look at standard java \jdk1.7.0\demo\applets\GraphLayout folder used variables: - boolean pickfixed; - int numMouseButtonsDown; and methods: - removeMouseMotionListener(this); - addMouseMotionListener(this); or alternatively in place of clicked use left and right button (with key modifiers) what is mouseClicked? mousePressed mouseReleased mousePressed mouseReleased Test this on simple mouse program similar to line … | |
Re: method get() load images from files to Image[] array - used once method set() gets images from Image[] array - used many times Show your getSpaceShipSprite() method. | |
Re: Hello ethio Look at the example: [URL="http://download.oracle.com/javase/tutorial/uiswing/examples/misc/InputVerificationDialogDemoProject/src/misc/InputVerificationDialogDemo.java"]http://download.oracle.com/javase/tutorial/uiswing/examples/misc/InputVerificationDialogDemoProject/src/misc/InputVerificationDialogDemo.java[/URL] Use this example as a pattern to work. Particularly start your application in same way. You can copy as a whole two methods: public static void main(String[] args) private static void createAndShowGUI() In the last method change only name InputVerificationDialogDemo to Password. Your … | |
Re: [URL="http://download.oracle.com/javase/tutorial/uiswing/components/icon.html"]http://download.oracle.com/javase/tutorial/uiswing/components/icon.html[/URL] [URL="http://download.oracle.com/javase/tutorial/2d/images/loadimage.html"]http://download.oracle.com/javase/tutorial/2d/images/loadimage.html[/URL] [QUOTE]If you are writing a real-world application, it is likely (and recommended) that you put your files into a package.[/QUOTE] | |
Re: [CODE]public class Flight { private final String name; private final int id; Flight(String name, int id) { this.name = name; this.id = id; } String getName() { return name; } int getId() { return id; } String getFullName() { return name + id; } }[/CODE] [CODE]public class FlightSet { private … | |
Re: yes [URL="http://download.oracle.com/javase/tutorial/uiswing/components/icon.html"]http://download.oracle.com/javase/tutorial/uiswing/components/icon.html[/URL] [URL="http://download.oracle.com/javase/tutorial/2d/images/loadimage.html"]http://download.oracle.com/javase/tutorial/2d/images/loadimage.html[/URL] AWT Label, keys operate, thread based application example: [URL="http://www.daniweb.com/forums/thread331227.html"]http://www.daniweb.com/forums/thread331227.html[/URL] You can base on javax.swing.Timer or javax.swing.SwingWorker<T,V>. Look at api doc (examples inside). | |
Re: with Anonymous Inner Class Runnable [CODE]import java.awt.*; import java.awt.event.*; class Snake extends Frame implements KeyListener {//ActionListener Thread t = new Thread(); String s = "####";//my snake, String sc = "";//for storing score int score = 0; int dir = 0; int kt; int x, y;//position variables for snake label Label … | |
Re: If it is a Swing applicaction here is an example: [URL="http://download.oracle.com/javase/tutorial/uiswing/examples/misc/InputVerificationDialogDemoProject/src/misc/InputVerificationDialogDemo.java"]http://download.oracle.com/javase/tutorial/uiswing/examples/misc/InputVerificationDialogDemoProject/src/misc/InputVerificationDialogDemo.java[/URL] | |
Re: There are two solutions; 1. class Female extends Student class Male extends Student abstract class Student 2. class Female implements Student class Male implements Student interface Student Both methods allows you to write: [CODE] public static void main(String args[]) { Student[] studentArray = new Student[2]; studentArray[0] = new Male(22, 6); … | |
Re: Missing Arithmetic Multiplication operator [URL="http://download.oracle.com/javase/tutorial/java/nutsandbolts/opsummary.html"]http://download.oracle.com/javase/tutorial/java/nutsandbolts/opsummary.html[/URL] | |
Re: use: Map<K, V> Set<K> List<K> and their methods | |
Re: I propose to create a new class to work with SQL (from class QueryTableModel move part of sql code) [CODE]DataBase db = new DataBase(url, databasename, login, pass);[/CODE] each query returns "new table model" [CODE]QueryTableModel qtm = db.setQuery(String q)[/CODE] method setQuery(String q) should return [CODE] public QueryTableModel setQuery(String q) { //... … | |
Re: 1. download sources 2. create nb new project 3. put com folder to nb src folder 4. download [URL="http://www.jfugue.org/jfugue-chapter1.pdf"]http://www.jfugue.org/jfugue-chapter1.pdf[/URL] 5. run a Test Program from 4. 6. with sources, docs, examples you can answer your questions Look at the methods in org.jfugue.Player class. | |
Re: daniweb.com, - position in the world: (HIGH) 1 238 - visits per day (average, last 90 days) 285 690 ... more details on the website [URL="http://bizinformacja.pl/www.daniweb.com"]http://bizinformacja.pl/www.daniweb.com[/URL] ------------------------------------------ kvggdf.com [91.213.217.191] tried to attack? my computer | |
Re: Imagine, that you have only one line to read from text file. Write a java console program with the following assumptions: Open and read text file with fixed name. Parse values to 6 Local Variables (of String or Double types) Report on screen. Variables,Naming [URL="http://download.oracle.com/javase/tutorial/java/nutsandbolts/variables.html"]http://download.oracle.com/javase/tutorial/java/nutsandbolts/variables.html[/URL] ... Create new class ie. … | |
Re: Implement MouseListener in class MyPanel. [URL="http://download.oracle.com/javase/tutorial/uiswing/events/mouselistener.html"]http://download.oracle.com/javase/tutorial/uiswing/events/mouselistener.html[/URL] Inside mouse methods use e.getPoint() where e is a MouseEvent // You have two JFrames: Line 15 and Line 32 ? | |
Re: [B]testcaseValues[/B] always indicate the same object. Final effect you can see. In the line 26 you should create new object Put line 14 in place of line 26 | |
Re: set layout for JFrame for example: [CODE] //GUI JFrame frame = new JFrame("Biz Sim"); frame.setLayout(new GridLayout(1,0));[/CODE] for JFrame default layout is: [CODE] System.out.println(frame.getLayout());[/CODE] java.awt.BorderLayout[hgap=0,vgap=0] | |
Re: Write first CustomerInfo program without GUI with the input data as in your example 24 roses TOTAL= 1 bear TOTAL= 14 Lilies TOTAL= | |
Re: [CODE] public void Customer(String name, PaymentType paymentType) { //select which paymentType he opted switch (paymentType) { case CHEQUE: // enumeration constant, wrong is use PaymentType.CHEQUE // break; case CREDITCARD: // break; case CASH: // break; } }[/CODE] The Java Tutorials is your first book! [URL="http://download.oracle.com/javase/tutorial/java/javaOO/enum.html"]http://download.oracle.com/javase/tutorial/java/javaOO/enum.html[/URL] | |
Re: java -cp "_your class path,place where folder org is_" org.newdawn.spaceinvaders.Game | |
Re: Do not use awt.Button in Swing Lines 30,31 and lines 38,39 do the same (logic) | |
Re: Experimental look - not tested use getPreferredSize, then setPreferredSize [CODE]private JTextField[] txtAttrTextFields = new JTextField[NrOfTextFields]; { for (int i = 0; i < NrOfTextFields; i++) { // int i can't be final txtAttrTextFields[i] = new JTextField(){ @Override public Dimension getPreferredSize() { // return new Dimension((10+10*Integer.valueOf(getName())),40); return new Dimension(table.getColumn(attrTitle.elementAt(Integer.valueOf(getName())).toString()).getPreferredWidth(), 40); //no … | |
Re: unreported exception java.lang.Exception; TWO WAYS must be caught //handling error in place -->[CODE] else { try { throw new Exception(); } catch (Exception ex) { // here your reaction on error } }[/CODE] or declared to be thrown. add throws clause: [CODE] public void setRectangle(int initialX, int initialY, int initialWidth, … | |
Re: The Event Dispatch Thread [URL="http://mindprod.com/jgloss/swingthreads.html"]http://mindprod.com/jgloss/swingthreads.html[/URL] [URL="http://download.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html"]http://download.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html[/URL] | |
Re: Apply to your JTable method: [CODE] jotTable.setFillsViewportHeight(true);[/CODE] Your method should look typically: [CODE]public Object getValueAt(int row, int col) { return ((Object[]) cache.elementAt(row))[col]; }[/CODE] Use DefaultTableCellRenderer Here is an example. [CODE]DefaultTableCellRenderer LPRenderer = new DefaultTableCellRenderer() { @Override public void setValue(Object value) { int cellValue = (value instanceof Number) ? ((Number) value).intValue() … | |
| |
Re: this mean: YOU should first create the array with the initial employees’ salaries and then update the salaries to show the 30% increase Read Me: Starting "Java" [Java tutorials / resources / faq] - first thread on the page | |
Re: java doc. Interface java.awt.LayoutManager defaults: 1. javax.swing.JRootPane$1[hgap=0,vgap=0] 2. java.awt.FlowLayout[hgap=5,vgap=5,align=center] | |
Re: delete lines 9 and 28 - do not use do-while loop here | |
Re: [CODE] Object[] getField(){ return list.toArray(); }[/CODE] ? | |
Re: I simplified class names ( too long for me ) Write new classes from scratch, only that, that you need to run execute this main() line by line and show your results [CODE] public static void main(String args[]) { // at any phase write only, what things you need //write … | |
Re: line: Color newColor = new Color(r / count, g / count, b / count); introduces rounding error for each color component A faster algorithm uses this line two times (rows and columns separately) for smaller number of cells to compute and introduces cumulative rounding error (two roundings) [side effect of … | |
The End.