kim jungil

Greenhorn
+ Follow
since Sep 27, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by kim jungil

u can use celleditor and cellrender to try.
maybe it can
22 years ago
http://www2.gol.com/users/tame/swing/examples/SwingExamples.html
in this web site u can find the function what u want
22 years ago
u can use setRowCount() to control your table row's count
22 years ago
i use "1.4.0" too.
but i can not print out "AAAA" anyway
why?
22 years ago
I need help!!
Now, i want to make an application with several hotKeys in JFrame.My source like this:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.util.*;
public class Demo extends JFrame {
public Demo () {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.enableEvents(AWTEvent.KEY_EVENT_MASK);
getContentPane().setLayout(null);
closeBtt.setBounds(new Rectangle(0, 13, 19, 40));
closeBtt.setBorder(new TitledBorder(""));
closeBtt.setHorizontalAlignment(SwingConstants.LEFT);
closeBtt.setHorizontalTextPosition(SwingConstants.LEFT);
closeBtt.setMargin(new Insets(0, 0, 0, 0));
closeBtt.setMnemonic('0');
closeBtt.setText("X");
closeBtt.setVerticalAlignment(SwingConstants.TOP);
closeBtt.setVerticalTextPosition(SwingConstants.TOP);
this.setEnabled(true);
templateLab.setText("template");
templateLab.setBounds(new Rectangle(23, 25, 80, 17));
templateCB.setBounds(new Rectangle(103, 23, 109, 21));
codeLab.setText("name");
codeLab.setBounds(new Rectangle(225, 26, 33, 17));
codeTxt.setBounds(new Rectangle(266, 23, 63, 21));
setBtt.setBounds(new Rectangle(340, 20, 79, 27));
setBtt.setBorder(new TitledBorder(""));
setBtt.setText("set");
getContentPane().add(templateCB, null);
getContentPane().add(codeTxt, null);
getContentPane().add(setBtt, null);
getContentPane().add(closeBtt, null);
getContentPane().add(templateLab, null);
this.getContentPane().add(codeLab, null);
}
protected void processKeyEvent(KeyEvent evt) {
super.processKeyEvent(evt);
if(evt.getKeyCode() == KeyEvent.VK_F4){
System.out.println("AAAA");
}
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
;
}
Demo demo = new Demo();
demo.setBounds(50,50,479, 80);
demo.show();
}
private JButton closeBtt = new JButton();
private JLabel templateLab = new JLabel();
private JComboBox templateCB = new JComboBox();
private JLabel codeLab = new JLabel();
private JTextField codeTxt = new JTextField();
private JButton setBtt = new JButton();
}
when i clicked the F4 button, i can not catch the KeyEvent. "AAAA" is not printed.
What problem with my program?
help me, plz
thank u

BTW, if i remove all the components from JFrame except label, "AAAA" will be printed.
if possible, give me a demo.
22 years ago
//this source maybe help u.
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.event.*;
public class Test extends JFrame {
JTree tree = new JTree();
DefaultTreeModel model = (DefaultTreeModel)tree.getModel();
TreeSelectionModel selectionModel = tree.getSelectionModel();
JButton removeButton = new JButton("Remove selected node");
JButton addButton = new JButton("Add node");
public Test() {
Container contentPane = getContentPane();
selectionModel.setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION);
contentPane.add(new ControlPanel(), BorderLayout.NORTH);
contentPane.add(tree, BorderLayout.CENTER);
tree.addTreeSelectionListener(
new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
TreePath path = e.getNewLeadSelectionPath();
boolean nodesAreSelected = (path != null);
addButton.setEnabled(nodesAreSelected);
removeButton.setEnabled(nodesAreSelected);
}
});
model.addTreeModelListener(new TreeModelListener() {
public void treeNodesInserted(TreeModelEvent e) {
showInsertionOrRemoval(e, " added to ");
}
public void treeNodesRemoved(TreeModelEvent e) {
showInsertionOrRemoval(e, " removed from ");
}
private void showInsertionOrRemoval(TreeModelEvent e,
String s) {
Object[] parentPath = e.getPath();
int[] indexes = e.getChildIndices();
Object[] children = e.getChildren();
Object parent = parentPath[parentPath.length-1];
JOptionPane.showMessageDialog(Test.this,
"Node \"" + children[0].toString() +
"\"" + s + parent.toString() +
" at index " + indexes[0],
"Node Added or Removed",
JOptionPane.INFORMATION_MESSAGE);
}
public void treeNodesChanged(TreeModelEvent e) {}
public void treeStructureChanged(TreeModelEvent e) {}
});
}
class ControlPanel extends JPanel {
public ControlPanel() {
addButton.setEnabled(false);
removeButton.setEnabled(false);
add(addButton);
add(removeButton);
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
TreePath path =
selectionModel.getSelectionPath();
MutableTreeNode parent, node =
(MutableTreeNode)path.getLastPathComponent();
if(path.getPathCount() > 1)
parent = (MutableTreeNode)node.getParent();
else
parent = (MutableTreeNode)node;
int index = parent.getIndex(node) + 1;
String s = JOptionPane.showInputDialog(
Test.this,
"Enter a name for the new node:",
"New Tree Node",
JOptionPane.QUESTION_MESSAGE);
MutableTreeNode newNode =
new DefaultMutableTreeNode(s);
model.insertNodeInto(newNode, parent, index);
}
});
removeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
TreePath path =
selectionModel.getSelectionPath();
if(path.getPathCount() == 1) {
JOptionPane.showMessageDialog(ControlPanel.this,
"Can't remove root node!");
return;
}
MutableTreeNode node =
(MutableTreeNode)path.getLastPathComponent();
model.removeNodeFromParent(node);
}
});
}
}
public static void main(String args[]) {
Test t = new Test();
t.setSize(400,300);
t.show();
}
}
22 years ago
u must use validate,or updateUI refresh your UI.
22 years ago
u can add ComponentListener in the frame, it can receive component events from current component.
And u can use setResizable(boolean resizable).resizable - true if this frame is resizable; false otherwise.
22 years ago
Rene Liebmann, thank u for you reply.
but this it neednt add keyListener in any components, because i use processEvent not keyTyped or other method in KeyListener.
"protected void processEvent(KeyEvent evt)" is overrided the JFrame's method, it can catch the keyListener.Because i have added "this.enableEvents(AWTEvent.KEY_EVENT_MASK);".

