Results 1 to 3 of 3
- 06-10-2011, 09:57 AM #1
Member
- Join Date
- Jun 2011
- Posts
- 1
- Rep Power
- 0
How can I get a GUI preview on java source code
I just download some GUI source codes in Java. It's not a SWING GUI form , but I wish to preview that GUI just as the design view .
Code as follows:
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JComboBox;
import javax.swing.JButton;
import org.jdesktop.swingx.JXBusyLabel;
public class UserLoginUI extends JPanel implements ActionListener {
private static final long serialVersionUID = 1L;
private JLabel jLabelUsername = null;
private JLabel jLabelPassword = null;
private JTextField jTextFieldUsername = null;
private JPasswordField jPasswordFieldPassword = null;
private JButton jButtonSubmit = null;
private LoginListener loginListener;
private JXBusyLabel jBusyLabel = null;
/**
* This is the default constructor
*/
public UserLoginUI() {
super();
initialize();
}
/**
*
* Add a listener that will be notified for login
* @param listener
*/
public void setLoginListener(LoginListener listener){
this.loginListener = listener;
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
jBusyLabel = new JXBusyLabel();
jBusyLabel.setBusy(true);
jBusyLabel.setVisible(false);
jBusyLabel.setBounds(new Rectangle(87, 165, 161, 31));
jBusyLabel.setText("Authenticating......");
jLabelPassword = new JLabel();
jLabelPassword.setBounds(new Rectangle(61, 90, 72, 16));
jLabelPassword.setText("Password");
jLabelUsername = new JLabel();
jLabelUsername.setBounds(new Rectangle(61, 61, 65, 16));
jLabelUsername.setText("User Name");
this.setLayout(null);
this.setPreferredSize(new Dimension(300, 222));
this.add(jLabelUsername, null);
this.add(jLabelPassword, null);
this.add(getJTextFieldUsername(), null);
this.add(getJPasswordFieldPassword(), null);
this.add(getJButtonSubmit(), null);
this.add(jBusyLabel, null);
}
public void setBusy(boolean state){
jBusyLabel.setVisible(state);
}
/**
* This method initializes jTextFieldUsername
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldUsername() {
if (jTextFieldUsername == null) {
jTextFieldUsername = new JTextField();
jTextFieldUsername.setBounds(new Rectangle(150, 61, 106, 20));
}
return jTextFieldUsername;
}
/**
* This method initializes jPasswordFieldPassword
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getJPasswordFieldPassword() {
if (jPasswordFieldPassword == null) {
jPasswordFieldPassword = new JPasswordField();
jPasswordFieldPassword.setBounds(new Rectangle(150, 91, 106, 20));
}
return jPasswordFieldPassword;
}
/**
* This method initializes jButtonSubmit
*
* @return javax.swing.JButton
*/
private JButton getJButtonSubmit() {
if (jButtonSubmit == null) {
jButtonSubmit = new JButton();
jButtonSubmit.setBounds(new Rectangle(117, 131, 88, 26));
jButtonSubmit.setText("Submit");
jButtonSubmit.addActionListener(this);
}
return jButtonSubmit;
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java .awt.event.ActionEvent)
* Whenever a mouse button is pressed notify the LoginListener
*/
@Override
public void actionPerformed(ActionEvent event) {
if(event.getSource()== getJButtonSubmit()){
jBusyLabel.setVisible(true);
jBusyLabel.repaint();
String username = getJTextFieldUsername().getText();
String password = new String(getJPasswordFieldPassword().getPassword());
if(loginListener != null){
loginListener.login(username,password);
}
}
}
- 06-10-2011, 12:33 PM #2
Please read the forum rules to which you agreed when you signed up to the site:
Forum Rules
Your other two threads have been deleted.
Also check the BB Code list to learn how to post code
BB Code List - Java Forums
To answer your question, you can't. Not in any reasonable way at least. But what you can do is learn Swing and not depend on someone else's code, or a visual designer (which is an advanced tool) for your homework.
Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)
db
- 06-10-2011, 12:36 PM #3
Also cross posted over at the NetBeans forums:
NetBeans Forums - How can I get a GUI preview on java source code just as using SWING GUI form.
db
Similar Threads
-
Get source code from java file
By rjagan in forum New To JavaReplies: 1Last Post: 04-04-2011, 10:51 AM -
Need help on writing Java source code
By k4it0xtr3me in forum New To JavaReplies: 29Last Post: 01-24-2011, 03:56 PM -
Can we Obtain Java Source Code?
By tornado in forum New To JavaReplies: 7Last Post: 12-10-2008, 07:23 PM -
MavenJava - browse source code of all open source projects online
By jirkacelak in forum Java SoftwareReplies: 1Last Post: 11-28-2008, 06:27 PM -
open source java code
By reena in forum Advanced JavaReplies: 1Last Post: 04-19-2008, 06:57 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks