H
hannes4711
Gast
hallo,
ich habe mir ein fenster mit reitern erstellt, aber ich kann irgednwie keine klassen da rein laden. oder ist das gar nicht möglich ??
ich habe hier dieses beispiel mit dem tabbedpane:
jetzt möchjte ich das in panel3 die untere klasse(klasse Immer) angezeigt wird. kann ich das nicht irgednwie übergeben ? oder muss ich das alles in die tabbedpanedemo klasse schreiben ???
danke euch !!!
die soll in panel3 zu sehen sein:
ich habe mir ein fenster mit reitern erstellt, aber ich kann irgednwie keine klassen da rein laden. oder ist das gar nicht möglich ??
ich habe hier dieses beispiel mit dem tabbedpane:
jetzt möchjte ich das in panel3 die untere klasse(klasse Immer) angezeigt wird. kann ich das nicht irgednwie übergeben ? oder muss ich das alles in die tabbedpanedemo klasse schreiben ???
danke euch !!!
Code:
public class TabbedPaneDemo extends JPanel {
public TabbedPaneDemo() {
super(new GridLayout(1, 1));
JTabbedPane tabbedPane = new JTabbedPane();
ImageIcon icon = createImageIcon("scribble.jpg");
JComponent panel1 = makeTextPanel("Bestellung");
tabbedPane.addTab("Bestellung", icon, panel1,
"Does nothing");
tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
JComponent panel2 = makeTextPanel("Panel #2");
tabbedPane.addTab("Kunden", icon, panel2,
"Does twice as much nothing");
tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);
JComponent panel3 = new JPanel();
Immer art = new Immer( );
panel3.add(art);
tabbedPane.addTab
("Artikel", icon, panel3,"Still does nothing");
tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);
JComponent panel4 = makeTextPanel(
"Panel #4 (has a preferred size of 410 x 50).");
panel4.setPreferredSize(new Dimension(410, 50));
tabbedPane.addTab("Einstellungen", icon, panel4,
"Does nothing at all");
tabbedPane.setMnemonicAt(3, KeyEvent.VK_4);
//Add the tabbed pane to this panel.
add(tabbedPane);
//The following line enables to use scrolling tabs.
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
}
protected JComponent makeTextPanel(String text) {
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
/** Returns an ImageIcon, or null if the path was invalid. */
protected static ImageIcon createImageIcon(String path) {
java.net.URL imgURL = TabbedPaneDemo.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event dispatch thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("Bestellsystem");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
JComponent newContentPane = new TabbedPaneDemo();
newContentPane.setOpaque(true); //content panes must be opaque
frame.getContentPane().add(new TabbedPaneDemo(),
BorderLayout.CENTER);
//Display the window.
frame.setSize(640,480);
frame.setVisible(true);
}
public static void main(String[] args) {
//Turn off metal's use of bold fonts
UIManager.put("swing.boldMetal", Boolean.FALSE);
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
die soll in panel3 zu sehen sein:
Code:
public class Immer extends JFrame
{
/**
*
*/
private static final long serialVersionUID = 1L;
Container c;
public Immer()
{
c = getContentPane();
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
setLayout(gbl);
gbc.fill = GridBagConstraints.HORIZONTAL;
final JLabel label1 = new JLabel();
final JTextField textField1 = new JTextField();
final JLabel label15 = new JLabel();
final JTextField textField14 = new JTextField();
final JSeparator separator2 = new JSeparator();
final JButton button1 = new JButton();
final JLabel label12 = new JLabel();
final JTextField textField12 = new JTextField();
final JLabel label3 = new JLabel();
final JTextField textField3 = new JTextField();
final JLabel label4 = new JLabel();
final JTextField textField4 = new JTextField();
final JLabel label5 = new JLabel();
final JTextField textField5 = new JTextField();
final JLabel label6 = new JLabel();
final JTextField textField9 = new JTextField();
final JTextField textField8 = new JTextField();
final JSeparator separator1 = new JSeparator();
final JButton button3 = new JButton();
final JButton button4 = new JButton();
final JScrollPane scrollPane1 = new JScrollPane();
final JButton button5 = new JButton();
final JButton button6 = new JButton();
//---- label1 ----
label1.setText("Bestellnr");
add(label1, new GridBagConstraints(16, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
add(textField1, new GridBagConstraints(19, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//---- button1 ----
button1.setText("Hinzuf\u00fcgen");
add(button1, new GridBagConstraints(16, 3, 3, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//---- button4 ----
button4.setText("Entfernen");
add(button4, new GridBagConstraints(19, 10, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//======== scrollPane1 ========
String[] columnNames = {"Art_No",
"Bezeichnung",
"Preis",
"Menge"};
Object[][] data =
{
{"1", "Campione",
"Snowboarding", new Integer(5), new Boolean(false)},
{"2", "Huml",
"Rowing", new Integer(3), new Boolean(true)},
final JTable table1 = new JTable(data, columnNames);
table1.setPreferredScrollableViewportSize(new Dimension(350, 80));
{
scrollPane1.setViewportView(table1);
}
add(scrollPane1, new GridBagConstraints(16, 11, 14, 5, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//---- button5 ----
button5.setText("Abbrechen");
add(button5, new GridBagConstraints(26, 19, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//---- button6 ----
button6.setText("Bestellen");
add(button6, new GridBagConstraints(27, 19, 3, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
}
class BasicButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
}
}
}