Scrollable JMenu?

Hello everyone,
I've recently been creating a small chat program, and I figured I had enough base essentials that it was time to add some customization. I want a font menu that will give the user to change the message box (JTextArea) to any font that is installed on their system and to set a size between 8 and 14. To do this, I used the following code:
JMenu fontMenu = new JMenu("Font");
        customize.add(fontMenu);
        //TODO make this scrollable
        GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
        Font[] fonts = e.getAllFonts(); // Get the fonts
        for (Font f : fonts)
            final Font font = new Font(f.getName(), f.getStyle(), 10);
            JMenuItem fontItem = new JMenuItem(f.getName());
            fontMenu.add(fontItem);
            fontItem.addActionListener(new ActionListener()
                @Override
                public void actionPerformed (ActionEvent ae)
                    boolean ok = true;
                    do
                        String stringSize = JOptionPane.showInputDialog(null,"Enter a font size between 8 " +
                                  "and 14", "Font Size", JOptionPane.QUESTION_MESSAGE);
                        try
                            int size = Integer.parseInt(stringSize);
                            if (size < 8 || size > 14)
                                ok = false;
                            else
                                ok = true;
                                convArea.setFont(new Font(font.getName(), font.getStyle(), size));
                                systemMessage("Font changed to " + convArea.getFont().getName() +
                                        ", size " + convArea.getFont().getSize());
                        catch (NumberFormatException ex)
                            ok = false;
                    }while (!ok);
        }Just so you know, customize is the name of a JMenu. systemMessage is a method to post a certain message on one user's message box. That's all well and good, but there's so many fonts installed on a system that it spills way off the screen, as shown in this screenshot: http://i36.tinypic.com/21evzpk.png
How could I make that the JMenu fontMenu limited to approximately 10 JMenuItems visible at once, and then make it scrollable using a scrollbar or the mouse wheel or scroll buttons (similar to the bookmarks menu in Firefox or Google Chrome when there are a lot of bookmarks).
Any help would be greatly appreciated. Thanks in advance.
Edited by: Skyline969 on Aug 26, 2010 7:53 PM

This is great! I'll work on implementing it tomorrow. Thanks.
And I'll consider that in the future. Sorry, kind of new to the forums and haven't had time to look around. I was flustered and found the first semi-applicable location and fired my question.

