G
Guest
Gast
hi leutz..
kann da mal einer helfen!!
das prog kann man ausführen.. hab es auf ein min. reduziert
soll allgemeingültig bleiben, deswegen muss ich alles berechnen.
der fehler liegt glaub bei der variable test!! da will ich mir merken wo der das panel von den buttons in reihe 2 beginnt.
dort soll auch der begin des panels in reihe 3 sein!!
die panels sollen gleich in der richtigen höhe(so wie in den arrays eingetragen) geaddet werden und je nach knopfdruck sichtbar/unsichtbar sein!!
einfach auf die 1 drücken und dann die 2 reihe durchprobieren!! da ist das letzte feld um 2 * button höhe zu tief!!
kann mir bitte wer helfen.. komm einfach net drauf!!
ich finde sowas ähnliches nirgends... wenn wer ne leichtere lösung oder nen link auf was ähnliches.. wär auch cool.
den fehler zu finden wär natürlich das beste. hat mich schon zeit gekostet!!
kann da mal einer helfen!!
das prog kann man ausführen.. hab es auf ein min. reduziert
soll allgemeingültig bleiben, deswegen muss ich alles berechnen.
der fehler liegt glaub bei der variable test!! da will ich mir merken wo der das panel von den buttons in reihe 2 beginnt.
dort soll auch der begin des panels in reihe 3 sein!!
die panels sollen gleich in der richtigen höhe(so wie in den arrays eingetragen) geaddet werden und je nach knopfdruck sichtbar/unsichtbar sein!!
einfach auf die 1 drücken und dann die 2 reihe durchprobieren!! da ist das letzte feld um 2 * button höhe zu tief!!
kann mir bitte wer helfen.. komm einfach net drauf!!
Code:
// Datei DateiLesen.java
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.util.regex.Pattern;
import java.awt.*;
public class look extends JFrame implements ActionListener
{
private void place(Component comp,int x,int y,int width,int height)
{
comp.setBounds(x, y, width, height);
add(comp);
}
// Anfang Variablen
JButton btn, btn_, btn2_;
JScrollPane scroller;
String BTN_WRITING;
int MENU_BTN_WIDTH, BTN_HEIGHT, btn_realheight, btn_realheight1, btn_realheight2, btnY;
int BTN_STYLE, BTN_CHARSIZE, R, G, B;
int anz_btn, anz_btn1, anz_btn2;
int real_height, real_height1, real_height2;
int i, l, m, hoehe;
int coord_r3;
int begin_panel, begin_panel2;
JPanel jp, jp_Materialwirtschaft, jp_Zeitwirtschaft, jp_Kalkulation, jp_Verkauf;
Container cp;
String[] arr_hauptmenu = new String [20];
String[][] arr_ = new String [20][20];
String[][] arr_mat = new String [20][20];
String[][] arrr = new String [20][20];
String[][] arr_zeit = new String [20][20];
JPanel[] arr_panel = new JPanel [20];
JPanel[] arr_panel2 = new JPanel [20];
int[] arr_hauptmenu_coords = new int[20];
int[] arr_hauptmenu_coords2 = new int[20];
// Ende Variablen
public look (String title)
{
// Frame-Initialisierung
super(title);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent evt) { System.exit(0); }
});
// Einstellungen*********************************************************************
MENU_BTN_WIDTH=200; //Menu breite
BTN_HEIGHT=25; //höhe der Buttons
BTN_STYLE=1|2; //Style des Buttons PLAIN, BOLD, ITALIC, oder BOLD+ITALIC
BTN_WRITING="Comic Sans MS"; //Schriftart der Buttons
BTN_CHARSIZE=12; //Schriftgrösse der Buttons
R=255;G=255;B=255; //Farbe Schrift der Buttons
btn_realheight=0; //Variable die immer bei begin eines JPanels auf 0 gesetzt wird und dann um BTN_HEIGHT erhöht wird
int frameWidth = 800; //Fensterbreite
int frameHeight = 600; //Fensterhöhe
// Ende Einstellungen****************************************************************
getArrays();
setSize(frameWidth, frameHeight);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (d.width - getSize().width) / 2;
int y = (d.height - getSize().height) / 2 ;
setLocation(x, y);
cp = getContentPane();
cp.setLayout(null);
cp.setBackground(new Color(86,148,200));
jp = new JPanel();
jp.setLayout(null);
jp.setBackground(new Color(255,255,255));
jp.setBounds(20, 0, MENU_BTN_WIDTH, frameHeight);
cp.add(jp);
real_height = 0;
// Anfang Komponenten Menu 2 Reihe***************************************************
for(i=0;i<arr_hauptmenu.length;i++) // Solange Hauptmenu noch felder hat
{
btn_realheight1 = 0;
real_height1 = 0;
anz_btn1 = 0;
arr_panel[i] = new JPanel();
arr_panel[i].setLayout(null);
arr_panel[i].setVisible(false); // soll nicht gleich von anfang an Visible sein
btn_realheight2 = 0;
real_height2 = 0;
anz_btn2 = 0;
arr_panel2[i] = new JPanel();
arr_panel2[i].setLayout(null);
arr_panel2[i].setVisible(false); // soll nicht gleich von anfang an Visible sein
if(arr_hauptmenu[i] !="") //Wird nur angezeigt wenn etwas in diesem Array-Feld steht
{
int test = 0;
btn = new JButton(arr_hauptmenu[i]);
btn.setBounds(0, btn_realheight+=real_height, MENU_BTN_WIDTH, BTN_HEIGHT);
real_height = BTN_HEIGHT;
getFontButton(btn);
arr_hauptmenu_coords[i] = btn_realheight;
jp.add(btn);
for(l=0;l<arr_.length;l++)
{
if(arr_[i][l] !="") //Wird nur angezeigt wenn etwas in diesem Array-Feld steht
{
btn_ = new JButton(arr_[i][l]);
btn_.setBounds(0, btn_realheight1+=real_height1, MENU_BTN_WIDTH, BTN_HEIGHT);
test = arr_hauptmenu_coords[i];
real_height1 = BTN_HEIGHT;
getFontButton(btn_);
arr_panel[i].add(btn_);
anz_btn1++;
// Reihe 3*********************************
for(m=0; m<arr_mat.length; m++)
{
hoehe = 0;
if(arr_mat[i][m] !="")// && arr_mat[i][m] !=null
{
if(i==0)
test += hoehe; // das ist irgendwie falsch. hier muss ich mir die höhe irgendwie merken!!
hoehe = BTN_HEIGHT;
btn2_ = new JButton(arr_mat[i][m]);
btn2_.setBounds(0, btn_realheight2+=real_height2, MENU_BTN_WIDTH, BTN_HEIGHT);
real_height2 = BTN_HEIGHT;
getFontButton(btn2_);
arr_panel2[i].add(btn2_);
anz_btn2++;
}
arr_panel2[i].setBounds(20 + MENU_BTN_WIDTH*2, test, MENU_BTN_WIDTH, anz_btn2*BTN_HEIGHT); //test stimmt hier nicht
cp.add(arr_panel2[i]);
}
test = 0;
anz_btn2 = 0;
// Ende Reihe 3 **************************
}
}
// Oberkante des Panels merken
begin_panel = arr_hauptmenu_coords[i];
arr_panel[i].setBounds(20 + MENU_BTN_WIDTH, begin_panel, MENU_BTN_WIDTH, anz_btn1*BTN_HEIGHT);
cp.add(arr_panel[i]);
}
}
// Ende Komponenten Menu 2 Reihe*****************************************************
setResizable(true);
setVisible(true);
}
public static void main(String[] args) throws IOException
{
new look("fff");
}
// ActionListener*******************************************************************************************
public void actionPerformed(ActionEvent e)
{
String cmd = e.getActionCommand();
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "1")
{
getVisibleUnvisible(0);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "2")
{
getVisibleUnvisible(1);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "3")
{
getVisibleUnvisible(2);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "4")
{
getVisibleUnvisible(3);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "5")
{
getVisibleUnvisible(4);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "6")
{
getVisibleUnvisible(5);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "7")
{
getVisibleUnvisible(6);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "8")
{
getVisibleUnvisible(7);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "9")
{
getVisibleUnvisible(8);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "10")
{
getVisibleUnvisible(9);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "11")
{
getVisibleUnvisible(10);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "12")
{
getVisibleUnvisible(11);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "13")
{
getVisibleUnvisible(12);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "14")
{
getVisibleUnvisible(13);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "1.1")
{
getVisibleUnvisible2(0);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "1.2")
{
getVisibleUnvisible2(1);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "1.3")
{
getVisibleUnvisible2(2);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "1.4")
{
getVisibleUnvisible2(3);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "1.5")
{
getVisibleUnvisible2(4);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "1.6")
{
getVisibleUnvisible2(5);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "1.11")
{
getVisibleUnvisible2(10);
System.out.println(arr_mat.length);
}
// btn(JComboButton)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(e.getActionCommand() == "1.13")
{
getVisibleUnvisible2(12);
}
}
// *****************************************
// ************** METHODEN *****************
public void getArrays()
{
// Hauptmenu
arr_hauptmenu[0] = "1";
arr_hauptmenu[1] = "2";
arr_hauptmenu[2] = "3";
arr_hauptmenu[3] = "4";
arr_hauptmenu[4] = "5";
arr_hauptmenu[5] = "6";
arr_hauptmenu[6] = "";
arr_hauptmenu[7] = "";
arr_hauptmenu[8] = "";
arr_hauptmenu[9] = "10";
arr_hauptmenu[10] = "11";
arr_hauptmenu[11] = "12";
arr_hauptmenu[12] = "13";
arr_hauptmenu[13] = "14";
arr_hauptmenu[14] = "";
arr_hauptmenu[15] = "";
arr_hauptmenu[16] = "";
arr_hauptmenu[17] = "";
arr_hauptmenu[18] = "";
arr_hauptmenu[19] = "";
// Menu Materialwirtschaft
arr_[0][0] = "1.1";
arr_[0][1] = "1.2";
arr_[0][2] = "1.3";
arr_[0][3] = "1.4";
arr_[0][4] = "1.5";
arr_[0][5] = "1.6";
arr_[0][6] = "";
arr_[0][7] = "";
arr_[0][8] = "";
arr_[0][9] = "";
arr_[0][10] = "1.11";
arr_[0][11] = "";
arr_[0][12] = "1.13";
arr_[0][13] = "";
arr_[0][14] = "";
arr_[0][15] = "";
arr_[0][16] = "";
arr_[0][17] = "";
arr_[0][18] = "";
arr_[0][19] = "";
// Menu Artikelverwaltung
arr_mat[0][0] = "1.1.1";
arr_mat[0][1] = "1.1.2";
arr_mat[0][2] = "1.1.3";
arr_mat[0][3] = "1.1.4";
arr_mat[0][4] = "1.1.5";
arr_mat[0][5] = "1.1.6";
arr_mat[0][6] = "1.1.7";
arr_mat[0][7] = "";
arr_mat[0][8] = "";
arr_mat[0][9] = "";
arr_mat[0][10] = "1.1.11";// umbenennen
arr_mat[0][11] = "1.1.12";
arr_mat[0][12] = "";
arr_mat[0][13] = "";
arr_mat[0][14] = "";
arr_mat[0][15] = "";
arr_mat[0][16] = "";
arr_mat[0][17] = "";
arr_mat[0][18] = "";
arr_mat[0][19] = "";
// Menu Inventurbearbeitung
arr_mat[1][0] = "test2";
arr_mat[1][1] = "";
arr_mat[1][2] = "";
arr_mat[1][3] = "";
arr_mat[1][4] = "";
arr_mat[1][5] = "";
arr_mat[1][6] = "";
arr_mat[1][7] = "";
arr_mat[1][8] = "";
arr_mat[1][9] = "";
arr_mat[1][10] = "";
arr_mat[1][11] = "";
arr_mat[1][12] = "";
arr_mat[1][13] = "";
arr_mat[1][14] = "";
arr_mat[1][15] = "";
arr_mat[1][16] = "";
arr_mat[1][17] = "";
arr_mat[1][18] = "";
arr_mat[1][19] = "";
// Menu Stücklistenverwaltung
arr_mat[2][0] = "test3";
arr_mat[2][1] = "";
arr_mat[2][2] = "";
arr_mat[2][3] = "";
arr_mat[2][4] = "";
arr_mat[2][5] = "";
arr_mat[2][6] = "";
arr_mat[2][7] = "";
arr_mat[2][8] = "";
arr_mat[2][9] = "";
arr_mat[2][10] = "";
arr_mat[2][11] = "";
arr_mat[2][12] = "";
arr_mat[2][13] = "";
arr_mat[2][14] = "";
arr_mat[2][15] = "";
arr_mat[2][16] = "";
arr_mat[2][17] = "";
arr_mat[2][18] = "";
arr_mat[2][19] = "";
// Menu Lagerverwaltung
arr_mat[3][0] = "test4";
arr_mat[3][1] = "";
arr_mat[3][2] = "";
arr_mat[3][3] = "";
arr_mat[3][4] = "";
arr_mat[3][5] = "";
arr_mat[3][6] = "";
arr_mat[3][7] = "";
arr_mat[3][8] = "";
arr_mat[3][9] = "";
arr_mat[3][10] = "";
arr_mat[3][11] = "";
arr_mat[3][12] = "";
arr_mat[3][13] = "";
arr_mat[3][14] = "";
arr_mat[3][15] = "";
arr_mat[3][16] = "";
arr_mat[3][17] = "";
arr_mat[3][18] = "";
arr_mat[3][19] = "";
// Menu Nettobedarfsrechnung
arr_mat[4][0] = "test5";
arr_mat[4][1] = "";
arr_mat[4][2] = "";
arr_mat[4][3] = "";
arr_mat[4][4] = "";
arr_mat[4][5] = "";
arr_mat[4][6] = "";
arr_mat[4][7] = "";
arr_mat[4][8] = "";
arr_mat[4][9] = "";
arr_mat[4][10] = "";
arr_mat[4][11] = "";
arr_mat[4][12] = "";
arr_mat[4][13] = "";
arr_mat[4][14] = "";
arr_mat[4][15] = "";
arr_mat[4][16] = "";
arr_mat[4][17] = "";
arr_mat[4][18] = "";
arr_mat[4][19] = "";
// Stochastische Disposition
arr_mat[5][0] = "test6";
arr_mat[5][1] = "";
arr_mat[5][2] = "";
arr_mat[5][3] = "";
arr_mat[5][4] = "";
arr_mat[5][5] = "";
arr_mat[5][6] = "";
arr_mat[5][7] = "";
arr_mat[5][8] = "";
arr_mat[5][9] = "";
arr_mat[5][10] = "";
arr_mat[5][11] = "";
arr_mat[5][12] = "";
arr_mat[5][13] = "";
arr_mat[5][14] = "";
arr_mat[5][15] = "";
arr_mat[5][16] = "";
arr_mat[5][17] = "";
arr_mat[5][18] = "";
arr_mat[5][19] = "";
// Artikelübersichten
arr_mat[10][0] = "";//´das soll mal leer bleiben
arr_mat[10][1] = "";
arr_mat[10][2] = "";
arr_mat[10][3] = "";
arr_mat[10][4] = "";
arr_mat[10][5] = "";
arr_mat[10][6] = "";
arr_mat[10][7] = "";
arr_mat[10][8] = "";
arr_mat[10][9] = "";
arr_mat[10][10] = "";
arr_mat[10][11] = "";
arr_mat[10][12] = "";
arr_mat[10][13] = "";
arr_mat[10][14] = "";
arr_mat[10][15] = "";
arr_mat[10][16] = "";
arr_mat[10][17] = "";
arr_mat[10][18] = "";
arr_mat[10][19] = "";
// Stücklistenausgabe
arr_mat[12][0] = "test13";
arr_mat[12][1] = "";
arr_mat[12][2] = "";
arr_mat[12][3] = "";
arr_mat[12][4] = "";
arr_mat[12][5] = "";
arr_mat[12][6] = "";
arr_mat[12][7] = "";
arr_mat[12][8] = "";
arr_mat[12][9] = "";
arr_mat[12][10] = "";
arr_mat[12][11] = "";
arr_mat[12][12] = "";
arr_mat[12][13] = "";
arr_mat[12][14] = "";
arr_mat[12][15] = "";
arr_mat[12][16] = "";
arr_mat[12][17] = "";
arr_mat[12][18] = "";
arr_mat[12][19] = "";
}
// Diese Funktion macht das Übergebene JPanel sichtbar, und alle anderen unsichtbar!!
public void getVisibleUnvisible(int visi)
{
for(int i=0;i<arr_hauptmenu.length;i++)
{
if(arr_hauptmenu[i] !="") //Wird nur angezeigt wenn etwas in diesem Array-Feld steht
{
arr_panel[i].setVisible(false);
}
}
arr_panel[visi].setVisible(true);
}
// Diese Funktion macht das Übergebene JPanel sichtbar, und alle anderen unsichtbar!!
public void getVisibleUnvisible2(int visi)
{
for(int i=0;i<arr_mat.length;i++)
{
if(arr_[0][i] !="") //Wird nur angezeigt wenn etwas in diesem Array-Feld steht
{
arr_panel2[i].setVisible(false);
}
}
arr_panel2[visi].setVisible(true);
}
public void getFontButton(JButton button)
{
// aussehen des buttons (rausgenommen)
button.addActionListener(this);
}
}//****************ENDE PROGRAMM******************
ich finde sowas ähnliches nirgends... wenn wer ne leichtere lösung oder nen link auf was ähnliches.. wär auch cool.
den fehler zu finden wär natürlich das beste. hat mich schon zeit gekostet!!