B
bmwGTR
Gast
Hallo liebe Forumsgemeinde,
ich programmiere gerade ein Programm mit Swing. In diesem Programm habe ich ein Fenster mit JFrame und Internal Frames mit JInternalFrames. Mein Problem ist, das ein paar Befehle im folgenden Code nicht ausgeführt werden: (Die Klasse ist von JFrame abgeleitet, ich benutze Border Layout (für ganze Fenster) und Grid Layout (für das BorderLayout.Center)
[Java]
String name,name1;
ObjectName poolName =((ObjectInstance)object).getObjectName();
JPanel panel1 = new JPanel();
if (poolName.toString().contains("java.lang:type=MemoryPool")) {
CompositeDataSupport data = (CompositeDataSupport) mbsc.getAttribute(poolName, "Usage");
Long zahl1,zahl2,prozent;
DecimalFormat df = new DecimalFormat("0.00");
GridLayout layout1=new GridLayout (-1,1,10,30);
float zahl3,zahl4;
zahl1=(Long) data.get("committed");
zahl2=(Long) data.get("used");
zahl3=zahl1/1024;
zahl3=zahl3/1024;
zahl4=zahl2/1024;
zahl4=zahl4/1024;
prozent=zahl2*100/zahl1;
name=poolName.toString();
name1=name.substring(31);
JLabel l = new JLabel (name1+": "+df.format(zahl3)+" MB / "+df.format(zahl4)+" MB "+prozent+"%");
if(prozent>89)
{l.setForeground(Color.RED);}
if(prozent>69&&prozent<90)
{l.setForeground(Color.ORANGE);}
panel1.setLayout(layout1); //Diese
panel1.add(l); //3 Befehle
panel1.setBackground(Color.WHITE); //werden nicht ausgeführt!
this.setVisible(true);
}
this.add(panel1,BorderLayout.CENTER);
this.pack();
[/code]
Vielen Dank im Vorraus für die Hilfe.
ich programmiere gerade ein Programm mit Swing. In diesem Programm habe ich ein Fenster mit JFrame und Internal Frames mit JInternalFrames. Mein Problem ist, das ein paar Befehle im folgenden Code nicht ausgeführt werden: (Die Klasse ist von JFrame abgeleitet, ich benutze Border Layout (für ganze Fenster) und Grid Layout (für das BorderLayout.Center)
[Java]
String name,name1;
ObjectName poolName =((ObjectInstance)object).getObjectName();
JPanel panel1 = new JPanel();
if (poolName.toString().contains("java.lang:type=MemoryPool")) {
CompositeDataSupport data = (CompositeDataSupport) mbsc.getAttribute(poolName, "Usage");
Long zahl1,zahl2,prozent;
DecimalFormat df = new DecimalFormat("0.00");
GridLayout layout1=new GridLayout (-1,1,10,30);
float zahl3,zahl4;
zahl1=(Long) data.get("committed");
zahl2=(Long) data.get("used");
zahl3=zahl1/1024;
zahl3=zahl3/1024;
zahl4=zahl2/1024;
zahl4=zahl4/1024;
prozent=zahl2*100/zahl1;
name=poolName.toString();
name1=name.substring(31);
JLabel l = new JLabel (name1+": "+df.format(zahl3)+" MB / "+df.format(zahl4)+" MB "+prozent+"%");
if(prozent>89)
{l.setForeground(Color.RED);}
if(prozent>69&&prozent<90)
{l.setForeground(Color.ORANGE);}
panel1.setLayout(layout1); //Diese
panel1.add(l); //3 Befehle
panel1.setBackground(Color.WHITE); //werden nicht ausgeführt!
this.setVisible(true);
}
this.add(panel1,BorderLayout.CENTER);
this.pack();
[/code]
Vielen Dank im Vorraus für die Hilfe.