formats

[Java] 取得螢幕寬度

Java如何取得營幕寬度? 

import java.awt.Toolkit;
import java.awt.Dimension;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

然後就可以透過screen.width和screen.height來取得螢幕的寬度與高度

 

如果要取得瀏覽器的寬度與高度, 則使用 getClientWidth() and getClientHeight() 就可以了. 

 

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

[Flex] about namespace 2.6 issue

Q:

Namespace 2.6 in the application descriptor file should be equal or higher than the minimum version 3.1 required by Flex SDK ????

A: 

you need to replace <application xmlns="http://ns.adobe.com/air/application/2.6"> to <application xmlns="http://ns.adobe.com/air/application/3.1"> inside *-app.xml file.


 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

[轉帖] 对于MySQL使用 GROUP_CONCAT 函数 的方式进行处理(非常简单)

如何透過 concat 將查詢結果資料記錄組合成一串 ?

繼續閱讀 »

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

[轉帖] git-upload-pack: command not found, how to fix this correctly

I have been using git to keep two copies of my project in sync, one is my local box, the other the test server. This is an issue which occurs when I log onto our remote development server using ssh;

繼續閱讀 »

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

[轉貼] GWT – Browser window resized handler

Q:

I am developing a GWT application that render a text on a canvas. I want to resize the canvas whenever browser window resized. The problem is if I used Window.addResizeHandler, the rendering process with each resize will be very slow. So I need a way to resize the canvas only when the user release the mouse button after finishing resize. Is there anyway to do that?

繼續閱讀 »

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

[轉貼] GWT/Firefox: getOffsetHeight() always returns 0

Q: Using GWT 1.6.4, I have the following code to retrieve the dimensions of the browser window:

 

RootPanel panel = RootPanel.get();

int height = panel.getOffsetHeight(); 

int width = panel.getOffsetWidth();

Now, in the Hosted Mode browser, and in IE (but I believe the hosted mode browser uses IE, right?), this returns the correct values for both width and height. However, in FF3, width gives the correct value, but height is always zero. Can anyone explain this? Am I doing something wrong? What is the correct way to retrieve the height of the window in Firefox, and is there one method that works correctly in both IE and Firefox?

繼續閱讀 »

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

[轉帖] How to change the URL of your SVN repository

We just changed our Subversion repository’s url from something terrible with custom port number hideousness to a URL so clean, concise and georgeous that I became brain damaged. The old URL still works but I wanted to repoint all my checked out code to the new URL. I tried switch and it didn’t work until Bret mentioned that Eclipse had something called relocate for this issue. A google search later…

繼續閱讀 »

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

[git] Setting Up A Public Repository

Assume your personal repository is in the directory ~/proj. We first create a new clone of the repository and tell git-daemon that it is meant to be public:

$ git clone --bare ~/proj proj.git $ touch proj.git/git-daemon-export-ok 

The resulting directory proj.git contains a "bare" git repository–it is just the contents of the ".git" directory, without any files checked out around it.

Next, copy proj.git to the server where you plan to host the public repository. You can use scp, rsync, or whatever is most convenient.

Exporting a git repository via the git protocol

This is the preferred method.

If someone else administers the server, they should tell you what directory to put the repository in, and what git:// URL it will appear at.

Otherwise, all you need to do is start git daemon; it will listen on port 9418. By default, it will allow access to any directory that looks like a git directory and contains the magic file git-daemon-export-ok. Passing some directory paths as git-daemon arguments will further restrict the exports to those paths.

You can also run git-daemon as an inetd service; see the git daemon man page for details. (See especially the examples section.)

Exporting a git repository via http

The git protocol gives better performance and reliability, but on a host with a web server set up, http exports may be simpler to set up.

All you need to do is place the newly created bare git repository in a directory that is exported by the web server, and make some adjustments to give web clients some extra information they need:

$ mv proj.git /home/you/public_html/proj.git $ cd proj.git $ git --bare update-server-info $ chmod a+x hooks/post-update 

(For an explanation of the last two lines, see git update-server-info and githooks.)

Advertise the URL of proj.git. Anybody else should then be able to clone or pull from that URL, for example with a command line like:

$ git clone http://yourserver.com/~you/proj.git 
 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Java 日期 v.s 字串 互轉

Java 日期轉字串範列

1.//目前時間
2.Date date = new Date();
3.//設定日期格式
4.SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
5.//進行轉換
6.String dateString = sdf.format(date);
7.System.out.println(dateString);

Java字串轉日期範例

 
1.//欲轉換的日期字串
2.String dateString = "20010-03-02 20:25:58";
3.//設定日期格式
4.SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
5.//進行轉換
6.Date date = sdf.parse(dateString);
7.System.out.println(date);


以上不支援 gwt, 若要在 gwt 字串日期互轉, 必須使用 

DateTimeFormat

原因為:
 
GWT Doesnt support this java APi. It’s explicit in documentation pages 

GWT does not provide full emulation for the date and number formatting 
classes (java.text.DateFormat, java.text.DecimalFormat, 
java.text.NumberFormat, java.TimeFormat, et cetera). Instead, a subset 
of the functionality of the JRE classes is provided by 
com.google.gwt.i18n.client.NumberFormat and 
com.google.gwt.i18n.client.DateTimeFormat 

GWT provides the DateTimeFormat class to replace the functionality of 
the DateFormat and TimeFormat classes from the JRE.

詳細用法, 請參考 http://code.google.com/intl/fr/webtoolkit/doc/1.6/DevGuideCodingBasics.html#DevGuideDateAndNumberFormat 

參考資料: GWT官方文件 and http://cooking-java.blogspot.com/2010/03/java-string-to-date.html 


 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

[轉帖] What does Object signify in Java?

Question:

I’m new to Java but not to programming (I normally code in Ruby). One thing I’ve seen in Java code examples is the use of <> instead of () to pass params to an object. Below is a code example (taken from a Google Web Toolkit tutorial):

 

publicvoid onValueChange(ValueChangeEvent<String> event){    String token = event.getValue();     // depending on the value of the token, do whatever you need    ...}

Does it have to do with casting or is it something else? Can someone explain to me what this signifies or is used for? Thanks!

繼續閱讀 »

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
© 首耀科技股份有限公司
credit