Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JComboBox ... Problem :-(  RSS feed

 
Javeo Lineo
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i just want to ask how do i prevent JComboBox in the JFileChooser from, going up to the next folder, but i can go to the subfolder of the defaulth path...

example:

my default path is C:\Temp\data, i can go to the subfolders of C:\Temp\data, but i cannot go upward like C:\Temp or C:\, in this case if the user goes up, the JComboBox will force to set the defaulth path.

here are some of the codes...

public void load()
{
��.
cJComboBox.addActionListener( this );
��..
}


public void actionPerformed(ActionEvent pEvent)
{
Object mSourceObj = pEvent.getSource();
if (mSourceObj.equals(cJComboBox))
{
comboboxChanged();
}
}


private void comboboxChanged()
{
String mlen = cJComboBox.getSelectedItem().toString();

if (currentPath.startsWith(defaultPath))
{
.............
}
else
{
setCurrentDirectory(new File(defaulthPath)); -> force the combobox to default path...
.............
}
}
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import javax.swing.plaf.basic.BasicFileChooserUI;

JFileChooser fc = new JFileChooser(".");
BasicFileChooserUI fcUI = (BasicFileChooserUI)fc.getUI();
fcUI.getChangeToParentDirectoryAction().setEnabled(false);
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Swing...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!