Search Results

Search found 5 results on 1 pages for 'bnabilos'.

Page 1/1 | 1 

  • Implements an Undo/Redo in MVC

    - by bnabilos
    Hello, I have a Java application and I want to implement an Undo/Redo option. the value that I want to stock and that I want to be able to recover is an integer. My Class Model implements the interface StateEditable and I have to redefine the 2 functions restoreState(Hashtable<?, ?> state) and storeState(Hashtable<Object, Object> state) but I don't know what to put on them. It will be really great if somebody can help me to do that. These are the first lines of my Model class, the value that I want to do an undo/redo on it is value public class Model extends Observable implements StateEditable { private int value = 5; private UndoManager undoRedo = new UndoManager(); final UndoableEditListener editListener = new UndoableEditListener() { public void undoableEditHappened(UndoableEditEvent evt) { undoRedo.addEdit(evt.getEdit()); } }; @Override public void restoreState(Hashtable<?, ?> state) { } @Override public void storeState(Hashtable<Object, Object> state) { } }

    Read the article

  • Connect to SQLite Database using Eclipse (Java)

    - by bnabilos
    Hello, I'm trying to connect to SQLite database with Ecplise but I have some errors. This is my Java code and the errors that I get on output. Please see if you can help me. Thank you in advance. package jdb; import java.sql.*; public class Test { public static void main(String[] args) throws Exception { Class.forName("org.sqlite.JDBC"); Connection conn = DriverManager.getConnection("jdbc:sqlite:/Applications/MAMP/db/sqlite/test.sqlite"); Statement stat = conn.createStatement(); stat.executeUpdate("drop table if exists people;"); stat.executeUpdate("create table people (name, occupation);"); PreparedStatement prep = conn.prepareStatement( "insert into people values (?, ?);"); prep.setString(1, "Gandhi"); prep.setString(2, "politics"); prep.addBatch(); prep.setString(1, "Turing"); prep.setString(2, "computers"); prep.addBatch(); prep.setString(1, "Wittgenstein"); prep.setString(2, "smartypants"); prep.addBatch(); conn.setAutoCommit(false); prep.executeBatch(); conn.setAutoCommit(true); ResultSet rs = stat.executeQuery("select * from people;"); while (rs.next()) { System.out.println("name = " + rs.getString("name")); System.out.println("job = " + rs.getString("occupation")); } rs.close(); conn.close(); } } ans that what I get in Ecplise : Exception in thread "main" java.lang.ClassNotFoundException: org.sqlite.JDBC at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:315) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330) at java.lang.ClassLoader.loadClass(ClassLoader.java:250) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at jdb.Test.main(Test.java:7) Thank you

    Read the article

  • Define a default .properties file in JAVA

    - by bnabilos
    Hello, I have 2 .properties files in my java project and I want to define one of them as default file to be used when the language of the operating system is different from the 2 languages already defined. Can you tell me please what should I add to my code to make that possible? Thank you

    Read the article

  • Add other components to JFrame with background

    - by bnabilos
    Hello, I want to add a background image to my JFrame but when I do it using the code below, I'm unable to add other elements like JLabel or JTextField. ImageIcon icon = new ImageIcon("src/images/back.jpg"); backImage = icon.getImage(); BackgroundImagePanel contentPane = new BackgroundImagePanel(); contentPane.setBackgroundImage(backImage); this.setContentPane(contentPane); Can you tell me please if there is another way to add JTabbedPane to a JFrame with a background ? Thank you.

    Read the article

  • Store date object in sqlite database

    - by bnabilos
    Hello, I'm using a database in my Java project and I want to store date in it, the 5th and the 6th parameter are Date Object. I used the solution below but I have errors in these 2 lines : creerFilm.setDate(5, new Date (getDateDebut().getDate())); creerFilm.setDate(6, new Date (getDateFin().getDate())); PreparedStatement creerFilm = connecteur.getConnexion().prepareStatement("INSERT INTO FILM (ID, REF, NOM, DISTRIBUTEUR, DATEDEBUT, DATEFIN) VALUES (?, ?, ?, ?, ?, ?)"); creerFilm.setInt(1, getId()); creerFilm.setString(2, getReference()); creerFilm.setString(3, getNomFilm()); creerFilm.setString(4, getDistributeur()); creerFilm.setDate(5, new Date (getDateDebut().getDate())); creerFilm.setDate(6, new Date (getDateFin().getDate())); creerFilm.executeUpdate(); creerFilm.close(); Can you help me to fix that please ? Thank you

    Read the article

1