dejie lin

Ranch Hand
+ Follow
since Jan 29, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by dejie lin

Hi all,
I have a very long long image, if users try to have a look at it by scrolling the scrollbar, it would be very trouble. How can make the scrollBar scrolled automatically, so that it just looks like playing movie
thanks a lot
dejie
20 years ago
Hi, all
By some reasons, i have to draw a very long long gragh, let's say it is much wider than 5000 pixels, Then i put the graph into a scrollpane, how can i make the "animation" so that the graph can move to left automatically, just like user is draging the scrollbar of the panel to have a look the graph?
thanks in advace
dejie
20 years ago
Hi all,
3 urgent questions, do help pls
first question:
There is a large image in a scrollPane, how can i know which part is displayed to user? for example, the part from pixel(10,10) to (610,810)is shown in screen, how can i know it??
second question:
if user is watching a "flower" in the center of the panel, once user presses the zoom out button, the whole image will be amplified. How can i make sure the "flower" still be shown in the center, won't go to right-down coner of the panel.
third question:
If i wanna the part from pixel(400,400) to (500,500) to be in the center of the panel, how can it do it??

thanks in advance
dejie
thanks in advacne
dejie
20 years ago
Hi Abhilash Vasudevan,
er....when i replace extends JPanel by JDialog, the only error happens at "can not resolve symbol-->subFrame.revalidate()" when compling, i have already check the API for revalidate() of JDialog, but no result, can you tell me what' the code for it?
another question: after extends JDialog using your method, can the subFrame keeps updating and shows the latest information to users whenever the "open" be pressed?
thanks for your time
dejie
20 years ago
hi abhilash_iv,
...my requirement is to allow user click the "open" button whenever they what, but there should be only one subframe appeared, which will shows the user's lastest modification from the mainFrame.
I can't understand your meaning well, can you specify it more?
thanks
dejie
20 years ago
Hi all,
There's a button in main GUI, press the button-->a new GUI will jump out, if press the button twice, there will be another new GUI jump out, how can i close the first GUI automatically when the second GUI comes out?
The code looks like:
class MainFrame extends JFrame{
....
Container f = getContentPane();
JButton openFrame = new JButton("open");
openFrame.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
subFrame sf=new subFrame();
sf.show();
}
});
f.add(openFrame);
....
}
class subFrame extends JPanel{
subFrame(){}
...
}
Thanks in advance
dejie
20 years ago
Hi, all
I have created a 2 two dimension array, it's a bit large
matrix m = new matrix[100][100];
then put something inside, if i don't use it anymore, how can i release the memory from m?
another question:
if later i define:
m = new matrix[50][50];
then put sometning inside, the m address is same as previous one, or it will put m into other memory range?
thanks in advance
dejie
20 years ago
Hi all
I got a nice code about file filter from a book, but there's a bug inside, the code looks like:
import javax.swing.filechooser.FileFilter;
import java.io.File;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class SaveAction extends JFrame {
public SaveAction() {
initComponents ();
pack();
}
private void initComponents(){
Container f = getContentPane();
f.setLayout(new BorderLayout());
jMenuBar = new JMenuBar();
File = new JMenu("File");
JMenuItem save = new JMenuItem("Save as Image");
File.add(save);

jMenuBar.add(File);
setJMenuBar(jMenuBar);
files = new JFileChooser(DEFAULT_DIRECTORY);
DEFAULT_DIRECTORY = new File("D:/");
save.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
File file =showDialog("Save BOM Diagram As Image","Save","Save",'s',new File(DEFAULT_DIRECTORY,"defaultname"));
if(file!=null){
saveImage(file);
}
}
});
}

private File showDialog(String dialogTitle,
String approveButtonText,
String as,
char approveButtonMnemonic,
File file)
{

files.setDialogTitle(dialogTitle);
files.setApproveButtonText(approveButtonText);
files.setApproveButtonToolTipText(as);
files.setApproveButtonMnemonic(approveButtonMnemonic);
files.setFileSelectionMode(files.FILES_ONLY);
files.rescanCurrentDirectory();
files.setSelectedFile(file);
ExtensionFilter imageFilter=new ExtensionFilter(".gif","Graphics Interchange Format(*.gif)");
files.addChoosableFileFilter(imageFilter);
files.setFileFilter(imageFilter);

int result = files.showDialog(SaveAction.this,null);
return (result == files.APPROVE_OPTION) ? files.getSelectedFile() : null;
}

