ashok kandaswamy

Greenhorn
+ Follow
since Aug 19, 2008
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 ashok kandaswamy

Hi All,

currently i am using JTextpane.In Key event now i am capturing shift_enter , control + W , by following code...actually i need key suppress here..

KeyStrokectrl_Wkeystroke=KeyStroke.getKeyStroke(KeyEvent.VK_W,ActionEvent.CTRL_MASK,false);//Falsesuppresses the tab keyrelease event..
textPane.getInputMap().put(ctrl_Wkeystroke, "ctrl_W_Pressed");
ControlWPressedAction ctrlWAction =new ControlWPressedAction(this,script,this.textPane);
textPane.getActionMap().put("ctrl_W_Pressed", ctrlWAction);


Like that i wants to capture "(" this key and i really want to suppress the actual key event i want to write my own code there...... For that i am using,

KeyStroke openbraceKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT_PARENTHESIS, 0, false);//False suppresses the tab keyrelease event.. textPane.getInputMap().put(openbraceKeyStroke, "open_brace_pressed");
OpenBracedAction openBraceAction = new OpenBracedAction(this, script, this.textPane);
textPane.getActionMap().put("open_brace_pressed", openBraceAction);

The above code but it's not capturing..and then i am using

if (keyCode == KeyEvent.VK_LEFT_PARENTHESIS) {
System.out.println("I AM IN KEY RELEASED VK_LEFT_PARENTHESIS ");
}

In key Typed , key released...but still i am not able to get For " ( "....please tell me.i really need quick replay..

Thanks in advance......

-Ashok.......
15 years ago
hi all ,
i am trying to connect mysql Db by this code ,

import java.sql.*;
//import com.mysql.jdbc.Driver;

