Hallo!
Wer kann mir rede und antwort stehen und vielleicht auf die Schnelle ganz viel helfen! Wäre super nett! Wir müssen eine m3u Format einlesen und diese im Fenster anzeigen, bin wohl zu doof dazu! Aber ohne diese Einlesung und Anzeigen kann ich den Rest leider nicht machen. Schnelle Hilfe wäre PRIMA! Hier schon mal das was ich habe:
Wer kann mir rede und antwort stehen und vielleicht auf die Schnelle ganz viel helfen! Wäre super nett! Wir müssen eine m3u Format einlesen und diese im Fenster anzeigen, bin wohl zu doof dazu! Aber ohne diese Einlesung und Anzeigen kann ich den Rest leider nicht machen. Schnelle Hilfe wäre PRIMA! Hier schon mal das was ich habe:
Code:
import java.awt.*;
import java.awt.event.*;
import java.io.File; // ??
import javax.swing.*;
import javax.swing.plaf.FileChooserUI; // ??
/*
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.KeyStroke;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.JFrame;*/
public class MP3GUI implements ActionListener, ItemListener {
JTextArea output;
JScrollPane scrollPane;
public JMenuBar createMenuBar() {
JMenuBar menuBar;
JMenu menu;
JMenuItem menuItem;
// Create the menu bar.
menuBar = new JMenuBar();
// Build the first menu.
menu = new JMenu("Datei");
menu.setMnemonic(KeyEvent.VK_D);
menu.getAccessibleContext().setAccessibleDescription( "Dateioperationen");
menuBar.add(menu);
// a group of JMenuItems
menuItem = new JMenuItem("Öffnen...", KeyEvent.VK_F);
menuItem.setMnemonic(KeyEvent.VK_F);
menuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_F, ActionEvent.ALT_MASK));
menuItem.addActionListener(this);
menu.add(menuItem);
menuItem = new JMenuItem("Speichern...", KeyEvent.VK_S);
menuItem.setMnemonic(KeyEvent.VK_S);
menuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_S, ActionEvent.ALT_MASK));
menuItem.addActionListener(this);
menu.add(menuItem);
menu.addSeparator();
menuItem = new JMenuItem("Beenden", KeyEvent.VK_B);
menuItem.setMnemonic(KeyEvent.VK_B);
menuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_B, ActionEvent.ALT_MASK));
menuItem.addActionListener(this);
menu.add(menuItem);
// Build second menu in the menu bar.
menu = new JMenu("Sortieren");
menu.setMnemonic(KeyEvent.VK_S);
menu.getAccessibleContext().setAccessibleDescription( "This menu does nothing");
menuBar.add(menu);
// a group of JMenuItems
menuItem = new JMenuItem("Sortieren nach Interpret und Stück", KeyEvent.VK_I);
menuItem.setMnemonic(KeyEvent.VK_I);
menuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_I, ActionEvent.ALT_MASK));
menuItem.addActionListener(this);
menu.add(menuItem);
menuItem = new JMenuItem("Sortieren nach Spielzeit", KeyEvent.VK_Z);
menuItem.setMnemonic(KeyEvent.VK_Z);
menuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_Z, ActionEvent.ALT_MASK));
menuItem.addActionListener(this);
menu.add(menuItem);
menuItem = new JMenuItem("Sortieren nach Dateinamen", KeyEvent.VK_N);
menuItem.setMnemonic(KeyEvent.VK_N);
menuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_N, ActionEvent.ALT_MASK));
menuItem.addActionListener(this);
menu.add(menuItem);
return menuBar;
}
public Container createContentPane() {
//Create the content-pane-to-be.
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setOpaque(true);
//Create a scrolled text area.
output = new JTextArea(5, 30);
output.setLineWrap(true);
// output.setBorder(10);
output.setEditable(false);
scrollPane = new JScrollPane(output);
//Add the text area to the content pane.
contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(new JLabel("Dateiname Sortiert nach ???", JLabel.CENTER), BorderLayout.SOUTH);
return contentPane;
}
// Create the GUI and show it. For thread safety,
//this method should be invoked from the
// event-dispatching thread.
private static void createAndShowGUI() {
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
JFrame frame = new JFrame("MP3-Playlisten sortieren");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
MP3GUI gui = new MP3GUI();
frame.setJMenuBar(gui.createMenuBar());
frame.setContentPane(gui.createContentPane());
//Display the window.
frame.setSize(600, 500);
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() { createAndShowGUI(); } });
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() instanceof JMenuItem)
{
if(e.getActionCommand().equals("Öffnen..."))
{
// System.out.println("Öffnen...");
JFileChooser chooser = new JFileChooser();
/* ExampleFileFilter filter = new ExampleFileFilter();
filter.addExtension("jpg");
filter.addExtension("gif");
filter.setDescription("JPG & GIF Images");
chooser.setFileFilter(filter);*/
int returnVal = chooser.showOpenDialog(chooser);
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose to open this file: " +
chooser.getSelectedFile().getName());
String filecontent = contentOfFile(chooser.getSelectedFile().getName());
}
}
else
if(e.getActionCommand().equals("Speichern..."))
{
System.out.println("Speichern...");
}
else
if(e.getActionCommand().equals("Beenden"))
{
System.exit(0);
}
else
if(e.getActionCommand().equals("Sortieren nach Interpret und Stück"))
{
System.out.println("Sortieren nach Interpret und Stück");
}
else
if(e.getActionCommand().equals("Sortieren nach Spielzeit"))
{
System.out.println("Sortieren nach Spielzeit");
}
else
if(e.getActionCommand().equals("Sortieren nach Dateinamen"))
{
System.out.println("Sortieren nach Dateinamen");
}
}
}
private String contentOfFile(String filename) throws IOException {
return "";
}
public void itemStateChanged(ItemEvent arg0) {
// TODO Auto-generated method stub
}
}
DANKE