public static void main (String args[]) {
JFrame saveaction =new SaveAction();
saveaction.show ();
}
public void saveImage(File file){}
private File DEFAULT_DIRECTORY;
private JFileChooser files;
private JMenuBar jMenuBar;
private JMenu File;
}

class ExtensionFilter extends FileFilter
{
public ExtensionFilter(String ext, String descr)
{
extension = ext.toLowerCase(); // Store the extension as lower case
description = descr; // Store the description
}
public boolean accept(File file)
{
return (file.isDirectory() || file.getName().toLowerCase().endsWith(extension));
}
public String getDescription()
{
return description;
}
private String description; // Filter description
private String extension; // File extension, including .
}
The problem is: there will be one more "Graphics Interchange Format(*.gif)" in the field Files of Type comes out after each time the FileChooser dialog shows, another word is there will be 10 more "Graphics Interchage Format(*.gif)" comes out if you press 10 times of File\Save as Image, maybe you can run above the programming and have a look how's the effect.
please give me some suggestion to correct it, thanks a lot!
dejie
20 years ago
hi all,
I have one frame with two panels inside, code likes the following:
public class ShowChart extends JFrame{
.....
Container f = getContentPane();
f.setLayout(new BorderLayout());
JPanel chart=new drawChart();
JPanel setting=new settingChart(chart);
f.add(setting,java.awt.BorderLayout.WEST);
f.add(chart);
.....
}
class drawChart extends JPanel(){
.....
setTableWidth(int w){...}
.....
}
class settingChart extends JPanel(){
drawChart chart;
pubic settingChart(drawChart c){
chart=c;
JTextField width = new JTextField("9",4);
add(width);
.....
JButton change = new JButton("Change");
change.addActionListener(new changeHandle(chart));
add(change);
change.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event){
int w = (int)Double.parseDouble(width.getText());

chart.setTableWidth(w);
}
});
}
}
Compilling error: local virable chart is accessed from within inner class, need to be declared as final. chart.setTabelWidth(w);
how can i deal with this problem? (i know it will be ok if i messy all the viriables and method of settingChart into the ShowChart class, but it seems not a nice way...)
thanks dejie
20 years ago
I didn't use thread in my programming...
I guess the problem are more concerned with the layout, there are two combobox in my layout(they are arranged in vertically, and inside a grid layout panel), when i remove one combobox, the chance of Frame GRAYed is much more less...but some times still happens
when i press "CTRL+X", the grayed frame will refreshed, can see again, i will made a jar file for my programming, i don't think the "CTRL+X" would be working well for my jar file....
i will try to work out on it, anybody has more suggestions do post pls.
thanks a lot
dejie
20 years ago
hi all
Any comand can set the radio button of landscape in the page setup to be selected automatically?
Regards
dejie
20 years ago
programming codes are quite a lot.... the purpose of my programming is to show a tree diagram to user, but sometimes the Frame are grayed, no any response, "CTRL+Xunlese the" are pressed in DOS prompt, the Frame will show the GUI again...
What's the function of "CTRL+X" in DOS prompt?
dejie
20 years ago
hi all,
I put some drawing and buttons into a frame.
But sometimes the whole frame beacomes "GRAY", can't see anything, even can't see those buttons, why???
anybody can give some some ideas?
thanks in advance
dejie
20 years ago
hi, all
the extensionName of a file would be named by myself, how can i change a nice icon for it rather than floating windows icon?
thanks
dejie
20 years ago
Hi all,
Sometimes the frame window was closed, but in the DOS prompt, it seems the program still running because the PATH>_ hasn't come out, unless the CTRL+c were pressed?? why???
any command for "immediately stop the process if the close action were perfomed"?? so far i was just using
public void windowClosing(WindowEvent evt) {
dispose();
}
});
thanks in advance
dejie
20 years ago