Results 1 to 6 of 6
Thread: Basic java
- 11-16-2009, 10:00 AM #1
Basic java
Hello, im new to java. Could any one help me with a simple text problem? I want to make a program that first shows a textfeild that you can write text in. Sends the text to a mysql database, then sends it back and displays it in the same box as the textfield. I would like to do this on a very basic level =) any tips or ideas? thanks =)
- 11-16-2009, 10:03 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
What have you done so far and where exactly are you stuck?
- 11-16-2009, 10:07 AM #3
I am at the startpoint. And my textfield dont work at all =(
- 11-16-2009, 10:11 AM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Describe "dont work at all".
- 11-16-2009, 10:12 AM #5
This is the text box i had in mind
And I do have the "java.awt.TextField;" library. When i run this in eclipse i get no errors but nothing hapens at all =S there should be a box? Am i wrong? :)import java.awt.TextField;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class chat {
Display d;
Shell s;
void TextField() {
d = new Display();
s = new Shell(d);
s.setSize(250, 250);
s.setText("Chat box");
Text text1 = new Text(s, SWT.WRAP | SWT.BORDER);
text1.setBounds(100, 50, 100, 20);
text1.setTextLimit(100);
text1.setText("12345");
Text text2 = new Text(s, SWT.SINGLE | SWT.BORDER);
text2.setBounds(100, 75, 100, 20);
text2.setTextLimit(30);
FocusListener focusListener = new FocusListener() {
public void focusGained(FocusEvent e) {
Text t = (Text) e.widget;
t.selectAll();
}
public void focusLost(FocusEvent e) {
Text t = (Text) e.widget;
if (t.getSelectionCount() > 0) {
t.clearSelection();
}
}
};
text1.addFocusListener(focusListener);
text2.addFocusListener(focusListener);
s.open();
while (!s.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
public static void main(String[] arg) {
new TextField();
}
}
- 11-16-2009, 10:16 AM #6
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Similar Threads
-
Basic Java help, AIM?
By jkswebsite in forum New To JavaReplies: 4Last Post: 07-11-2012, 06:17 PM -
basic Java looping
By ace_hl in forum New To JavaReplies: 16Last Post: 09-03-2009, 01:49 AM -
basic java
By vijay24805 in forum New To JavaReplies: 25Last Post: 04-14-2009, 02:46 AM -
basic java help
By adred in forum New To JavaReplies: 0Last Post: 03-08-2008, 12:36 PM -
Help with basic shapes in java
By carl in forum Java 2DReplies: 1Last Post: 07-31-2007, 11:40 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks