VISUAL BASIC 2010 A custom window shade designer charges a base fee of $50 per s
ID: 3649125 • Letter: V
Question
VISUAL BASIC 2010A custom window shade designer charges a base fee of $50 per shade. Additionally, charges are added fro certain styles, sizes and colors as follows:
Styles:
Regular shades Add $0
Folding shades Add $10
Roman shades Add $15
Sizes:
25 inches wide Add $0
27 inches wide Add $2
32 inches wide Add $4
40 inches wide Add $6
Colors:
Natural Add $5
Blue Add $0
Teal Add $0
Red Add $0
Green Add $0
Create an application that allows the user to select the style, size, color and number of shades fromm list boxes or combo boxes. If a combo box is used, set it Drop-Downstyle property in such a way that new items cannot be added to the customer list be the user. The total charges should be displayed on a second form.
Report Abuse
Explanation / Answer
public ShadeDesigner() { //display a title setTitle("Shade Designer"); // Specify what happens when the close button is clicked. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create the banner on a panel and add it to the North region. buildBannerPanel(); add(bannerPanel, BorderLayout.NORTH); stylesPanel(); add(stylesPanel, BorderLayout.WEST); sizePanel(); add(sizePanel, BorderLayout.CENTER); colorPanel(); add(colorPanel, BorderLayout.EAST); buttonPanel(); add(buttonPanel, BorderLayout.SOUTH); pack(); setVisible(true); } //build the bannerpanel private void buildBannerPanel() { bannerPanel = new JPanel(); bannerPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); banner = new JLabel("Shade Designer"); banner.setFont(new Font("SanSerif", Font.BOLD, 24)); bannerPanel.add(banner); } //stylepanel private void stylesPanel() { JLabel styleTitle = new JLabel("Select a Style."); stylesPanel = new JPanel(); stylesPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); stylesList = new JList (styles); stylesList.setVisibleRowCount(ROWS); JScrollPane stylesScrollPane = new JScrollPane(stylesList); stylesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); stylesList.addListSelectionListener(new stylesListListener()); stylesPanel.setLayout(new BorderLayout()); stylesPanel.add(styleTitle, BorderLayout.NORTH); stylesPanel.add(stylesScrollPane, BorderLayout.CENTER); Styles = new JTextField (5); Styles.setEditable(false); //stylesPanel.add(StylesLabel, BorderLayout.CENTER); stylesPanel.add(Styles, BorderLayout.SOUTH); } private class stylesListListener implements ListSelectionListener { public void valueChanged (ListSelectionEvent e) { String selection = (String) stylesList.getSelectedValue(); Styles.setText(selection); } } //size panel private void sizePanel() { JLabel sizeTitle = new JLabel("Select a Size."); sizePanel = new JPanel(); sizePanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); sizeList = new JList (size); sizeList.setVisibleRowCount(ROWS); JScrollPane stylesScrollPane = new JScrollPane(sizeList); sizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); sizeList.addListSelectionListener(new sizeListListener()); sizePanel.setLayout(new BorderLayout()); sizePanel.add(sizeTitle, BorderLayout.NORTH); sizePanel.add(stylesScrollPane, BorderLayout.CENTER); //sizeLabel = new JLabel("Style Selected: "); Size = new JTextField (5); Size.setEditable(false); //stylesPanel.add(StylesLabel, BorderLayout.CENTER); sizePanel.add(Size, BorderLayout.SOUTH); } private class sizeListListener implements ListSelectionListener { public void valueChanged (ListSelectionEvent e) { String selection = (String) sizeList.getSelectedValue(); Size.setText(selection); } } //color panel private void colorPanel() { JLabel colorTitle = new JLabel("Select a Color."); colorPanel = new JPanel(); colorPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); colorList = new JList (colors); colorList.setVisibleRowCount(ROWS); JScrollPane colorScrollPane = new JScrollPane(colorList); colorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); colorList.addListSelectionListener(new colorListListener()); colorPanel.setLayout(new BorderLayout()); colorPanel.add(colorTitle, BorderLayout.NORTH); colorPanel.add(colorScrollPane, BorderLayout.CENTER); //sizeLabel = new JLabel("Style Selected: "); Color = new JTextField (5); Color.setEditable(false); //stylesPanel.add(StylesLabel, BorderLayout.CENTER); colorPanel.add(Color, BorderLayout.SOUTH); } private class colorListListener implements ListSelectionListener { public void valueChanged (ListSelectionEvent e) { String selection = (String) colorList.getSelectedValue(); Color.setText(selection); } } //button panel private void buttonPanel() { calcButton= new JButton ("Calculate Charges"); calcButton.addActionListener(new calcButtonListener()); ExitButton = new JButton ("Exit"); ExitButton.addActionListener(new ExitButtonListener()); buttonPanel = new JPanel(); buttonPanel.add(calcButton); buttonPanel.add(ExitButton); } private class calcButtonListener implements ActionListener { //actionPerformed method parementer e an actionevent object public void actionPerformed(ActionEvent e) { // Create a DecimalFormat object. DecimalFormat dollar = new DecimalFormat("#,##0.00"); // Display the total. JOptionPane.showMessageDialog(null, "TotalCharges: $" + dollar.format(totalCharges)); } } private class ExitButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { //Exit the applicaiton System.exit(0); } } //static void main for the string public static void main(String[] args) { new ShadeDesigner(); }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.