Forums Register Login

JComboBox ... Problem :-(

+Pie Number of slices to send: Send
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...
.............
}
}
+Pie Number of slices to send: Send
import javax.swing.plaf.basic.BasicFileChooserUI;

JFileChooser fc = new JFileChooser(".");
BasicFileChooserUI fcUI = (BasicFileChooserUI)fc.getUI();
fcUI.getChangeToParentDirectoryAction().setEnabled(false);
+Pie Number of slices to send: Send
Moving to Swing...
It was the best of times. It was the worst of times. It was a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 707 times.
Similar Threads
help!! on dynamic select box - 2
ActionEvent
JComboBox
GUI like the Internet Explorer
Processing with two JComboBox's in one JPanel/JFrame
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:09:11.