ranindu 0 Newbie Poster
/*
<applet code="Assign2.class" width=350 height=350>
</applet>
*/


import java.awt.event.*;
import javax.swing.*;
import java.awt.*;



public class Assign2 extends JApplet {


private JButton buttons[]=new JButton[5];
private String labels[]= {"Footwear","Kitchen Goods","Stationery","Music","Ladies Wear"};
private JPanel thePanel;
private JMenu editMenu,optionsMenu;
public JMenuItem items[]=new JMenuItem[5];
private JRadioButton options[]= new JRadioButton[3];
private JMenuBar menubar;
private Color colors[]= {Color.yellow,Color.red,Color.magenta,Color.cyan,Color.green};



private int max_bar_width=250;
private int bar_height= 25;
private int bar_width[]= {100,100,100,100,100};
private int hits[]= {200,200,200,200,200};
private double percentage[]={80.00,80.00,80.00,80.00,80.00};


private int x_gap= 15;
private int y_gap=35;
private int gap_between_bars=15;
private String stat= "Applet started!";


private int option=0;


public void init(){
Container pane = getContentPane();
thePanel = new JPanel();
thePanel.setLayout(null);


menubar = new JMenuBar();
setJMenuBar(menubar);
editMenu = new JMenu ("Edit");
menubar.add(editMenu);
baroptionsMenu = new JMenu("Options");  menu


for (int i=0; i <5;i++) {
buttons= new JButton(labels);
buttons.setBackground(colors);
buttons.setSize(115,30);
thePanel.add(buttons);
buttons.addActionListener(new ButtonHandler());
}


buttons[0].setLocation(0,260);
buttons[1].setLocation(115,260);
buttons[2].setLocation(230,260);
buttons[3].setLocation(0,290);
buttons[4].setLocation(115,290);


for (int i=0; i <5;i++) {
items= new JMenuItem(labels);
editMenu.add(items);
items.addActionListener(new MenuHandler());
}
editMenu.add(optionsMenu);



ButtonGroup group = new ButtonGroup();


options[0]=new JRadioButton("Color");
options[0].setSelected(true);
options[0].addActionListener(new OptionHandler());
options[1]=new JRadioButton("Text");
options[1].setSelected(false);
options[1].addActionListener(new OptionHandler());


options[2]=new JRadioButton("Hits");
options[2].setSelected(false);
options[2].addActionListener(new OptionHandler());



group.add(options[0]);
group.add(options[1]);
group.add(options[2]);
optionsMenu.add(options[0]);
optionsMenu.add(options[1]);
optionsMenu.add(options[2]);


pane.add(thePanel);


}
public void paint(Graphics g){
super.paint(g);
calculateChanges();
paintBars(g);


}
public void update(Graphics g){
paint(g);


}



public void paintBars(Graphics g){
Graphics2D g2d = ( Graphics2D ) g;


for (int i=0;i<5;i++) {
g2d.setPaint( colors );


g2d.fill3DRect( x_gap , y_gap+((bar_height+gap_between_bars)*(i)), bar_width, bar_height, true);
g.drawString(hits + ", " + percentage+"%",bar_width+x_gap+10,y_gap + bar_height + ((bar_height+gap_between_bars)*(i)));
}



}



public void calculateChanges(){


int total =0;// initialize total to 0
for(int i=0; i<5; i++) {
bar_width=hits;// set hit=pixel
total += hits; …
ranindu 0 Newbie Poster

here is the code.... below is my problem.............

/*
<applet code="Assign2.class" width=350 height=350>
</applet>
*/


import java.awt.event.*;
import javax.swing.*;
import java.awt.*;


/*


Class Name - Assign2



PRIVATE FEATURES


private JButton buttons[] // array to store buttons
private String labels[]  // array to stoer the department name
private JPanel thePanel; // JPanel object
private JMenu editMenu,optionsMenu; //JMenu objects for EDIT menu and OPTIONS menu
public JMenuItem items[]  //array to store 'department name' menus inside EDIT menu
private JRadioButton options[] // array to store Color, Text, Hits options as radio buttons
private JMenuBar menubar; // MAIN MENU for the applet
private Color colors[] // array to hold colors the given colors



private final int max_bar_width // maximum width of a bar- set to 250, cna not be changed
private final int bar_height // maximum height of a bar
private int bar_width[] // array to store the bar widths for each department, can be changed by increasing the hits, 1 hit= 1 pixel
private int hits[]// array to store the number of hits for each department
private double percentage[] // array to store the number of percentage for each department


private int x_gap // x co-ordinate of each bar
private int y_gap / y co-ordinate of each bar
private int gap_between_bars // the height between each bar when displayed in the applet
private String stat // string that states the current status of the applet


private int option // helps to choose between the 3 options, "Color, Text, Hits"
// Color =0, …
ranindu 0 Newbie Poster

hi,
When you are using the Jprogressbar the % completed is usually printed in the middle of the bar. Can you change it to be printed at the end of the completed % . is there a method for that??? can anyone help me with this please..............:((