• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Gurus help!!!!!!!!

 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
trying to modify the list of options in a JMenu by reading the input provided by the user in a JTextField. For example the Jmenu
contained A,B and the user inputed C thus the new menu should contain A,B,C . The user`s input is being saved but the input is not shown. Im not sure if its a repaint, event or stream problem
can someone help PLEASE im stuck. Why is it that when I terminate the program and run it again it(the JMenu) does contain A,B,C?
Thank you for your time
public OptionsPane()
{
textField = new JTextField(15);
combo = new JComboBox();
combo.addItem("");
for(int i = 0; i < 5; i ++)
{
combo.addItem(itemStr[i]);
}
combo.setSelectedIndex(0);
combo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
int i = combo.getSelectedIndex();
if(OptionsPane.itemStr[i-1]== OptionsPane.itemStr[0])
{
System.out.println("Legacy");
textField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvente){
try
{
FileOutputStream out = new FileOutputStream("a:\\Legacy.txt",true);
PrintWriter p=new PrintWriter(out);

p.write(textField.getText());
p.close();

new AccountsTable().setUpBrokerColumn();

}
catch(Exception exception)
{
}
}
});
}
public void setUpBrokerColumn()
{

TableColumn brokerColumn = table.getColumnModel().getColumn(0);
while(true)
{
try
{
createMenu();
for(int i = 0; i < 5; i++)
{
String s = inFile[i].readLine();
while(s!=null)
{
menus[i].add(s);
s = inFile[i].readLine();
}
}

JMenu menu = ComboMenuBar.createMenu(""); for(int i = 0; i < 5; i++)
{
menu.add(menus[i]);

}
ComboMenuBar comboMenu = new ComboMenuBar(menu);
brokerColumn.setCellEditor(new MenuDefaultCellEditor(comboMenu));

//Set up tool tips for the Broker cells
DefaultTableCellRenderer renderer =
new DefaultTableCellRenderer();
renderer.setToolTipText("Click for combo box");
brokerColumn.setCellRenderer(renderer);
//Set tool tip for the Broker column header
TableCellRenderer headerRenderer = brokerColumn.getHeaderRenderer();
if(headerRenderer instanceof DefaultTableCellRenderer)
{
((DefaultTableCellRenderer)headerRenderer).setToolTipText(
"Click the Broker to see a list of choices");
break;
}

}
catch(FileNotFoundException e)
{
}
catch(IOException exception)
{
}
}
}

[Peter: Ugg...Tried editing your code, but the spacing is all messed up. Read the FAQ to see how to format your code so it's more readable.]
[This message has been edited by Peter Tran (edited February 15, 2001).]
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John,
You'll get much more help if you this topic was in the Swing / JFC / AWT forum, so I'm going to move it there for you.
-Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!