Welcome to Dream.In.Code
Become a Java Expert!

Join 150,201 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,011 people online right now. Registration is fast and FREE... Join Now!




Calling Methods [Closed]

 
Reply to this topicStart new topic

Calling Methods [Closed]

abgorn
24 Sep, 2008 - 02:27 AM
Post #1

Hello Crap for Brains
Group Icon

Joined: 5 Jun, 2008
Posts: 912



Thanked: 5 times
Dream Kudos: 50
My Contributions
I've been working on a text editor (http://www.dreamincode.net/forums/showtopic60239.htm) but I'm having trouble cllaing methods that are non-static. I know that you can't call a non-static method in another class, but I'm having trouble finding out how to fix this problem. Here one of the classes:
java

package texteditor;

public class Open extends javax.swing.JDialog {

public Open(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}

public static void OpenFileUI() {
Open.Open();
}

private void initComponents() {

jScrollPane1 = new javax.swing.JScrollPane();
OpenList = new javax.swing.JList(FileManagment.FileList);
OpenButton = new javax.swing.JButton();
CancelButton = new javax.swing.JButton();
InfoLabel = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Open File...");

OpenList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
OpenList.setToolTipText("Select File to Open");
jScrollPane1.setViewportView(OpenList);

OpenButton.setText("Open...");

CancelButton.setText("Cancel");

InfoLabel.setText("Open File...");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(InfoLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 181, Short.MAX_VALUE)
.addComponent(OpenButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(CancelButton)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(OpenButton)
.addComponent(CancelButton)
.addComponent(InfoLabel))
.addContainerGap())
);

pack();
}


public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
ReadFileUI dialog = new ReadFileUI(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}

private javax.swing.JButton CancelButton;
public static javax.swing.JLabel InfoLabel;
private javax.swing.JButton OpenButton;
public static javax.swing.JList OpenList;
private javax.swing.JScrollPane jScrollPane1;

}


This post has been edited by abgorn: 24 Sep, 2008 - 08:07 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 05:01AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month