public class MysqlConnect{
public static void main(String[] args) {
System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "test";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";
try {
//Class.forName(driver).newInstance();
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}
}

----------------------------------------------------------------------
exception:
------------------------------
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver

at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at MysqlConnect.main(MysqlConnect.java:15)

-------------------
but while executing this i got this exception....?

please help me..it's urgent..

Originally posted by Manoj Paul:
Yes its working ... thank you all my friends... great help..



hi all.

one more interesting question here..the same thing is possible with JDialogue...
15 years ago

Originally posted by Michael Dunn:
> so now tell me how i can get JInhternalFrame without the three but title is must...

read JInternalFrame's apidocs.

the answer is so simple
(you'll give yourself a triple uppercut when you find it)



yeah very nice i got it..thank you all........

and have a splendid Sunday.....
15 years ago
Campbell ,

thanks a lot.. i got it..

now i want one popupwindow without any min,max,close button...but i want title.

i tried lot of things.but now i am faded up.fianlly after long time googling it was supported by JInternalFrame's..so now tell me how i can get JInhternalFrame without the three but title is must...also i want to move the popup around the document..

thanks in advance Ranchers

by
Ashok
15 years ago

Originally posted by Campbell Ritchie:


Please read this FAQ. And it is not usual for the tab key to be used to navigate around the document.



hi okay,

without tab key now iam navigating through the document by abstract action class and keyMaps..

but what i want is i want to move the caret position to some new location....the document yet not travalled.

like i am line 1 .after typing ashok(now the offset vale is 5)now i am hitting a tab i want to one action at same time i want to move the cursor position to next line ..now i am able to the action after hitting the tab..but i am not able to move the cursor position..
like ....

textPane.setCaretPosition(some new offset value i am given);
textPane.moveCaterPosition(some new offset value i am given);

but the above two are failed because my new value is greater than the document length..

so What i want to do....?

give me ideas please quick....

i am strucked here....

by
ashok.
15 years ago
hi ,

we are developing one word processor.(for movie scripts)

in core functionality i want to control tab for my own..

that is i have handllling some (xml)(like action,character,dialogue , scene)
each object having certain properties(like left indent , right indent , font size,color) i am defined each in one mutual attribute set.
objects in JTextPane.i want to move on objet from another when tab is pressed.

at the same time i want to set the cursor to the new line.

ex:

i am typing "ashok" (in line 1 )in JtextPane and press Tab i want to move the cursor to the line 2..


genius please help it's very urgent requirement..i am deep trouble now..

help me soon....


Thanks
ashok.
15 years ago
yes.i am only suggestion is instead of setting icon to Jlabel.make it one Jpanel and setback round as image..then add whatever we ant to add on this Jpanel.

like

leftPanel = new ImagePanel(imgPath + "final/left_bg.jpg"); //here path of he image

public class ImagePanel extends JPanel{
private Image img;

public ImagePanel(String img) {
this(new ImageIcon(img).getImage());
}

public ImagePanel(Image img)
{
this.img = img;
Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
setPreferredSize(size);
setMinimumSize(size);
setMaximumSize(size);
setSize(size);
setLayout(null);
}

public void paintComponent(Graphics g) {
g.drawImage(img, 0, 0, null);
}

}



Originally posted by adeeb alexander:
Hi,
I want to add a image as a background on a panel i tried it by using ImageIcon icon = new ImageIcon("box.jpg");
JLabel iconl = new JLabel(icon);
but the panel consists of other components also like textfields. I am getting the image below the textfields when i added the JLabel. I actually want this image to be set as the complete background on which other components must be placed. Some body please help me to solve this.

Thanks & Regards

15 years ago
hi ,
i am developing one smart word processor in java siwng,for load and save operation am using filechossers.

i am supporting multiple documents also using tabbedpane.i want to do when typing something on the document and without save that we will close the application means i want to do the save operation here.

please help very urgent,

thanks in advance.
by
ashok
15 years ago

Originally posted by muthurama krishnan:
Thanks AshokKumar

Instead of JDesktopPane I'm using JPanel, in that JPanel only I'm adding the JInternalFrame



It's ok.obliviously it will works.
15 years ago

Originally posted by muthurama krishnan:
how to hide the (JInternalFrame's)border in the JInternalFrame



by using this method....
public void hide()

{
if (isIcon()) {
getDesktopIcon().setVisible(false);
}
super.hide();
}

i will hope nut make it confirm..

---Ashok.K.....
15 years ago

Originally posted by Bear Bibeault:
"ashok", please check your private messages for an important administrative matter. Again.



hi Bear Bibeault,
I will hpoe now i can do it properly....

Thanks,,

Ashokkumar.
15 years ago

Originally posted by Dilshan Edirisuriya:
Also note that I have added System.setProperty("apple.laf.useScreenMenuBar", "true") in the coding, so that all the menu items will be in the Mac menu bar. Once I make this false it appear as a normal JFrame window with the menu bar and it does not produce this issue.
The reason for this behavior is moving the menubar from the frame to mac os menu bar position.
I tried to solve this issue by making it heavyweight using JPopupMenu.setDefaultLightWeightPopupEnabled(false. But also it did not work.
Any suggestions?




HI Edirisuriya,

In mac normally we don't want to set any look and feel.because mac takes the menubar for it's own.so you don't set any look and feel in the code for mac implementation.just gave it as without any look and feel code...then i will hope now it will works fine.because the same issue i had faced in mac with swing application....

--ashok---
15 years ago

Originally posted by Rob Prime:
Yes it is. This exactly what layout managers like BorderLayout are for.

And please read your private messages ASAP. The issue is still not fixed correctly.

[ August 19, 2008: Message edited by: Rob Prime ]


hi Rob,
i have changed my name .please noted it out....

hi thank you.....okay..,..but what my issue is.....

please tell how can i implement it with border layout......(i can do but the result is not came properly..as of now....)
that's y am confused...am very new to layout concepts..
the following method i have used for Resizing the inner components of the stausbar..according to framesize.....

please anybody tell how can archive the live resizing.....? ?
if that is possible with border layout means..! HOW CAN...?

public int statusBarResizing(int Width) {

//GET THE CURRENT WIDTH AND HEIGHT......
int frameWidth = baseFrame.getWidth();
System.out.println(frameWidth);

int frameHeight = baseFrame.getHeight();
System.out.println(frameHeight);

scrollPaneHeight = frameHeight - statusPanelHeight;
stausPanel.setBounds(0, scrollPaneHeight, frameWidth, 110);
stausPanel.setVisible(true);
sp.setBounds(0, 0, frameWidth - 9, scrollPaneHeight);
mainPanel.setBounds(0, 0, frameWidth, frameHeight);

//CHANGED THE WIDTH FOR EACH PANEL......

changedDescriptionWidth = (frameWidth * 68) / 100;
changedClockWidth = (frameWidth * 10) / 100;
changedPageWidth = (frameWidth * 20) / 100;

int pageStartPoint = (frameWidth * 80) / 100;
int descriptionStartPoint = (frameWidth * 10) / 100;

System.out.println("changedDescriptionSize:" + changedDescriptionWidth);
System.out.println("changedClockSize:" + changedClockWidth);
System.out.println("changedPageSize" + changedPageWidth);

//GET THE PRIORITY BASED ON COMPARE THE PREF SIZE WITH CHANGED SIZE.....

//PRIORITY METHOD.....
public int getPriority() {
int priority = 0;

if (changedDescriptionWidth < prefDescriptionWidth) {
priority = 3;
return priority;
} else if (changedClockWidth < prefClockWidth && changedPageWidth >= prefPageWidth) {
priority = 1;
return priority;
} else if (changedClockWidth < prefClockWidth && changedPageWidth < prefPageWidth) {
priority = 2;
return priority;
}
return priority;

}

int switchPrior = getPriority();
System.out.println("Current Priority:" + switchPrior);

switch (switchPrior) {

case 1: {
describePanel.setVisible(true);
pagingPanel.setVisible(true);
noOfComponentsInStatusPanel--;
clockPanel.setVisible(false);
int changedWidthForResizing = changedClockWidth / noOfComponentsInStatusPanel;
changedPageWidth += changedWidthForResizing;
int changedWidthOfRemainder = (changedClockWidth + changedPageWidth) % noOfComponentsInStatusPanel;
changedDescriptionWidth += (changedWidthForResizing + changedWidthOfRemainder);
descriptionStartPoint = 0;
pageStartPoint = (frameWidth * 80) / 100;

pagingPanel.setBounds(pageStartPoint, 0, changedPageWidth, 100);
describePanel.setBounds(descriptionStartPoint, 0, changedDescriptionWidth, 100);
noOfComponentsInStatusPanel++;
return changedDescriptionWidth;

}
case 2: {
describePanel.setVisible(true);
noOfComponentsInStatusPanel--;
clockPanel.setVisible(false);
pagingPanel.setVisible(false);
int changedWidthForResizing = (changedClockWidth + changedPageWidth) / noOfComponentsInStatusPanel;
int changedWidthOfRemainder = (changedClockWidth + changedPageWidth) % noOfComponentsInStatusPanel;
changedDescriptionWidth += (changedWidthForResizing + changedWidthOfRemainder);
descriptionStartPoint = 0;

describePanel.setBounds(descriptionStartPoint, 0, changedDescriptionWidth, 100);
describePanel.setVisible(true);
noOfComponentsInStatusPanel++;
return changedDescriptionWidth;
}
case 3: {
stausPanel.removeAll();
return changedDescriptionWidth;
}
default:
{
describePanel.setVisible(true);
pagingPanel.setVisible(true);
clockPanel.setVisible(true);
clockPanel.setBounds(0, 0, changedClockWidth, 100);
describePanel.setBounds(descriptionStartPoint + 5, 0, changedDescriptionWidth, 100);
pagingPanel.setBounds(pageStartPoint + 10, 0, changedPageWidth, 100);
}
return changedDescriptionWidth;
}

}

THANKS,
ASHOKKUMAR.K
15 years ago

Originally posted by Rob Prime:
"s.k.a.k.",

Please read your private messages regarding an important announcement.

Thank you,

Rob


As for your problem, why not just use the default BorderLayout, and position your status bar using BorderLayout.SOUTH? It will then keep its preferred height, but the width will be whatever the width of the frame is.
You can't add components to the frame using BorderLayout.WEST or EAST though since those have precedence. The drawing order in BorderLayout:
- WEST and EAST go first, with their preferred width and frame height
- NORTH and SOUTH go next, with their preferred height and remaining frame width
- CENTER goes last, taking up all remaining space



Thank you....

But for that also some confusion will be....

when the size of the frame is reduced somewhat..we want to compare the preferred and changed size of the component and if it is less we want to hide that and resize the remaining components to the current frame size.....(inside the status bar panel)....

is this thing also possible if we handle all the things with border layout..? ? ? ? ? ? ? ? ? ......
15 years ago