Zum Inhalt springen

ksg9-sebastian

Mitglieder
  • Gesamte Inhalte

    176
  • Benutzer seit

  • Letzter Besuch

Alle Inhalte von ksg9-sebastian

  1. ksg9-sebastian

    Poi

    Das ist unglaublich. Anstatt eine doofe Testklasse zu erzeugen wo der MySQL-Treiber geladen wird und dazu noch irgendein POI-Objekt erzeugt wird frägst du hier tagelang rum. Das wär doch wirklich nicht allzu schwer gewesen, oder? MySQL entpacken POI entpacken Testklasse erstellen JAR-File draus mache Alle Ordner bis auf META-INF in das JAR kopieren Testen Fertig
  2. client meldet sich am server an, dann baus du ne socket verbindung von server -> client und andersrum. und der server sendet alle 30sec ein PING und der client antwortet mit PONG, oder was auch immer.
  3. Wo hast du die commons-fileupload bzw. commons-io abgelegt ? Bei den commons-fileupload müsste irgendwo ne readme drinsein wo auch beschrieben ist welche Libs benötigt werden. Du musst die libs in deiner Web-app unter WEB-INF/lib ablegen und solltest nicht den shard-lib-Ordner des Servers verwenden(falls du das tust).
  4. Hm..kann man in den parameter-tags des applets javascript benutzen ? dann würde es auch gehen *gg*
  5. Über den Request bei nem Applet ? Da bin ich gespannt *g*
  6. Tjo, da der Browser nichts mit Windows direkt zu tun hast wirst du weder über ENV-Vars noch über Systemproperties dran kommen. Wenn du ganz viel Glück hast kommst du über JNI dran. Du könntest eine DLL schreiben. Die DLL holt sich dann den Namen des Fensters welches momentan im Vordergrund ist. Ist aber nur ein Workaround und mehr oder minder untauglich. Allgemein zum Thema Applet: Es ist für ein Applet völlig uninteressant in welchem Browser es läuft. Einfluss auf die HTML Seite auf der das Applet läuft gibt es nicht. Somit können keine Veränderungen gemacht werden welche Browserspezifisch sein könnten. Und ob ein Applet läuft oder nicht kannst du nicht beeinflussen wenn der Browser bekannt ist. Ist ja keine JavaScript.
  7. Und du bist sicher dass du den Unterschied zwischen Java und Java Script kennst ? Ich weiß nämlich nicht, was eine Browsererkennung mit Java zu tun hat. Ich kenne eine Javaerkennung vom Browser, aber keine Browsererkennung von Java (denn das macht null Sinn). Mein Pc erkennt auch nicht wenn neben mir ein Stuhl steht.
  8. ksg9-sebastian

    SWT Layout Problem

    Hab vor kurzem einen kleinen Layoutmanager geschrieben, hat zwar noch Bugs u.s.w., aber er ist leicht zu benutzen und hat trotzdem viele Möglichkeiten. Ist an das von Swing bekannte TableLayout angelehnt. Mit dem Code kannst du von mir aus machen was du willst, ich übernehme keine Verantwortung *g* TableLayout.java package de.tablelayout; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.layout.*; public class TableLayout extends Layout { private double[] layoutRows; private double[] layoutCols; Point[] sizes; int maxWidth, totalHeight; public final static int FILL = -1; public TableLayout(double[] cols, double[] rows) { this.layoutCols = cols; this.layoutRows = rows; } protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { Control children[] = composite.getChildren(); if (flushCache || sizes == null || sizes.length != children.length) { initialize(children); } int width = wHint, height = hHint; if (wHint == SWT.DEFAULT) width = maxWidth; if (hHint == SWT.DEFAULT) height = totalHeight; TableData td = (TableData)composite.getLayoutData(); if(td != null){ return new Point(width + td.getMarginLeft() + td.getMarginRight(), height + td.getMarginBottom() + td.getMarginTop()); } else{ return new Point(width, height); } } protected void layout(Composite composite, boolean flushCache) { Control children[] = composite.getChildren(); if (flushCache || sizes == null || sizes.length != children.length) { initialize(children); } Rectangle rect = composite.getClientArea(); double onePercentWidth = (double) ((double) rect.width / (double) 100); double onePercentHeight = (double) ((double) rect.height / (double) 100); int x = 0, y = 0; int width = 0; int height = 0; for (int i = 0; i < children.length; i++) { TableData td = (TableData) children[i].getLayoutData(); if (td != null) { x = td.getMarginLeft() + (int)sizeTo(td.getCol(), onePercentWidth, layoutCols); y = td.getMarginTop() + (int)sizeTo(td.getRow(), onePercentHeight, layoutRows); width = (int)sizeTo(td.getCol(), td.getCol() + td.getStretchX(), onePercentWidth, layoutCols) - td.getMarginLeft() - td.getMarginRight(); height = (int)sizeTo(td.getRow(), td.getRow() + td.getStretchY(), onePercentHeight, layoutRows) - td.getMarginTop() - td.getMarginBottom(); } children[i].setBounds(x, y, width, height); } } private double getRest(double pixelPerPercent, double[] arr) { double val = pixelPerPercent * 100; for (int i = 0; i < arr.length; i++) { if (arr[i] != FILL){ if(arr[i] > 1){ val = val - arr[i]; } else{ val = val - (arr[i] * pixelPerPercent); } } } return val; } private double sizeTo(int start, int end, double pixelPerPercent, double[] arr) { double val = 0.0; for (int i = start; i <= end; i++) { if (arr[i] == FILL) { val = val + getRest(pixelPerPercent, arr); } else if(arr[i] > 1){ val += arr[i]; } else{ val += (double)arr[i] * 100 * pixelPerPercent; } } return val; } private double sizeTo(int index, double pixelPerPercent, double[] arr) { int i = 0; double val = 0.0; while (i < index) { if (arr[i] == FILL) { val = val + getRest(pixelPerPercent, arr); } else if(arr[i] > 1) { val += arr[i]; } else{ val += (double)arr[i] * 100 * pixelPerPercent; } i++; } return val; } void initialize(Control children[]) { maxWidth = 0; totalHeight = 0; sizes = new Point[children.length]; for (int i = 0; i < children.length; i++) { sizes[i] = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, true); maxWidth = Math.max(maxWidth, sizes[i].x); totalHeight += sizes[i].y; } totalHeight += (children.length - 1); } } TableData.java package de.tablelayout; public class TableData{ private int row; private int col; private int stretchX; private int stretchY; private int marginLeft; private int marginTop; private int marginRight; private int marginBottom; /** * * @param col The column where the component should be placed * @param row The row where the component should be placed */ public TableData(int col, int row) { super(); this.row = row; this.col = col; } /** * * @param col The column where the component should be placed * @param row The row where the component should be placed * @param stretchX The number of columns where the component should be streched about * @param stretchY The number of rows where the component should be streched about */ public TableData(int col, int row, int stretchX, int stretchY) { super(); this.row = row; this.col = col; this.stretchX = stretchX; this.stretchY = stretchY; } /** * * @param col The column where the component should be placed * @param row The row where the component should be placed * @param margin The margin of the component ([0] - left, [1] - top, [2] - right, [3] - bottom) */ public TableData(int col, int row, int[] margin) { if(margin.length < 4) throw new IllegalArgumentException("Size of array 'margin' must be 4"); this.row = row; this.col = col; marginLeft = margin[0]; marginTop = margin[1]; marginRight = margin[2]; marginBottom = margin[3]; } /** * * @param col The column where the component should be placed * @param row The row where the component should be placed * @param stretchX The number of columns where the component should be streched about * @param stretchY The number of rows where the component should be streched about * @param margin The margin of the component ([0] - left, [1] - top, [2] - right, [3] - bottom) */ public TableData(int col, int row, int stretchX, int stretchY, int[] margin) { if(margin.length < 4) throw new IllegalArgumentException("Size of array 'margin' must be 4"); this.row = row; this.col = col; this.stretchX = stretchX; this.stretchY = stretchY; marginLeft = margin[0]; marginTop = margin[1]; marginRight = margin[2]; marginLeft = margin[3]; } public int getCol() { return col; } public void setCol(int col) { this.col = col; } public int getRow() { return row; } public void setRow(int row) { this.row = row; } public int getStretchX() { return stretchX; } public void setStretchX(int stretchX) { this.stretchX = stretchX; } public int getStretchY() { return stretchY; } public void setStretchY(int stretchY) { this.stretchY = stretchY; } public int getMarginBottom() { return marginBottom; } public void setMarginBottom(int marginBottom) { this.marginBottom = marginBottom; } public int getMarginLeft() { return marginLeft; } public void setMarginLeft(int marginLeft) { this.marginLeft = marginLeft; } public int getMarginRight() { return marginRight; } public void setMarginRight(int marginRight) { this.marginRight = marginRight; } public int getMarginTop() { return marginTop; } public void setMarginTop(int marginTop) { this.marginTop = marginTop; } } TestApp.java package Testapp; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; import com.cloudgarden.resource.SWTResourceManager; import de.tablelayout.TableData; import de.tablelayout.TableLayout; public class TestApp extends org.eclipse.swt.widgets.Composite { { SWTResourceManager.registerResourceUser(this); } public TestApp(Composite parent, int style) { super(parent, style); initGUI(); } /** * Initializes the GUI. */ private void initGUI() { try { this.setSize(new org.eclipse.swt.graphics.Point(400,300)); this.setBackground(SWTResourceManager.getColor(192, 192, 192)); TableData td = new TableData(0, 1); double[] cols = {0.25, 0.25, 0.25, 0.25}; double[] rows = {0.25, 0.25, 0.25, 0.25}; int[] margin = {5, 5, 5, 5}; TableLayout tl = new TableLayout(cols, rows); this.setLayout(tl); td = new TableData(0, 0, margin); Button btn = new Button(this, SWT.PUSH); btn.setLayoutData(td); td = new TableData(1, 0, margin); td.setMarginTop(20); td.setMarginBottom(10); btn = new Button(this, SWT.PUSH); btn.setLayoutData(td); this.layout(); this.pack(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { Display display = Display.getDefault(); Shell shell = new Shell(display); TestApp inst = new TestApp(shell, SWT.NULL); Point size = inst.getSize(); shell.setLayout(new FillLayout()); shell.layout(); if(size.x == 0 && size.y == 0) { inst.pack(); shell.pack(); } else { Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y); shell.setSize(shellBounds.width, shellBounds.height); } shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }
  9. Das hat doch damit nichts zu tun. Fakt ist: Wenn man eine Technik benutzt, dann hält man sich an die Standarts welche von dieser Technik vorgegeben werden. Und zwar nach Möglichkeit an einen aktuellen Standart. Ebenso sollte man sich eine sinnvolle Realisierung einer Anforderung überlegen, und HTML zu parsen ist imho absolut nicht sinnvoll, da es ein riesiges Gefrickel ist den HTML-Code auseinander zu pflücken.
  10. Warum machst du das Dokument nicht einfach XHTML konform ? Dann hast du keine Probleme mehr und kannst mit XML-Bäumen arbeiten.
  11. Tags erweitern u.s.w.ist ja ok, aber Tags aus z.B. nem Servlet direkt über die Klasse anzusprechen ist ihmo absolut nicht state of the art.
  12. Ääähm..ja, natürlich ist Reflection die letzte Lösung die ich benutzen würde, aber so wie er es beschrieben hat die einzige Möglichkeit. Interfaces will er nicht(ich nehm mal an dass er mit nem Prototyp ein Interface meinte) und deshalb bleibt nichtmehr viel übrig. Folgende Lösung würde ich vorschlagen: Ein Interface (Action) welches nur ne actionPerformed(x, y, z)-Methode hat. Für jeden Navigationspunkt eine eigene Klasse welches das Action-Interface implementiert. Eine Mapping-Datei, in der nur drinsteht welcher String auf welche Klasse gemappt wird (notfalls auch direkt im Code per Map realisierbar). Map mapping = new HashMap(); mapping.put("index", de.navi.IndexAction); mapping.put("forum", de.navi.ForumAction); . . Und dann eben eine Klasse um die Mappings aufzulösen (MappingResolver). Die Klasse erhält die angeforderte Seite als String und holt sich aus der Mapping-Map/Mapping-Datei die entsprechende Klasse. Dann ein Objekt dieser gefundenen Klasse erzeugen, das ganze auf auf "Action" casten (das Interface) und eben die performAction vom Interface ausführen. private Map<String, Class> mapping = new HashMap<String, Class>(); . . public void gotoPage(String target){ Class clazz = null; if((clazz = mapping.get(target)) != null){ Action iAction = (Action)clazz.newInstance(); action.performAction(); } } Ist zwar am anfang bissl komisch, grade weils viele "leere" Klassen gibt, aber ist die einzige wirklich saubere Lösung. Auserdem ist es von der Wartung her klasse. Neue Sachen hinzufügen u.s.w. hast du kaum Aufwand, lediglich - Neue Klasse erzeugen (implements Action) - String in Mapping-Map/Mapping-Tabelle eintragen - Navigationspunkt hinzufügen Das ist wunderbar so...mach ich auch fast immer so. Gruß seb
  13. Ok, aber wo ist das der Sinn ? Ich kenne zig Möglichkeiten wie man eine Seite dynamisch aufbaut (z.B. über Interfaces und Module, über XML/XSL(T) mit Xalan u.s.w.), aber noch nie dass man einen Tag im Code aufruft..
  14. Du kannst Bilder u.s.w. mit nem ObjectOutputStream/ObjectInputStream speichern und lesen. Wie du Text und Bild in eine Dateispeichern willst -> keine Ahnung Ich denk nicht dass das geht, da du ja unterscheiden müsstest zwischen dem Text und den Bildinformationen. Für Word gibts glaub ich ne API von apache.org, weiß aber nicht genau.
  15. Über Reflection ist das teilweise machbar... du könntest eine Klasse erstellen welche nur für die Navigation zuständig ist, diese enthält sämtliche Methoden, z.b. void showIndex, void showForum u.s.w. Dann erstellst du dir ne ReflectionHelper-Klasse welche ein Objekt der Navigation-Klasse und die Methode die aufgerufen werden soll übergeben bekommt (Die Methode per Name als String). Und dann eben mit der ReflectionAPI die Methode ausführen, evtl. noch Parameter mitgeben. Gruß
  16. Die notes.ini ist korrekt ? Folgende Dienste sind drin? ServerTasks=<any other tasks>,http,diiop
  17. ksg9-sebastian

    Das letzte Elee

    String pfad = "de/test/start.class" String name = pfad.substring(pfad.lastIndexOf("/") + 1); System.out.println(name); //Ausgabe: start.class
  18. Hm.. willst du jetzt den Pfad des Items im Tree oder den Pfad zu ner Datei/nem Ordner auf Dateisystem-Ebene ? private String getTreePath(TreeItem selectedItem){ TreeItem parent = null; String treePath = selectedItem.getText(); while((parent = selectedItem.getParentItem()) != null){ treePath = parent.getText() + "/" + treePath; selectedItem = parent; } // Laufwerksbuchstabe anhängen return treePath; } Wenn das Dateisystem 1:1 durch den Tree repräsentiert wird geht es so. Du musst an der Stelle an der ich den Kommentar hingemacht hab noch den Laufwerksbuchstaben anhängen. Insgesamt ist das Ding noch n bissl zu optimieren, aber grob funktioniert es. Du solltest nen StringBuffer/StringBuilder benutzen u.s.w. Gruß seb
  19. Richtiges "always on top"-Verhalten geht in Java nicht. Erzeuge einfach einen Dialog mit deinem JFrame als Owner, dann noch modal setzen (setModal(true)) und gut ist. Oder du schaust dir gleich das Wizard-Framework an dass ich in meinem letzten Beitrag gelinkt hab. Gruß
  20. wenn du Glück hast kommst du mit nem AWTEventListener all "alle" Events ran..musst halt mal ausprobieren
  21. ksg9-sebastian

    JTable

    www.java-forum.org -> FAQ-Forum -> JTable Tutorial Teil 1 - 8
  22. omg, start eclipse einfach so eclipse.exe -vm c:\Programme\Java\j2sdk1.4\bin\javaw.exe "c:\Programme\Java\j2sdk1.4\bin\javaw.exe" durch den richtigen Pfad ersetzen. Oder setzt/änder die Umgebungsvariable JAVA_HOME auf deine 1.5er Version und nimm aus der PATH-Variable den Eintrag <PFAD_zu_JAVA>\bin raus und ersetz ihn durch den 1.5er Pfad
  23. public class AppletEx implements KeyListener{ public void init(){ addKeyListener(this); } //implement methods }
  24. www.google.de suche nach java file traverse

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...