u can complie my source and run it, if there is no components on JFrame, it can catch the KeyListener, but if i added JButton or JTextField it can not catch it.
22 years ago
I need help!!
Now, i want to make an application with several hotKeys in JFrame.My source like this:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.util.*;
public class Demo extends JFrame {
public Demo () {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.enableEvents(AWTEvent.KEY_EVENT_MASK);
getContentPane().setLayout(null);
closeBtt.setBounds(new Rectangle(0, 13, 19, 40));
closeBtt.setBorder(new TitledBorder(""));
closeBtt.setHorizontalAlignment(SwingConstants.LEFT);
closeBtt.setHorizontalTextPosition(SwingConstants.LEFT);
closeBtt.setMargin(new Insets(0, 0, 0, 0));
closeBtt.setMnemonic('0');
closeBtt.setText("X");
closeBtt.setVerticalAlignment(SwingConstants.TOP);
closeBtt.setVerticalTextPosition(SwingConstants.TOP);
this.setEnabled(true);
templateLab.setText("template");
templateLab.setBounds(new Rectangle(23, 25, 80, 17));
templateCB.setBounds(new Rectangle(103, 23, 109, 21));
codeLab.setText("name");
codeLab.setBounds(new Rectangle(225, 26, 33, 17));
codeTxt.setBounds(new Rectangle(266, 23, 63, 21));
setBtt.setBounds(new Rectangle(340, 20, 79, 27));
setBtt.setBorder(new TitledBorder(""));
setBtt.setText("set");
getContentPane().add(templateCB, null);
getContentPane().add(codeTxt, null);
getContentPane().add(setBtt, null);
getContentPane().add(closeBtt, null);
getContentPane().add(templateLab, null);
this.getContentPane().add(codeLab, null);
}
protected void processKeyEvent(KeyEvent evt) {
super.processKeyEvent(evt);
if(evt.getKeyCode() == KeyEvent.VK_F4){
System.out.println("AAAA");
}
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
;
}
Demo demo = new Demo();
demo.setBounds(50,50,479, 80);
demo.show();
}
private JButton closeBtt = new JButton();
private JLabel templateLab = new JLabel();
private JComboBox templateCB = new JComboBox();
private JLabel codeLab = new JLabel();
private JTextField codeTxt = new JTextField();
private JButton setBtt = new JButton();
}
when i clicked the F4 button, i can not catch the KeyEvent. "AAAA" is not printed.
What problem with my program?
help me, plz
thank u

BTW, if i remove all the components from JFrame except label, "AAAA" will be printed.
22 years ago
your classpath is wrong.
classpath=.;%your classpath%
23 years ago
did you configure your dsn? and when you create the connection the dsn is correct?
"SELECT Test.Value FROM Projectdata WHERE Test.Field='FirstName'");
while( rs.next() )
document += "/V (" + rs.getString( "Value" ) + ")\n";
I think the fourth line is error.
you must write rs.getString( "Test.Value" ), because you write the query language, you select Test.Value, not Value.

Originally posted by Mike Shn:


System.exit(0);
23 years ago
I want to fill color between two different curves using JClass.If it is impossible use java2d.
how can I do it?
please give me code.
thank u!

[This message has been edited by kim jungil (edited October 16, 2001).]
23 years ago