I am trying to create an array list without using the built in arrayList class that java has. I need to start the array being empty with a length of 5. I then add objects to the array. I want to check if the array is full and if not add a value to the next empty space. Once the array is full I then need to create a second array that starts empty and with the length of the first array + 1.
The contents of the first array are then copied into the new array without using the built in copy classes java has and then the new array ends up containing 5 elements and one null space the first time round. The first array is then overwritten with the new array containing the 5 elements and the null space. The process then starts again adding values until the array is full which will be 1 more value then recreating the second array empty and the length of the first array + 1. This is my attempt at creating this but I have run into multiple problems where I get only the last value I added and the rest of the values are null:
public class MyArrayList { public Object arrayList[]; public MyArrayList(Object[] arrayList) { this.arrayList = arrayList;
The thing is if SITA is the name then I have to insert component to the particular envi tabs , if DEVB is the component I have to insert the component there. How can I do this I have done some code its inserting the data at the bottom og the XML .
I am trying out jsp and servlets now for the first time. I have to insert two data, car code and car name into a mysql table. I got those details using jsp but if I use form, it redirects to another page for insertion. I want the data to be inserted and still remain in same jsp page. I am thinking of using onClick from javascript but as I googled this many places have said it is a bad idea to use jsp inside javascript. If so how can we insert data to mysql table without redirecting to another page?
I am creating a slot machine using eclipse. I am trying to get the "winnings" JTextField to be updated in a way so that when the random images have been selected it adds to the number that is already displayed in the JTextField as opposed to what it is doing at the minute which is just displaying how much was won on that particular spin. I am also struggling to set a code for when noting is won, nothing is added. My code is below.
I'm trying to make a update page where you search for person info by their number then have the ability to change any info and save it back to the binary field. I have the search working but i don't know how to do the update,.here my code:
public class User implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(unique = true, nullable = false) private int id;
public List<UserReason> getUserReasons() { return userReasons; } public void setUserReasons(List<UserReason> userReasons) { this.userReasons = userReasons; }
public UserReason addUserReason(UserReason userReason) { if (userReasons == null) { userReasons = new ArrayList<UserReason>();
[Code] ....
I want to be able to add userReason to the list, and that Hibernate will automatically update the reference between the parent & child object.
When using the above code, when trying to start the server, i'm getting the error message:
Repeated column in mapping for entity: com.commit.safebeyond.model.UserReason column: userId (should be mapped with insert="false" update="false")
Please notice that i mapped the userId in UserReasonPK with insertable = false, updatable = false.
If i change it, and add this on the User property in UserReason object, server is up, but when trying to insert new User I'm getting the following error:
I'm a beginner at java and am trying to code a basic pong game java applet. The code has no errors in it but when i run it the .png's do not come up in the window until its moved off screen. when the .png's are shown they do not update whatsoever. I thought the problem could be with the key-listener but even the ball (which moves independently of user input) does not move.
I've placed all the code from the 5 classes below. There's some unnecessary code in the background class but that's because I'm thinking of making the background scroll later on.
I have the below snipped of code that is giving me problems. The code is called when the user clicks on the "NEXT" button of the form. Why despite getting into the Lines 41-45 I am not able to update the BorderPane? Lines 30-39 appear to work as expected. In the case below there are 3 entries within the TreeMap. You can see this within the Output provided by NetBeans shown below.
I am writing a simple program in Java, where I call a method and pass some variables (namely, min and max) as arguments. This method is recursive, so the same arguments are again passed on in each recursive call.
I need to update these variables in recursive calls so that when the calling method uses them, it uses updated values. As it might sound confusing, here is sample code :
// Function 1. void func1() { //Call func2. func2 (int hd, int min, int max, Map<String, String> map); //Other stuff. } // Function 2.
[code]....
As you can see, min and max are updated after each recursive call returns, based on conditions. However, these changes aren't reflected in original min and max, which were used by func1 while calling func2. As far as I know, this happens due to call by value mechanism being used by Java while passing arguments. If I declare min and max as instance variables in the class, my problem is solved. But, I want to know whether there's any other way to update these variables so that changes in original min and max are reflected. Yes, I can return them as an array of 2 elements each time while returning, but it didn't seem a good solution to me.
So I have two related tables - Country (Master) Projects (Detail). Country has a OneToMany relationship with Projects. I put a link on my AllProjects.xhtml page. When tyhe link is clicked it uses a data model class to to display the current (clicked) project record (projectRecord object). After editing all the details, the UPDATE button calls a merge method in the DAO class. On the first attempt to update, nothing happens and the record is returned as it is with no errors. If I try updating again, I get:
Is the 'new' keyword in the entity class causing the Inser statement in the DAO because the JPA thinks I want to create a new object therefore invokes INSERT instead of UPDATE?
I have a GUI with several buttons and I'm using NetBeans GUI Builder to do. At the click of one of these I would like for it to open another frame containing a picture. So I associate a listener (actionPerformed) the button and when clicked it opens actually post the new frame.
In the new frame I waxed a JLabel and then I associate the image of the label. I saw that to do that NetBeans generates this code:
My problem is that the picture is overwritten several times during the execution of the program is not changed yet in the frame. That is, in the new frame is always displayed an old version of the image.
I have an image that is created every time I click on the button (it always has the same name and same path). Basically I have a generic tree on which I perform the operations (add, remove, etc..). When I click on the button I call a method that generates the image of the tree (using Graphviz). So I have one image that changes over the time...
How can I do so that the image is always up to date?
The Code:
package View; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JLabel; public class AlberoIpotesi extends javax.swing.JFrame {
Lets say I have a program that is not in any way connected to the Internet. I post it for for downloading, but I know that I will need to update it fairly often. I don't want people to have to redownload the entire program, I just want to send out a patch to update it. How can I do this?
I'm working on a space invades game and I have a swing timer set up to update the score(number of aliens killed) and for the aliens to shoot. I'm trying to get the score to update at say 100 ms, but the aliens to shoot at 3200ms. I tried to use 2 timers one for the aliens, and one for the score,but the aliens would just use faster score timer.
private void btnAktualisierenActionPerformed(java.awt.event.ActionEvent evt) { if(sql.conOK) { tabelle.table.tableChanged(null); tablePanel.remove(scrollPanel); // The following fetches the new database data and adds the new jFrame tableExists = false; this.getTable(); tabelle.setOptions(); } else lblStatusCon.setText("Bitte zur Datenbank verbinden."); }
this is what I've been doing. It shows only the new jTable when I resize the window.
I'm writing my first bigger program (mysql connection and the first thing bigger than 300 lines ). What I'd like to do is to render data from MySQL using JTable - I managed to handle all the queries but I don't know how to update the table on screen. I've tried to use repaint() but nothing happened. I'm not posting whole code because you'll probably not interested, below are the most important things. I thought about using TableModel but how.
public class Main implements ActionListener{ JTable table;
public Main() { JFrame frame = new JFrame("Frame"); frame.setLayout(new FlowLayout()); frame.add(table);
I have a client server application. The UI for the server contains a JTable and in each row, details of the connected client are shown. Say if I have 5 connections and the 3rd connection disconnects, I need the 4th and 5th connection details to be displayed in 3rd and 4th row respectively. Can this be done?
So, first i search the id from table and all the fields are filled as in the screenshot. then i modify in the text boxes and click on button modify but exception comes-too few parameters. expected 6.
here is the code:
try { JOptionPane.showMessageDialog(null,"Record succefully modified! ID is "+id.getText()+" Password is "+lname.getText()); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("Jdbc:Odbc:Employe eDB"); String str0=id.getText();
Reading a sequential flat file (which is working) but now I need to add code to update the status flag (setting it to ‘Y’ position(7,1)) before I close the file and not sure how without defining the fields.
What I am attempting to do is execute a long-running process and iterate over it multiple times. I'd like my page to update with the progress in between each run. What I have tried so far is using a HttpSessionAttributeListener and executing my long-running process from there and using my ViewScoped bean along with richfaces a4j:poll to update my page. Unfortunately no matter what method I try with a listener, the completion of the Partial JSF lifecycle always blocks until my listener method is through processing. So we go from start to finish with no updates in between.
I have which is to just have my view re-submit itself and try updates that way. But before I go that route I wanted to see if there was a way to do what I was originally attempting and I'm not just missing something.