Similar Messages

  • I need a scrollable JMenu is it possible?

    Hello Ladies and Gentle men!
    I'm in a fix to solve this problem! When I try to add to many Item in a
    JMenu it falls beyond my screen area. Can you tell how I can have a
    scrollable JMenu? I've provided the code below...plz tell me where I
    should modify or need to work on.
    private void setSubMenu()
              JCheckBoxMenuItem cbMenuItem;
              JMenu submenu=new JMenu("SubMenu");
              for(int i=0;i<=500;i++)
                   cbMenuItem=new JCheckBoxMenuItem(" A JChecboxMenuItem");
                   submenu.add(cbMenuItem);
    It'd be my privilege if anyone can provied me the solution code!!!
    Thanks.

    Dear raj_chi
    Thanks� I�m agreeing with you. I shouldn�t have so many menu items at the same level in the most trivial cases. But at the same time I�m trying to be a little more imaginative thinking what if? your program has a JMenu and it�s gets populated every time the end user installs a program? And someday it might fell beyond the visible area!!! In this case what does the windows like menu does? It scrolls right?
    Am I not speaking ideally???

  • How to make JMenu scrollable

    What to do if I have too many items in my Menu?
    Can I implement somthing similar scrolling and how?

    see http://forum.java.sun.com/thread.jsp?forum=57&thread=483165
    ;o)
    V.V.

  • How  to make the panel scrollable

    Hi,
    I am trying to set one panel on the other panel with all the Labels button , i want the screen to become scrollable when the size is bigger then the size of the panel . I am getting an issue on setting one panel over another and the controls on the panel will become scrollable.
    Code:
    Main Class which call the sampleadvance search
    import java.awt.BorderLayout;
    * AGLM Main Screen
    * @author vishal.agarwal
    public class AGLMMainScreen extends JFrame {
         // Component Declaration
         private static final long serialVersionUID = 1L;
         private static AGLMMainScreen mframeAGLMMainScreen = null;
         private JMenuBar gsMenuBar;
         private JMenu gsFileMenu;
         private JMenu gsToolsMenu;
         private JMenu gsSamplesMenu;
         private JMenu gsSeedsMenu;
         private JMenu gsReportsMenu;
         private JMenu gsCustomersMenu;
         private JMenu gsHelpMenu;
         private JMenuItem gsExitAction;
         private JMenuItem gsGeneralConfigurationAction;
         private JMenuItem gsRegisterSampleAction;
         private JMenuItem gsRegisterSeedAction;
         private JMenuItem gsRegisterCustomerAction;
         private JMenuItem gsSearchSampleAction;
         private JMenuItem gsAdvanceSearchSampleAction;
         private JMenuItem gsSearchSeedAction;
         private JMenuItem gsSearchCustomerAction;
         private JMenuItem gsAboutAGLMAction;
         private JPanel contentPane;
         private JPanel footerPane;
         private JPanel panelTop = null;
         private JPanel panelLeft = null;
         private JPanel panelRight = null;
         private JLabel lblSelectedRightScreen = null;
         private JLabel lblMCMPLogo;
         private JLabel gslblSoftwareName;
         private JLabel gslblCopyRight;
         * AGLMMain Screen default constructor
         public AGLMMainScreen() {
              addFocusListener(new FocusAdapter() {
                   @Override
                   public void focusGained(FocusEvent arg0) {
              /*setIconImage(Toolkit.getDefaultToolkit().getImage(
                        AGLMMainScreen.class.getResource("/resources/open.png")));*/
              addWindowListener(new WindowAdapter() {
                   @Override
                   public void windowClosing(WindowEvent arg0) {
                        System.exit(0);
              setLocationByPlatform(true);
              setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
              setBounds(0, 0, 1366, 768);
              setVisible(true);
              // Create Menu Bar.
              GenerateMenuBar();
              contentPane = new JPanel();
              setContentPane(contentPane);
              contentPane.setLayout(null);
              // Create Top Panel.
              GenerateTopPanel();
              // Generate Footer Panel.
              GenerateFooterPanel();
              // Generate Left Panel.
              GenerateLeftPanel();
              // Generate Right Panel.
              GenerateRightPanel();
         public void GenerateMenuBar() {
              // Menu Bar
              gsMenuBar = new JMenuBar();
              gsFileMenu = new JMenu();
              gsFileMenu.setText("File");
              gsMenuBar.add(gsFileMenu);
              gsToolsMenu = new JMenu();
              gsToolsMenu.setText("Tool");
              gsMenuBar.add(gsToolsMenu);
              gsSamplesMenu = new JMenu();
              gsSamplesMenu.setText("Sample");
              gsMenuBar.add(gsSamplesMenu);
              gsSeedsMenu = new JMenu();
              gsSeedsMenu.setText("Seed");
              gsMenuBar.add(gsSeedsMenu);
              gsReportsMenu = new JMenu();
              gsReportsMenu.setText("Reports");
              gsMenuBar.add(gsReportsMenu);
              gsCustomersMenu = new JMenu();
              gsCustomersMenu.setText("Customer");
              gsMenuBar.add(gsCustomersMenu);
              gsHelpMenu = new JMenu();
              gsHelpMenu.setText("Help");
              gsMenuBar.add(gsHelpMenu);
              setJMenuBar(gsMenuBar);
              // Items on Menu Bar
              gsExitAction = new JMenuItem();
              gsExitAction.setText("Exit");
              /*gsExitAction.setIcon(new ImageIcon(AGLMMainScreen.class
                        .getResource("/resources/Cancel.png")));*/
              gsExitAction.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent event) {
                        int result = JOptionPane
                                  .showConfirmDialog(
                                            null,
                                            "Do you want to close",
                                            "Selection Option", JOptionPane.YES_NO_OPTION);
                        if (result == JOptionPane.YES_OPTION) {
                             dispose();
                        } else if (result == JOptionPane.NO_OPTION) {
              gsFileMenu.add(gsExitAction);
              gsGeneralConfigurationAction = new JMenuItem();
              gsGeneralConfigurationAction.setText("General Configuration");
              /*gsGeneralConfigurationAction.setIcon(new ImageIcon(AGLMMainScreen.class
                        .getResource("/resources/General.png")));*/
              gsGeneralConfigurationAction.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent event) {
                        // TODO
              gsToolsMenu.add(gsGeneralConfigurationAction);
              gsRegisterSampleAction = new JMenuItem(
                        "Register Sample");
              /*gsRegisterSampleAction.setIcon(new ImageIcon(AGLMMainScreen.class
                        .getResource("/resources/Export.png")));*/
              gsRegisterSampleAction.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent event) {
                        // TODO
              gsSamplesMenu.add(gsRegisterSampleAction);
              gsSearchSampleAction = new JMenuItem("Search Sample");
              /*gsSearchSampleAction.setIcon(new ImageIcon(AGLMMainScreen.class
                        .getResource("/resources/Export.png")));*/
              gsSearchSampleAction.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent event) {
                        // TODO
              gsSamplesMenu.add(gsSearchSampleAction);
              gsAdvanceSearchSampleAction = new JMenuItem("Advance Search Sample");
              /*gsAdvanceSearchSampleAction.setIcon(new ImageIcon(AGLMMainScreen.class
                        .getResource("/resources/Export.png")));*/
              gsAdvanceSearchSampleAction.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent event) {
                        // TODO
                        showSampleAdvanceSearchForm();
              gsSamplesMenu.add(gsAdvanceSearchSampleAction);
              gsRegisterSeedAction = new JMenuItem("Register Seed");
              /*gsRegisterSeedAction.setIcon(new ImageIcon(AGLMMainScreen.class
                        .getResource("/resources/Export.png")));*/
              gsRegisterSeedAction.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent event) {
                        // TODO
              gsSeedsMenu.add(gsRegisterSeedAction);
              gsSearchSeedAction = new JMenuItem("Seed Search");
              /*gsSearchSeedAction.setIcon(new ImageIcon(AGLMMainScreen.class
                        .getResource("/resources/Export.png")));*/
              gsSearchSeedAction.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent event) {
                        // TODO
              gsSeedsMenu.add(gsSearchSeedAction);
              gsRegisterCustomerAction = new JMenuItem("Register Customer");
              /*gsRegisterCustomerAction.setIcon(new ImageIcon(AGLMMainScreen.class
                        .getResource("/resources/Export.png")));*/
              gsRegisterCustomerAction.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent event) {
                        // TODO
              gsCustomersMenu.add(gsRegisterCustomerAction);
              gsSearchCustomerAction = new JMenuItem("Search Customer");
              /*gsSearchCustomerAction.setIcon(new ImageIcon(AGLMMainScreen.class
                        .getResource("/resources/Export.png")));*/
              gsSearchCustomerAction.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent event) {
                        // TODO
              gsCustomersMenu.add(gsSearchCustomerAction);
              gsAboutAGLMAction = new JMenuItem("About Tool");
              /*gsAboutAGLMAction.setIcon(new ImageIcon(AGLMMainScreen.class
                        .getResource("/resources/Export.png")));*/
              gsAboutAGLMAction.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent event) {
                        // TODO
              gsHelpMenu.add(gsAboutAGLMAction);
         public void GenerateTopPanel() {
              // Top Panel
              panelTop = new JPanel();
              panelTop.setBorder(UIManager.getBorder("DesktopIcon.border"));
              panelTop.setBounds(0, 0, 1350, 55);
              contentPane.add(panelTop);
              panelTop.setLayout(null);
              lblSelectedRightScreen = new JLabel();
              lblSelectedRightScreen.setForeground(SystemColor.textHighlight);
              lblSelectedRightScreen.setFont(new Font("Tahoma", Font.PLAIN, 10));
              lblSelectedRightScreen.setBounds(10, 30, 415, 13);
              panelTop.add(lblSelectedRightScreen);
              lblMCMPLogo = new JLabel();
              lblMCMPLogo.setHorizontalAlignment(SwingConstants.CENTER);
              /*lblMCMPLogo.setIcon(new ImageIcon(AGLMMainScreen.class
                        .getResource("/resources/open.png")));*/
              lblMCMPLogo.setForeground(SystemColor.textHighlight);
              lblMCMPLogo.setFont(new Font("Trebuchet MS", Font.PLAIN, 18));
              lblMCMPLogo.setBounds(612, 0, 63, 55);
              panelTop.add(lblMCMPLogo);
         public void GenerateFooterPanel() {
              footerPane = new JPanel();
              footerPane.setBounds(0, 684, 1350, 25);
              footerPane.setBorder(null);
              contentPane.add(footerPane);
              footerPane.setLayout(null);
              gslblCopyRight = new JLabel(
                        "All Rights Reserved (C) ");
              gslblCopyRight.setFont(new Font("Tahoma", Font.PLAIN, 13));
              gslblCopyRight.setBounds(10, 0, 168, 25);
              footerPane.add(gslblCopyRight);
              gslblSoftwareName = new JLabel("ABC");
              gslblSoftwareName.setFont(new Font("Tahoma", Font.PLAIN, 13));
              gslblSoftwareName.setHorizontalAlignment(SwingConstants.RIGHT);
              gslblSoftwareName.setBounds(1201, 0, 139, 25);
              footerPane.add(gslblSoftwareName);
         public void GenerateLeftPanel() {
              // Left Panel
              panelLeft = new JPanel();
              panelLeft.setIgnoreRepaint(true);
              panelLeft.setFont(new Font("Tahoma", Font.PLAIN, 13));
              panelLeft.setBorder(UIManager.getBorder("DesktopIcon.border"));
              panelLeft.setBounds(0, 60, 300, 620);
              contentPane.add(panelLeft);
              panelLeft.setLayout(new BorderLayout(0, 0));
         public void GenerateRightPanel() {
              panelRight = new JPanel();
              panelRight.setBackground(SystemColor.controlHighlight);
              panelRight.setFont(new Font("Tahoma", Font.PLAIN, 13));
              panelRight.setBorder(UIManager.getBorder("DesktopIcon.border"));
              panelRight.setBounds(305, 60, 1045, 620);
              contentPane.add(panelRight);
              panelRight.setLayout(new BoxLayout(panelRight, BoxLayout.X_AXIS));
         public void showSampleAdvanceSearchForm() {
              try {
                   panelRight.removeAll();
                   SampleAdvancedSearch registration = new SampleAdvancedSearch();
                   // registration.setLocation(panelRight.getLocation());
                   // registration.setBounds(panelRight.getBounds());
                   registration.setBounds(1, 1, 1000, 600);
                   panelRight.add(registration);
                   registration.setVisible(true);
                   repaint();
              } catch (Exception e) {
                   JOptionPane.showMessageDialog(null, e.getMessage());
         public void CloseAGLMMainScreenEvent() {
              int result = 0;
              if (result == JOptionPane.YES_OPTION) {
                   mframeAGLMMainScreen.dispose();
                   mframeAGLMMainScreen = null;
              } else if (result == JOptionPane.NO_OPTION) {
              } else {
         * Main Method
         public static void main(String[] args) {
              EventQueue.invokeLater(new Runnable() {
                   public void run() {
                        try {
                             mframeAGLMMainScreen = new AGLMMainScreen();
                             mframeAGLMMainScreen.setTitle("AGLM");
                             mframeAGLMMainScreen.setVisible(true);
                        } catch (Exception e) {
                             JOptionPane
                                       .showMessageDialog(
                                                 null,
                                                 "Error");
                             mframeAGLMMainScreen.dispose();
    SAmpleAdvanceSearch class
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.SystemColor;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.HashMap;
    import javax.swing.ButtonGroup;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JRadioButton;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.ListSelectionModel;
    import javax.swing.ScrollPaneConstants;
    import javax.swing.SwingConstants;
    import javax.swing.border.LineBorder;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.JTableHeader;
    * @author Vishal Agarwal
    public class SampleAdvancedSearch extends JPanel {
         private static final long serialVersionUID = 1L;
         private JLabel lblFormName;
         private JPanel panelGeneralDetail;
         private JLabel lblSearchDetails;
         private JLabel lblMoistureFrom;
         private JLabel lblSampleNumberFrom;
         private JLabel lblOilContentFrom;
         private JLabel lblSeedType;
         private JLabel lblSampleRateFrom;
         private JTextField txtWeightTo;
         private JTextField txtSampleNumberFrom;
         private JTextField txtMoistureFrom;
         private JComboBox cmbSeedType;
         private JTextField txtMoistureTo;
         private JLabel lblSMSMobileNo;
         private JLabel lblWeightFrom;
         private JLabel lblEmail;
         private JLabel lblSampleNumberTo;
         private JLabel lblProcessingStatus;
         private JLabel lblPaymentStatus;
         private JTextField txtSMSMobileNo;
         private JTextField txtSampleNumberTo;
         private JTextField txtEmail;
         private JTextField txtWeightFrom;
         private JRadioButton rdbtnStatusProcessed;
         private JRadioButton rdbtnStatusUnProcessed;
         private JButton btnClear;
         private JButton btnSearch;
         private JLabel lblWeightTo;
         private JLabel lblMoistureTo;
         private JLabel lblOilContentTo;
         private JLabel lblSampleRateTo;
         private JTextField txtOilContentFrom;
         private JTextField txtSampleRateFrom;
         private JTextField txtOilContentTo;
         private JTextField txtSampleRateTo;
         private JRadioButton rdbtnStatusAll;
         private JRadioButton rdbtnPaymentStatusAll;
         private JLabel lblReceiptPrintStatus;
         private JRadioButton rdbtnReceiptStatusAll;
         private JLabel lblReportPrintStatus;
         private JRadioButton rdbtnReportStatusAll;
         private JRadioButton rdbtnReportStatusPrinted;
         private JRadioButton rdbtnReportStatusNonPrinted;
         private JRadioButton rdbtnReceiptStatusPrinted;
         private JRadioButton rdbtnReceiptStatusNonPrinted;
         private JRadioButton rdbtnPaymentStatusPaid;
         private JRadioButton rdbtnPaymentStatusDue;
         private JScrollPane scrollPaneSearchResult;
         private JTableHeader tblheaderSearchResult;
         private JTable tblSearchResult;
         private DefaultTableModel dtmSearchResult = null;
         private String[] gsobjColumnHeaders = null;
         AGLMMainScreen gsAGLMMainScreen;
         * @throws AGLEngineException
         public SampleAdvancedSearch()
                   throws Exception {
              setAutoscrolls(true);
              setMinimumSize(new Dimension(1000, 1000));
              try {
                   createScreenComponents();
                   createSearchResultScreenComponents();
              } catch (Exception e) {
                   throw e;
         private void createSearchResultScreenComponents() {
              gsobjColumnHeaders = new String[] { "SNo", "Sample Name", "Date",
                        "Sample Type", "Weight (gm)", "Moisture (%)",
                        "Oil Content (%)", "Payment Status", "Status", "Report Print",
                        "Mobile No", "Email Id", "Actions" };
              dtmSearchResult = new DefaultTableModel(null, gsobjColumnHeaders) {
                   private static final long serialVersionUID = 1L;
                   boolean[] columnEditables = new boolean[] { false, false, };
                   public boolean isCellEditable(int row, int column) {
                        return columnEditables[column];
                   @SuppressWarnings("unused")
                   public boolean isRowSelected(int row) {
                        return true;
              scrollPaneSearchResult = new JScrollPane();
              scrollPaneSearchResult
                        .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
              scrollPaneSearchResult
                        .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
              scrollPaneSearchResult.setEnabled(true);
              scrollPaneSearchResult.setBounds(10, 460, 900, 200);
              add(scrollPaneSearchResult);
              tblSearchResult = new JTable();
              tblSearchResult.setModel(dtmSearchResult);
              tblSearchResult
                        .setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
              tblSearchResult.setFont(new Font("Tahoma", Font.PLAIN, 11));
              tblSearchResult.setBackground(Color.WHITE);
              tblSearchResult.setBorder(new LineBorder(new Color(0, 0, 0)));
              tblSearchResult.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
              scrollPaneSearchResult.setViewportView(tblSearchResult);
              tblSearchResult.setRowHeight(40);
              for (int i = 0; i < tblSearchResult.getColumnCount(); i++) {
                   tblSearchResult.getColumnModel().getColumn(i).setCellRenderer(new TextAreaRenderer());
              tblSearchResult.setCellEditor(new TextAreaEditor());
              tblSearchResult.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    //          AGLUtility.packColumns(tblSearchResult, 4);
              tblSearchResult.getColumnModel().getColumn(2).setPreferredWidth(100);
              tblSearchResult.getColumnModel().getColumn(8).setPreferredWidth(100);
              tblSearchResult.getColumnModel().getColumn(10).setPreferredWidth(100);
              tblSearchResult.getColumnModel().getColumn(11).setPreferredWidth(150);
              tblSearchResult.getColumnModel().getColumn(12).setPreferredWidth(100);
              tblheaderSearchResult = tblSearchResult.getTableHeader();
              tblheaderSearchResult.setAlignmentX(Component.CENTER_ALIGNMENT);
              tblheaderSearchResult.setAlignmentY(Component.CENTER_ALIGNMENT);
         private void createScreenComponents() throws Exception {
              try {
                   setAlignmentX(Component.LEFT_ALIGNMENT);
                   setBackground(SystemColor.controlHighlight);
                   setLayout(null);
                   lblFormName = new JLabel("Sample Advance Search");
                   lblFormName.setHorizontalTextPosition(SwingConstants.CENTER);
                   lblFormName.setHorizontalAlignment(SwingConstants.LEFT);
                   lblFormName.setFont(new Font("Tahoma", Font.BOLD, 18));
                   lblFormName.setBounds(10, 10, 400, 30);
                   add(lblFormName);
                   // General Detail Panel
                   panelGeneralDetail = new JPanel();
                   panelGeneralDetail.setForeground(Color.RED);
                   panelGeneralDetail.setBorder(new LineBorder(new Color(0, 0, 0)));
                   panelGeneralDetail.setBounds(10, 40, 900, 410);
                   add(panelGeneralDetail);
                   panelGeneralDetail.setLayout(null);
                   lblSearchDetails = new JLabel("Sample Search Details :-");
                   lblSearchDetails.setHorizontalAlignment(SwingConstants.LEFT);
                   lblSearchDetails.setFont(new Font("Tahoma", Font.BOLD, 13));
                   lblSearchDetails.setBounds(20, 10, 231, 20);
                   panelGeneralDetail.add(lblSearchDetails);
                   lblMoistureFrom = new JLabel("Moisture Range (%) From ");
                   lblMoistureFrom.setForeground(Color.BLACK);
                   lblMoistureFrom.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblMoistureFrom.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblMoistureFrom.setBounds(30, 310, 200, 20);
                   panelGeneralDetail.add(lblMoistureFrom);
                   lblSampleNumberFrom = new JLabel("Sample Number From ");
                   lblSampleNumberFrom.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblSampleNumberFrom.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblSampleNumberFrom.setBounds(30, 250, 200, 20);
                   panelGeneralDetail.add(lblSampleNumberFrom);
                   lblOilContentFrom = new JLabel("Oil Content (%) From ");
                   lblOilContentFrom.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblOilContentFrom.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblOilContentFrom.setBounds(30, 340, 200, 20);
                   panelGeneralDetail.add(lblOilContentFrom);
                   txtWeightTo = new JTextField();
                   txtWeightTo.setBounds(490, 280, 170, 20);
                   panelGeneralDetail.add(txtWeightTo);
                   txtWeightTo.setColumns(10);
                   txtSampleNumberFrom = new JTextField();
                   txtSampleNumberFrom.setColumns(10);
                   txtSampleNumberFrom.setBounds(250, 250, 170, 20);
                   panelGeneralDetail.add(txtSampleNumberFrom);
                   txtMoistureFrom = new JTextField();
                   txtMoistureFrom.setColumns(10);
                   txtMoistureFrom.setBounds(250, 310, 170, 20);
                   panelGeneralDetail.add(txtMoistureFrom);
                   lblSeedType = new JLabel("Sample Seed Type ");
                   lblSeedType.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblSeedType.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblSeedType.setBounds(30, 40, 200, 20);
                   panelGeneralDetail.add(lblSeedType);
                   lblSampleRateFrom = new JLabel("Sample Testing Rate From ");
                   lblSampleRateFrom.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblSampleRateFrom.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblSampleRateFrom.setBounds(30, 370, 200, 20);
                   panelGeneralDetail.add(lblSampleRateFrom);
                   cmbSeedType = new JComboBox();
                   cmbSeedType.setBounds(250, 40, 170, 20);
                   panelGeneralDetail.add(cmbSeedType);
                   txtMoistureTo = new JTextField();
                   txtMoistureTo.setColumns(10);
                   txtMoistureTo.setBounds(490, 310, 170, 20);
                   panelGeneralDetail.add(txtMoistureTo);
                   lblSMSMobileNo = new JLabel("Registered Mobile No ");
                   lblSMSMobileNo.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblSMSMobileNo.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblSMSMobileNo.setBounds(30, 70, 200, 20);
                   panelGeneralDetail.add(lblSMSMobileNo);
                   lblWeightFrom = new JLabel("Weight Range (gm) From ");
                   lblWeightFrom.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblWeightFrom.setForeground(Color.BLACK);
                   lblWeightFrom.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblWeightFrom.setBounds(30, 280, 200, 20);
                   panelGeneralDetail.add(lblWeightFrom);
                   lblEmail = new JLabel("Registered Email ");
                   lblEmail.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblEmail.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblEmail.setBounds(30, 100, 200, 20);
                   panelGeneralDetail.add(lblEmail);
                   lblSampleNumberTo = new JLabel("To ");
                   lblSampleNumberTo.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblSampleNumberTo.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblSampleNumberTo.setBounds(430, 250, 50, 20);
                   panelGeneralDetail.add(lblSampleNumberTo);
                   lblProcessingStatus = new JLabel("Processing Status ");
                   lblProcessingStatus.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblProcessingStatus.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblProcessingStatus.setBounds(30, 130, 200, 20);
                   panelGeneralDetail.add(lblProcessingStatus);
                   lblPaymentStatus = new JLabel("Payment Status ");
                   lblPaymentStatus.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblPaymentStatus.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblPaymentStatus.setBounds(30, 160, 200, 20);
                   panelGeneralDetail.add(lblPaymentStatus);
                   txtSMSMobileNo = new JTextField();
                   txtSMSMobileNo.setColumns(10);
                   txtSMSMobileNo.setBounds(250, 70, 170, 20);
                   panelGeneralDetail.add(txtSMSMobileNo);
                   txtWeightFrom = new JTextField();
                   txtWeightFrom.setColumns(10);
                   txtWeightFrom.setBounds(250, 280, 170, 20);
                   panelGeneralDetail.add(txtWeightFrom);
                   txtEmail = new JTextField();
                   txtEmail.setColumns(10);
                   txtEmail.setBounds(250, 100, 170, 20);
                   panelGeneralDetail.add(txtEmail);
                   txtSampleNumberTo = new JTextField();
                   txtSampleNumberTo.setColumns(10);
                   txtSampleNumberTo.setBounds(490, 250, 170, 20);
                   panelGeneralDetail.add(txtSampleNumberTo);
                   rdbtnStatusAll = new JRadioButton("All");
                   rdbtnStatusAll.setSelected(true);
                   rdbtnStatusAll.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   rdbtnStatusAll.setBounds(250, 130, 50, 20);
                   panelGeneralDetail.add(rdbtnStatusAll);
                   rdbtnStatusProcessed = new JRadioButton("Processed");
                   rdbtnStatusProcessed.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   rdbtnStatusProcessed.setBounds(310, 130, 85, 20);
                   panelGeneralDetail.add(rdbtnStatusProcessed);
                   rdbtnStatusUnProcessed = new JRadioButton("Un-Processed");
                   rdbtnStatusUnProcessed.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   rdbtnStatusUnProcessed.setBounds(400, 130, 120, 20);
                   panelGeneralDetail.add(rdbtnStatusUnProcessed);
                   final ButtonGroup rdbtngrpProcessingStatus = new ButtonGroup();
                   rdbtngrpProcessingStatus.add(rdbtnStatusProcessed);
                   rdbtngrpProcessingStatus.add(rdbtnStatusUnProcessed);
                   rdbtngrpProcessingStatus.add(rdbtnStatusAll);
                   rdbtnPaymentStatusAll = new JRadioButton("All");
                   rdbtnPaymentStatusAll.setSelected(true);
                   rdbtnPaymentStatusAll.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   rdbtnPaymentStatusAll.setBounds(250, 160, 50, 20);
                   panelGeneralDetail.add(rdbtnPaymentStatusAll);
                   rdbtnPaymentStatusPaid = new JRadioButton("Paid");
                   rdbtnPaymentStatusPaid.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   rdbtnPaymentStatusPaid.setBounds(310, 160, 85, 20);
                   panelGeneralDetail.add(rdbtnPaymentStatusPaid);
                   rdbtnPaymentStatusDue = new JRadioButton("Due");
                   rdbtnPaymentStatusDue.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   rdbtnPaymentStatusDue.setBounds(400, 160, 120, 20);
                   panelGeneralDetail.add(rdbtnPaymentStatusDue);
                   final ButtonGroup rdbtngrpPaymentStatus = new ButtonGroup();
                   rdbtngrpPaymentStatus.add(rdbtnPaymentStatusAll);
                   rdbtngrpPaymentStatus.add(rdbtnPaymentStatusPaid);
                   rdbtngrpPaymentStatus.add(rdbtnPaymentStatusDue);
                   rdbtnReceiptStatusAll = new JRadioButton("All");
                   rdbtnReceiptStatusAll.setSelected(true);
                   rdbtnReceiptStatusAll.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   rdbtnReceiptStatusAll.setBounds(250, 190, 50, 20);
                   panelGeneralDetail.add(rdbtnReceiptStatusAll);
                   rdbtnReceiptStatusPrinted = new JRadioButton("Printed");
                   rdbtnReceiptStatusPrinted.setFont(new Font("Tahoma", Font.ITALIC,
                             13));
                   rdbtnReceiptStatusPrinted.setBounds(310, 190, 85, 20);
                   panelGeneralDetail.add(rdbtnReceiptStatusPrinted);
                   rdbtnReceiptStatusNonPrinted = new JRadioButton("Non Printed");
                   rdbtnReceiptStatusNonPrinted.setFont(new Font("Tahoma",
                             Font.ITALIC, 13));
                   rdbtnReceiptStatusNonPrinted.setBounds(400, 190, 120, 20);
                   panelGeneralDetail.add(rdbtnReceiptStatusNonPrinted);
                   final ButtonGroup rdbtngrpReceiptStatus = new ButtonGroup();
                   rdbtngrpReceiptStatus.add(rdbtnReceiptStatusAll);
                   rdbtngrpReceiptStatus.add(rdbtnReceiptStatusPrinted);
                   rdbtngrpReceiptStatus.add(rdbtnReceiptStatusNonPrinted);
                   rdbtnReportStatusAll = new JRadioButton("All");
                   rdbtnReportStatusAll.setSelected(true);
                   rdbtnReportStatusAll.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   rdbtnReportStatusAll.setBounds(250, 220, 50, 20);
                   panelGeneralDetail.add(rdbtnReportStatusAll);
                   rdbtnReportStatusPrinted = new JRadioButton("Printed");
                   rdbtnReportStatusPrinted
                             .setFont(new Font("Tahoma", Font.ITALIC, 13));
                   rdbtnReportStatusPrinted.setBounds(310, 220, 85, 20);
                   panelGeneralDetail.add(rdbtnReportStatusPrinted);
                   rdbtnReportStatusNonPrinted = new JRadioButton("Non Printed");
                   rdbtnReportStatusNonPrinted.setFont(new Font("Tahoma", Font.ITALIC,
                             13));
                   rdbtnReportStatusNonPrinted.setBounds(400, 220, 120, 20);
                   panelGeneralDetail.add(rdbtnReportStatusNonPrinted);
                   final ButtonGroup rdbtngrpReportStatus = new ButtonGroup();
                   rdbtngrpReportStatus.add(rdbtnReportStatusAll);
                   rdbtngrpReportStatus.add(rdbtnReportStatusPrinted);
                   rdbtngrpReportStatus.add(rdbtnReportStatusNonPrinted);
                   lblWeightTo = new JLabel("To ");
                   lblWeightTo.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblWeightTo.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblWeightTo.setBounds(430, 280, 50, 20);
                   panelGeneralDetail.add(lblWeightTo);
                   lblMoistureTo = new JLabel("To ");
                   lblMoistureTo.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblMoistureTo.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblMoistureTo.setBounds(430, 310, 50, 20);
                   panelGeneralDetail.add(lblMoistureTo);
                   lblOilContentTo = new JLabel("To ");
                   lblOilContentTo.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblOilContentTo.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblOilContentTo.setBounds(430, 340, 50, 20);
                   panelGeneralDetail.add(lblOilContentTo);
                   lblSampleRateTo = new JLabel("To ");
                   lblSampleRateTo.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblSampleRateTo.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblSampleRateTo.setBounds(430, 370, 50, 20);
                   panelGeneralDetail.add(lblSampleRateTo);
                   txtOilContentFrom = new JTextField();
                   txtOilContentFrom.setColumns(10);
                   txtOilContentFrom.setBounds(250, 340, 170, 20);
                   panelGeneralDetail.add(txtOilContentFrom);
                   txtSampleRateFrom = new JTextField();
                   txtSampleRateFrom.setColumns(10);
                   txtSampleRateFrom.setBounds(250, 370, 170, 20);
                   panelGeneralDetail.add(txtSampleRateFrom);
                   txtOilContentTo = new JTextField();
                   txtOilContentTo.setColumns(10);
                   txtOilContentTo.setBounds(490, 340, 170, 20);
                   panelGeneralDetail.add(txtOilContentTo);
                   txtSampleRateTo = new JTextField();
                   txtSampleRateTo.setColumns(10);
                   txtSampleRateTo.setBounds(490, 370, 170, 20);
                   panelGeneralDetail.add(txtSampleRateTo);
                   lblReceiptPrintStatus = new JLabel("Receipt Print Status ");
                   lblReceiptPrintStatus.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblReceiptPrintStatus.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblReceiptPrintStatus.setBounds(30, 190, 200, 20);
                   panelGeneralDetail.add(lblReceiptPrintStatus);
                   lblReportPrintStatus = new JLabel("Report Print Status ");
                   lblReportPrintStatus.setHorizontalAlignment(SwingConstants.RIGHT);
                   lblReportPrintStatus.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   lblReportPrintStatus.setBounds(30, 220, 200, 20);
                   panelGeneralDetail.add(lblReportPrintStatus);
                   // Buttons
                   btnClear = new JButton("Clear");
                   btnClear.setBounds(745, 317, 100, 30);
                   panelGeneralDetail.add(btnClear);
                   btnClear.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   btnSearch = new JButton("Search");
                   btnSearch.setBounds(745, 360, 100, 30);
                   panelGeneralDetail.add(btnSearch);
                   btnSearch.setFont(new Font("Tahoma", Font.ITALIC, 13));
                   btnSearch.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent arg0) {
                             searchSample();
              } catch (Exception e) {
                   throw new Exception("Error occured while generating data for screen. "
                                       + e.getMessage(), e);
         private void searchSample() {}
    }

    1. wall of unformatted code. Use \ tags when posting code.
    2. you're not even asking a question. You're just saying "it doesn't work" and then you dump the code. What do you expect? That people now go to debug it for you?                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Scrollable/Read_only  ResultSet objects

    I am trying to create an instance of a scrollable/read_only ResultSet object with the following code:
    Statement stmt = con.createStatement(
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_READ_ONLY);
    ResultSet rs = stmt.executeQuery("SELECT * FROM ...");
    The Connection object has been made successfully but am getting an AbstractMethodError Exception at line 1.
    Can anyone please help me out here.
    Thank you.

    I don't believe the Oracle driver allows for
    read/only. I'll take a look at the Oracle website,
    and see if I can verify that.
    JoelSorry, I was wrong on this. From the Oracle JDBC documentation, it states that CONCUR_READ_ONLY is valid for the Oracle 8 and Oracle 9 drivers. Are you using classes12.zip or classes12.jar for your Oracle libraries?

  • Scrollable/Updateable ResultSet objects

    I am trying to create an instance of a scrollable/updateable ResultSet object with the following code:
    Statement stmt = con.createStatement(
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stmt.executeQuery("SELECT * FROM sch.a");
    The Connection object has been made successfully but am getting an AbstractMethodError Exception at line 1.
    Can anyone please help me out here.
    Thanks
    I am using JDK 1.3.1 and JDBC 2.0

    I use this and works fine for me....let me know how it goes...
    ResultSet resultSetMultCond = null;
    Statement getMultPartCond = null;
    String sqlMultCond = null;
    sqlMultCond = "SELECT #PART,#CONDS,COUNT(*) AS MCOUNT FROM MYLIB WHERE #PART = 'A123' GROUP BY #PART,#CONDS ORDER BY #PART";
    getMultPartCond = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_SENSITIVE,java.sql.ResultSet.CONCUR_UPDATABLE);
    resultSetMultCond = getMultPartCond.executeQuery(sqlMultCond);

  • Scroll down/up functionality in a jMenu?

    What i mean is a jMenu similar to that of internet explorer's
    Favorites menu. When you have a ton of favorites you get a little arrow
    pointing down or up depending on where you are in the menu. Is it possible to implement something similar in java with a jmenu? if so how?
    Ps thanks to all who helped with my previous JMenu question. I got it figured out :)

    Found this for you
    http://forum.java.sun.com/thread.jsp?forum=57&thread=310457&message=1250922#1250922

  • How do I put a PDF on my website?  It needs to be scrollable.

    I have an open PDF in Preview.  How do I put it on a web page of mine?  I took a screenshot of the Preview window, but now the cursor is the little + thing that wants to draw an area to select.  So I don't know whether this shot is scrollable.
    I need to be educated here.
    Thank you
    Jerry

    Screen shots are not scrollable.  They are just static image files.
    To include it on a webpage of yours, put it on your server and make a link to the file of the file name.   Mind you those browsing the website without an appropriate Acrobat plugin will probably launch Acrobat reader, and it won't be readable in the browser.   Acrobat files are handled differently depending on the plugin.   A better way to deal with it, is learn some HTML and use Textwrangler by http://www.barebones.com/ to code your page with the correct HTML to make it look like the Acrobat page.  You'll have to select all, and copy the Acrobat document into your HTML text document.  Then you'll have to mark it up.   Unfortunately you can't expect everyone to have an Acrobat plugin.

  • Is there a way of jumping to a specific point in scrollable content?

    I have a list of values sub-divided by month in a scrollable content frame, i.e. -
    AUGUST
    Value1
    Value2
    Value3
    SEPTEMBER
    Value4
    Value5
    Value6
    Value7
    OCTOBER
    Value8
    ...and so on...
    If my reader wants to jump directly to January for example, it would be nice if they could just click a button(labelled 'January') and the scrollable content automatically jumps to the January values. Is this possible?
    Thanks.

    Bob Levine wrote:
    You want to continue to carry on like this, knock yourself out but you’re acting like child now.
    You were told the proper place to ask a DPS related question. You got the answer and you’re still going on about it.
    And yes, it is a nice system because technically you were not asking an InDesign question.
    Bob, your tone of reply is regularly dismissive and unprofessional and you're being completely unreasonable. It isn't as if I asked about scrollable content in the Photoshop forum - it is a perfectly legitimate feature of InDesign!
    Peter, if you don't know then answer, you don't have to reply to the question. Leave it to someone who does in the future. As for you 'always asking people for more information', how is 'You might want to tell us how this is an InDesign question...' helpful.

  • How to print a scrollable, interactive PDF file

    I've had an interactive PDF application form built. Works great for the applicants, as boxes allow scrolling so that applicants can add detailed info where relevant. However, now that the completed applications are flowing in, I can't figure how to print them (as part of the application review process) so that they display/print all the content in the scrollable boxes. Am I missing something? Any assistance would be appreciated.

    This is really a user question for whatever program you are using to print
    the PDF forms - it's not really an issue of the PDF language.
    Assuming you are using Adobe Acrobat, please post in our Acrobat forums.

  • Outline View In Isolation Mode + Scrollable font list on mac like its on PC

    I would love to have outline view available when in isolation mode.. Not sure why its not available.. Also would like to have the scrollable font list on the mac version like how it is on PC..

    Outline view is available in CS4. At least on a mac, OSX 4.11.

  • Scrollable picture with other pictures attached to it?

    Any ideas how and with what classes this should be done?
    I want to make a GUI with largish picture in the background.
    The size of the picture exceeds the size of the window
    so it needs to be scrollable.
    Then I want to have other smaller images on top of that.
    These images should also move when the background is scrolled
    and my plan is to be able to drag them around with mouse
    (i.e. change their position in relation to the background picture).
    I managed to create the scrollable picture, but weren't
    able to display anything on top of it.
    I'm using JDK 1.3.1 (and Borland's Java Builder 7)

    All right, I managed to do it all. This Java is pretty quick to use
    (when you know what class to inherit ;)
    Here's the sollution for those draggable pictures
    public class DraggablePic extends JLabel implements MouseMotionListener, MouseListener {
      int clickPositionX;
      int clickPositionY;
      // constructors
      public DraggablePic() {
        super();
        addMouseMotionListener(this);
        addMouseListener(this);
      public DraggablePic(Icon image) {
        super(image);
        addMouseMotionListener(this);
        addMouseListener(this);
      // mouse motions
      public void mouseDragged(MouseEvent e) {
        super.setLocation(e.getX()-clickPositionX+this.getX(),
                          e.getY()-clickPositionY+this.getY());
      public void mouseMoved(MouseEvent e) {
      // mouse events
      public void mouseClicked(MouseEvent e) {
      public void mouseEntered(MouseEvent e) {
      public void mouseExited(MouseEvent e) {
      public void mousePressed(MouseEvent e) {
        clickPositionX = e.getX();
        clickPositionY = e.getY();
      public void mouseReleased(MouseEvent e) {

  • How do I print all of the text in a scrollable form field?

    How do I print all of the text in a scrollable form field?  When I print the form, the text becomes cut off based on the size of the field and displays a little plus sign in the lower right hand corner indicating more text.  I want to print all of the text.

    The form is HTML which means what you see in your browser window is what you will see in your print out.  You can, as the form author, view the submitted data in the View Responses tab and print that out.  You can also export the responses to Excel, CSV, or PDF and print that out.

  • How to show the content of a table (long text) in a scrollable textbox?

    Hi,
    I have to say first, many thanks to the ones who answers to threads in this forum, it's very helpfull when we're learning web dynpro!
    I have a RFC function that return a table containing a long text (node "it_text", with elements "Tdformat" and "Tdline").
    1) I want first to copy all the Tdlines in a new node "text_box" (that I made specially for the screen, it contains only the element "Tdline" [the text itself]);
    2) Then I want to show the content of the node "text_box" in a scrollable textbox on the screen (to show 8 lines of text, for example).
    How to do that easily?  What is the UI Element needed to show that?
    Thanks!

    If you want to display as it is then you can use Table UI element. You can change the design property to 'transparent' and set column header visibility property to none. Then you need not to write any code simple you can map the node to table field.
    Even with TextEdit you can achieve what you want. Try this code...
         StringBuffer tmpBuffer = new StringBuffer();
         for(int index=0;index<wdContext.nodeLines().size();index++)
              wdContext.nodeLines().setLeadSelection(index);
              tmpBuffer.append(wdContext.currentLinesElement().getLine()+"n");
         wdContext.currentContextElement().setData(tmpBuffer.toString());
    Regards
    Abhilash

  • Dynamic jmenu bar

    i have a dynamic JMenu on a jframe. The menu is populated by looking up database entries and ptting them into the right place. This is done by a method 'menus()'.
    I also have an addingredients class which adds new ingredient entries into the database, problem is when it does this, the JMenu has to be repopulated. The following code shows the main frame
    // Recipe Creation GUI
    // Written by Michael Emett
    // Monday 15th Decemeber 2003
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JFrame.*;
    import java.sql.*;
    import java.util.*;
    public class TextAreaDemo extends JFrame     {
    private static JTextArea part1;
    private JButton Browse, Enter, Preview, Remove;
    public static JList printList, newList;
    private JCheckBox pic;
    private JLabel namePrompt, title1, title2, title3;
    private static JTextField nameInput;
    private JPanel jp, jp1, jp2, jp3, jp4, jp5;
    private Connection con;
    private Statement stmt;
    public static JMenu fileMenu;
    private static JMenuBar bar;
    // additions /////////////////////////////////////////////////////////////////////////
    //set up GUI
    public TextAreaDemo()     {
    super( "Recipe Entry Sheet" );
    // set up File menu and its menu items
    // Menu and button Initialization ////////////////////////////////////////////////////
    //myMouse = new MyMouseAdapter();
    //final JMenu
    fileMenu = new JMenu( "Ingredients");
             fileMenu.setMnemonic( 'I' );
    fileMenu.add(menus());
    bar = new JMenuBar();
    setJMenuBar( bar );
    JMenu file = new JMenu( "File");
    file.setMnemonic( 'F' );
        bar.add(file);
              JMenuItem Adder = new JMenuItem( "New Ingredient");
             Adder.setMnemonic( 'N' );
    JMenuItem Subber = new JMenuItem( "New subMenu");
             Subber.setMnemonic( 'S' );
             // set up About... menu item
             JMenuItem aboutItem = new JMenuItem( "About..." );
             aboutItem.setMnemonic( 'A' );
    namePrompt = new JLabel( "Recipe Name " );
    nameInput = new JTextField( 20 );
    title1 = new JLabel( "Selected ingredients" );
    title3 = new JLabel( "Please enter the Recipe Instructions" );
    title2 = new JLabel( "Enter The SubMenu Name " );
    pic = new JCheckBox("Add Picture", false);
    file.add( Adder );
         Adder.addActionListener(
              new ActionListener()     {
                    public void actionPerformed( ActionEvent event )
                        getList f = new getList();
    // Add Ingredient menu item //////////////////////////////////////////////////////////
    file.add( Subber );
         Subber.addActionListener(
              new ActionListener()     {
                    public void actionPerformed( ActionEvent event )
                        AddSubMenu f = new AddSubMenu();
    // About menu item ///////////////////////////////////////////////////////////////////
    file.add( aboutItem );
          aboutItem.addActionListener(
             new ActionListener() {  // anonymous inner class
                // display message dialog when user selects About...
                public void actionPerformed( ActionEvent event )
                   JOptionPane.showMessageDialog( TextAreaDemo.this,
                      "Developed by Michael Emett, 2004",
                      "About", JOptionPane.PLAIN_MESSAGE );
              }     // end anonymous inner class
         );  // end call to addActionListener
    // Exit menu item ////////////////////////////////////////////////////////////////////
         JMenuItem exitItem = new JMenuItem( "Exit" );
         exitItem.setMnemonic( 'x' );
         file.add( exitItem );
          exitItem.addActionListener(
             new ActionListener() {  // anonymous inner class
                // terminate application when user clicks exitItem
                public void actionPerformed( ActionEvent event )
                   System.exit( 0 );
             }  // end anonymous inner class
          ); // end call to addActionListener
    //create Button Enter
    Enter = new JButton("Enter");
    Enter.addActionListener(
              new ActionListener()     {
                              public void actionPerformed( ActionEvent event )
                        StringBuffer a = new StringBuffer();
                        StringBuffer b = new StringBuffer();
                        StringBuffer c = new StringBuffer();
                        for(int i= 0; i< victor.size(); i++){
                        b.append(victor.elementAt(i));
                        b.append("; ");
                        a.append(nameInput.getText());
                        c.append(part1.getText());
                        //System.out.println(a);
                        //System.out.println(b);
                        //System.out.println(c);
                        InsertRecipe f = new InsertRecipe(a,b,c);
                        //invalidate();
                //fileMenu.updateUI();
               // fileMenu.revalidate();
    //create Button Remove
    Remove = new JButton("Remove");
    //add Actionlistener
    Remove.addActionListener(
              new ActionListener()     {
                    public void actionPerformed( ActionEvent event )
    int[] arr;
    arr = printList.getSelectedIndices();
    int counter = 0;
         for (int i= 0; i< arr.length; i++){
              int n=arr;
              victor.remove(n-counter);
              counter++;
    printList.setListData(victor);
    //create Button Remove
    Browse = new JButton("Browse");
    //create Button Preview
    Preview = new JButton("Clear");
    Preview.addActionListener(
    new ActionListener() {  // anonymous inner class
    // display message dialog when user selects Preview...
    public void actionPerformed( ActionEvent event )
    int result = JOptionPane.showConfirmDialog
                             (null,      "Are you sure to want to clear this form", "Clear?",      JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE);
                             if(result == JOptionPane.YES_OPTION)
                             {TextAreaDemo.clear();
                                  //System.out.println("Recipe Entered");
              }//end of joptionpane
    printList = new JList();
    printList.setVisibleRowCount(9);
    printList.setFixedCellWidth(150);
    printList.setFixedCellHeight(15);
    printList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
    newList = new JList();
    newList.setVisibleRowCount(9);
    newList.setFixedCellWidth(150);
    newList.setFixedCellHeight(15);
    newList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION );
    // Initialise Text Areas //
    part1 = new JTextArea( 25, 50);
    part1.setFont(new Font("Courier", Font.BOLD, 12));
    part1.setLineWrap(true);
    part1.setWrapStyleWord(true);
    // JPanels for Layout //
    jp = new JPanel();
    jp1 = new JPanel();
    jp2 = new JPanel();
    jp3 = new JPanel();
    jp4 = new JPanel();
    jp5 = new JPanel();
    final Container c = getContentPane();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
         c.setLayout(gbl);
         gbc.weightx = 0.1;
         gbc.weighty = 0.5;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    add(jp1, gbc, 0, 0, 1, 1);
    gbc.fill = GridBagConstraints.NONE;
    add(jp2, gbc, 0, 1, 1, 1);
    add(jp3, gbc, 1, 0, 2, 2);
    jp1.add(jp4, BorderLayout.CENTER);
    jp2.add(jp, BorderLayout.CENTER);
    bar.add( namePrompt );
    bar.add( nameInput);
    bar.add( fileMenu );
    jp4.setLayout(new BorderLayout());
    jp4.add(title1, BorderLayout.NORTH);
    jp4.add(new JScrollPane( printList), BorderLayout.CENTER);
    jp4.add(Remove, BorderLayout.SOUTH);
    jp.setLayout(new BorderLayout());
    jp.add(pic, BorderLayout.NORTH);
    jp.add(new JScrollPane (newList), BorderLayout.CENTER);
    jp.add(Browse, BorderLayout.SOUTH);
    jp3.setLayout(new BorderLayout());
    jp3.add (title3, BorderLayout.NORTH);
    jp3.add (new JScrollPane(part1), BorderLayout.CENTER);
    //c.addMouseListener(myMouse);
    gbc.anchor = GridBagConstraints.LAST_LINE_END;
    add(jp5, gbc, 2, 3, 1, 1);
    jp5.setLayout(new FlowLayout());
    jp5.add(Preview);
    jp5.add(Enter);
    setSize(770, 620);
         pack();
         setVisible(true);
         setResizable(false);
    private static Vector victor = new Vector();
    public static void printListset(String t) {
         victor.add(t);
    for(int i = 0; i<victor.size(); i++)
    printList.setListData(victor);
    public void add(Component ce, GridBagConstraints constraints, int x, int y, int w, int h) {
                   constraints.gridx = x;
                   constraints.gridy = y;
                   constraints.gridwidth = w;
                   constraints.gridheight = h;
                   getContentPane().add(ce, constraints);
    public static JMenu menus()     {
         // Map Created to Handle JMenuItem Addition //
              Map labelToMenu = new HashMap();
              Map labelToMenu2 = new HashMap();
              Map labelToMenu3 = new HashMap();
              String url = "jdbc:odbc:database";
              Connection con;
              Statement stmt;
                        try     {
                             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        catch(ClassNotFoundException e)     {
                        System.err.print("Class Not found");
                        String query = "select baseIngred.IngredientType, baseIngred.PrimaryKey FROM baseIngred";
                        String query2 = "select baseIngred.IngredientType, baseIngred.PrimaryKey,"
                        + "subMenu.menuNumber, subMenu.subMenu FROM baseIngred, "
                        + "subMenu WHERE baseIngred.PrimaryKey = subMenu.menuNumber ORDER BY submenu";
                                  String query3 = "select subMenu.subMenu, subMenu.PrimaryNumber,"
                                       + "Ingredient.Ingredient, Ingredient.MenuNumber FROM subMenu, Ingredient"
                        + " WHERE Ingredient.MenuNumber = subMenu.PrimaryNumber ORDER BY PrimaryNumber";
         String query4 = "select Ingredient.Ingredient, Ingredient.MenuNumber FROM Ingredient";
                             try     {
                                       con = DriverManager.getConnection(url, "myLogin", "myPassword");
                                       stmt = con.createStatement();
         // Initial Jmenu added ///////////////////////////////////////////////////////////////
                   ResultSet rs = stmt.executeQuery(query);
                   String[] arr = new String[100];
                   int[] num = new int[200];
                   int[] num2 = new int[200];
                   int counter = 0;
                   int counter2 = 0;
                   while     (rs.next())     {
                                  //String t is set to the value contained in ingredient type
                                  String t = rs.getString("IngredientType");
                                  //map labelToMenu has String t and a new JMenu with the menu
                                  //name contained in t stored in it
                                  labelToMenu.put(t, fileMenu.add(new JMenu(t)));
                                  //an array containing values of the priamry key is produced
                                  num[counter] = rs.getInt("PrimaryKey");
                                  //a counter is incremeted so that upon further
                                  //interations it is stored in a new array field
                                  counter++;
         // Second Jmenu added ////////////////////////////////////////////////////////////////
                   ResultSet rs2 = stmt.executeQuery(query2);
                   while     (rs2.next()) {
                                  //String first is set to the value contained in ingredient type
                                  String first = rs2.getString("IngredientType");
                                  //String second is set to the value contained in subMenu
                                  String second = rs2.getString("subMenu");
                                  //firstlevel looks up item t in the map, and creates a jmenu name as it.
                                  JMenu firstLevel = (JMenu)labelToMenu.get(first);
                                  //handles menu placement by comparing PrimaryKeys with MenuNumbers
                                  // f = rs2.getInt("menuNumber");
                                  num2[counter2] = rs2.getInt("menuNumber");
         for (int nm = 0; nm<num.length; nm++){
                   if (num[nm] == num2[counter2]
                                            //adds the second value to the jmenu with th name stored in t.
                                            labelToMenu2.put(second, (firstLevel.add(new JMenu (second))));
                                       }counter2++;
         // Third JMenu added /////////////////////////////////////////////////////////////////
         ResultSet rs3 = stmt.executeQuery(query3);
              while     (rs3.next()) {
                                  //String next is set to the value contained in subMenu
                                  String next = rs3.getString("subMenu");
                                  //String third is set to the value contained in ingredient
                                  String third = rs3.getString("Ingredient");
                                  JMenu secondLevel = (JMenu)labelToMenu2.get(next);
                                  int f2 = rs3.getInt("MenuNumber");
                                  //System.out.println(f2);
                                  int f3 = rs3.getInt("PrimaryNumber");
                   if (f3 == f2){
                             labelToMenu3.put(third, secondLevel.add(new JMenuItem(third)));
         // Add AtionListeners ////////////////////////////////////////////////////////////////
         ResultSet rs4 = stmt.executeQuery(query4);
              while     (rs4.next()) {
                   String third2 = rs4.getString("Ingredient");
         JMenuItem thirdLevel = (JMenuItem)labelToMenu3.get(third2);
         thirdLevel.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                   JMenuItem source = (JMenuItem)(e.getSource());
                   String actionText = source.getText();
                   PopUp pop = new PopUp(actionText);
                        stmt.close();
                        con.close();
                             }catch(SQLException ex)     {
                        System.err.println(ex);
    return (fileMenu);
         //                                        End Of Connection                                             //
         // Add subMenu menu item /////////////////////////////////////////////////////////////
    public static void clear()     {
    nameInput.setText("");
    victor.removeAllElements();
    printList.setListData(victor);
    part1.setText("");
    public static void rebuild()     {
    fileMenu.removeAll();
    fileMenu.add(menus());
    bar.add( fileMenu );
    public static void main(String args[])     {
         TextAreaDemo t = new TextAreaDemo();
         t.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);
    the code inside the method 'rebuild()' will work from inside the main JFrame body if assigned to a button (such as the example position denoted by HERE in the code), but that is undesirable as it requires the user to refresh manually every time they add a new ingredient. what i need is a method that can be called from another class/method/whatever.
    thankyou for any help you can offer, it is much appreciated

    The code you offered did not solve my problem. I have since entered the followinginto the actionlistener of a button on the JFrame,
    refreshMenu = new JButton("Refresh Menu");
    refreshMenu.addActionListener(
             new ActionListener() { 
                // display message dialog when user selects Preview...
                public void actionPerformed( ActionEvent event )
    fileMenu.removeAll();
    fileMenu.add(menus());
    bar.add( fileMenu );          
    );This does what i need, but i need these statements to be made from an external class, not a JButton,

Maybe you are looking for

  • HP LaserJet P3015 Creating its own copy in Control Panel

    Hi Everyone, I am new here.I've a HP LaserJet P3015 printer which is connected with my laptop via USB cable. Whenever i connect the cable to another port of the laptop it creates the copy of the printer naming with (Copy 1). Cna anyone help me immedi

  • How to find out the listeners on a Queue

    Hi, We are using publish/subscribe method to send messages. Given a queue name, is there any way to find out the number of sessions listening on this Queue. that is if there are two servers subscribed to listen messages from a Queue, is there a way t

  • My FLV looks horrible

    I'm trying to post a Quicktime movie into Flash CS3, but my FLV file looks AWFUL when compared to the original Quicktime video. When importing the Quicktime video, I've tried all kinds of settings. (Soreson Sparks was the worst.) I've changed the qua

  • Bug in Portal308 HLW Tutorial

    When you try to install the latest portal tutorial the import of hlw30_trl_sso.dmp fails with a "column not found" because the portal30_sso.wwutl_sso_transport_table$ and wwutl_sso_tx_person$ tables are missing the SUBSCRIBER_ID column. I altered the

  • How can I customize the toolbar when using the attribute browser

    In CVI 2012, the toolbar changes depending on the environment, e.g. it is different for the source window and the UI editor. The toolbar can be customized using the menu Options / Toolbar... Unfortunately, when using the attribute browser of the UI e