package desktopapplication1;
import java.io.*;
public class LoginForm extends javax.swing.JFrame {
BufferedReader in;
public LoginForm() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
button1 = new java.awt.Button();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setName("Form"); // NOI18N
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(desktopapplication1.DesktopApplication1.class).getContext().getResourceMap(LoginForm.class);
button1.setLabel(resourceMap.getString("button1.label")); // NOI18N
button1.setName("button1"); // NOI18N
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(190, Short.MAX_VALUE)
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(153, 153, 153))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(180, Short.MAX_VALUE)
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(96, 96, 96))
);
pack();
}// </editor-fold>
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
// How can i write code to run a page names 'DesktopApplication1View.java' in same package?
// Please show me here..pls.
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new LoginForm().setVisible(true);
}
});
}
private java.awt.Button button1;
}
5 Replies - 4230 Views - Last Post: 21 June 2010 - 09:16 PM
#1
How can I make Button that can run another Java file?
Posted 21 June 2010 - 08:32 PM
Guys, i created a page names 'LoginForm.java' and want a button, when i clicked it, it will run my another java files names 'DesktopApplication1View.java'..how can i done this?
Replies To: How can I make Button that can run another Java file?
#2
Re: How can I make Button that can run another Java file?
Posted 21 June 2010 - 08:34 PM
Guys, i created a page names 'LoginForm.java' and want a button, when i clicked it, it will run my another java files names 'DesktopApplication1View.java'..how can i done this?
package desktopapplication1;
import java.io.*;
public class LoginForm extends javax.swing.JFrame {
BufferedReader in;
public LoginForm() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
button1 = new java.awt.Button();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setName("Form"); // NOI18N
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(desktopapplication1.DesktopApplication1.class).getContext().getResourceMap(LoginForm.class);
button1.setLabel(resourceMap.getString("button1.label")); // NOI18N
button1.setName("button1"); // NOI18N
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(190, Short.MAX_VALUE)
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(153, 153, 153))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(180, Short.MAX_VALUE)
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(96, 96, 96))
);
pack();
}// </editor-fold>
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
// How can i write code to run a page names 'DesktopApplication1View.java' in same package?
// Please show me here..pls.
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new LoginForm().setVisible(true);
}
});
}
private java.awt.Button button1;
}
#3
Re: How can I make Button that can run another Java file?
Posted 21 June 2010 - 08:40 PM
Asked to many times, I decided to write a CodeSnippet about it
http://www.dreaminco...snippet4460.htm
You should have search the forum first
http://www.dreaminco...snippet4460.htm
You should have search the forum first
#4
Re: How can I make Button that can run another Java file?
Posted 21 June 2010 - 08:41 PM
I think you accidently submitted it twice. This is a duplicate thread of this thread.
EDIT: It seems the duplicate thread has been removed. Thank you.
EDIT: Thank you pbl for merging the topics.
EDIT: It seems the duplicate thread has been removed. Thank you.
EDIT: Thank you pbl for merging the topics.
This post has been edited by Travis1012: 21 June 2010 - 08:46 PM
#5
Re: How can I make Button that can run another Java file?
Posted 21 June 2010 - 08:44 PM
Second times you double post today
Topics merged
Topics merged
#6
Re: How can I make Button that can run another Java file?
Posted 21 June 2010 - 09:16 PM
NetBeans GUI Generator (and Java GUI Generators in general) produce cumbersome, excessive, and unmaintainable code. As Swing is so easy to use, you should really be writing your GUIs by hand. In fact, the Java Tutorials Section has quite a few Swing GUI tutorials, if you want to check them out.
As Java is an Object-Oriented language, (hint) your problem can be solved by creating Objects. You may also want to look into the JFrame setVisible() and dispose() methods.
As Java is an Object-Oriented language, (hint) your problem can be solved by creating Objects. You may also want to look into the JFrame setVisible() and dispose() methods.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote







|