codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Jtabbedpane..  sam_02 at 09:23 on Tuesday, February 27, 2007
 

i have a question about jtabbedpane..

I have 2 classes.. one main with the JFrame and a JTabbedpane, the other with a JPanel with other swing components..

I want to add the JPanel class as a tab on the JTabbedpane in the main class...

Main class...

import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import com.jgoodies.forms.factories.*;
import com.jgoodies.forms.layout.*;
import com.jgoodies.uif_lite.panel.*;


public class layout extends JFrame {
public layout() {
initComponents();
}


public static void main(String[] args) {

layout frame = new layout();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);

frame.setVisible(true);

}


private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents

dialogPane = new JPanel();
contentPanel = new JPanel();
tabbedPane1 = new JTabbedPane();
CellConstraints cc = new CellConstraints();

//======== this ========
setTitle("RS Media Editing Suite - TEST");
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());


// test haha = new test(); //
// tabbedPane1.addTab("TAB 1", haha); //


//======== dialogPane ========
{
dialogPane.setBorder(Borders.DIALOG_BORDER);

// JFormDesigner evaluation mark
dialogPane.setBorder(new javax.swing.border.CompoundBorder(
new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
"", javax.swing.border.TitledBorder.CENTER,
javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
java.awt.Color.red), dialogPane.getBorder())); dialogPane.addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});

dialogPane.setLayout(new BorderLayout());

//======== contentPanel ========
{
contentPanel.setLayout(new FormLayout(
"default",
"top:default"));
contentPanel.add(tabbedPane1, cc.xy(1, 1));
}
dialogPane.add(contentPanel, BorderLayout.CENTER);
}
contentPane.add(dialogPane, BorderLayout.CENTER);
pack();
setLocationRelativeTo(getOwner());
// JFormDesigner - End of component initialization //GEN-END:initComponents
}

// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JPanel dialogPane;
private JPanel contentPanel;
private JTabbedPane tabbedPane1;
// JFormDesigner - End of variables declaration //GEN-END:variables
}


JPanel class.... I know that I need to extend to the main class but how?

import javax.swing.*;
import com.jgoodies.forms.layout.*;

public class test extends JPanel {
public test() {
initComponents();
}

private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents

button1 = new JButton();
CellConstraints cc = new CellConstraints();

//======== this ========

// JFormDesigner evaluation mark
setBorder(new javax.swing.border.CompoundBorder(
new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
"", javax.swing.border.TitledBorder.CENTER,
javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
java.awt.Color.red), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});

setLayout(new FormLayout(
"default",
"default"));

//---- button1 ----
button1.setText("TEST");
add(button1, cc.xy(1, 1));
// JFormDesigner - End of component initialization //GEN-END:initComponents
}

// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables

private JButton button1;
// JFormDesigner - End of variables declaration //GEN-END:variables
}


  Re: Jtabbedpane..  sam_02 at 09:39 on Tuesday, February 27, 2007
 

nevermind... silly mistake








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..
•  Re: Security - Code verify
•  Job @ EarlySail
•  Job @ EarlySail (perl)


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007