Maximize Frame, Uppercase detection

I create some swing application, i'm using JFrame, at my code i putsetSize(1024,768), i guest if i put that on my code, my application always fit to my resolution setting, but after i run my code, my application bigger than my resolution...

What i want to ask are, how to make my JFrame always fit to my resolution setting? and how to make my JFrame always Maximized, cos i think if my application always maximized, i will be automaticly fit into my resolution?

How to make detection from keyboard like this, i haveJOptionPane.showInputDialog(), what i want is, if someone type anything into my JOptionPane, it will always display Uppercase although the user input it withoutcapslock on keyboard

Thanks...

[755 byte] By [2Puluh11Lapan3a] at [2007-10-2 10:17:09]
# 1

> how to make my JFrame always Maximized

frame.setExtendedState(JFrame.MAXIMIZED_BOTH);

> if someone type anything into my JOptionPane, it will always display Uppercase

well, this is about as dodgy as it gets, but it seems to work

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

class Testing

{

public Testing()

{

final JOptionPane optionPane = new JOptionPane("Enter File Details:");

optionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);

optionPane.setWantsInput(true);

JDialog dialog = optionPane.createDialog(null, "File Details");

KeyboardFocusManager.getCurrentKeyboardFocusManager()

.addKeyEventDispatcher(new KeyEventDispatcher(){

public boolean dispatchKeyEvent(KeyEvent ke){

if(optionPane.isShowing())

{

int key = ke.getKeyChar();

if(key > 96 && key < 123)

{

ke.setKeyChar((char)(key-32));

}

}

return false;}});

dialog.setModal(true);

dialog.setVisible(true);

Object value = optionPane.getInputValue();

JOptionPane.showMessageDialog(null,"You entered "+value);

System.exit(0);

}

public static void main(String[] args){new Testing();}

}

Michael_Dunna at 2007-7-13 1:43:03 > top of Java-index,Desktop,Core GUI APIs...
# 2

> it will always display Uppercase

First, read the JTextField API. It gives an example of how to create a custom Document that will convert all characters to UpperCase. Note: the newer way to do this is to use a DocumentFilter, which is described in the "General Component Features" of the Swing tutorial which can be accessed by clicking on the "Text Component Features" link in the API description.

Next, you will need to create a JOptionPane using your custom JTextField. This posting gives an example of this can be done:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=669479

camickra at 2007-7-13 1:43:03 > top of Java-index,Desktop,Core GUI APIs...
# 3

I like the example above but I noticed that it is not possible to paste a text from the clipboard.

I want to use your example to make a key activation dialog for my software. When I send the keys to a user via email he might want to copy this key into the input area of the JOptionPane.

Any solution for this problem?

Thank you in advance!

krafziga at 2007-7-13 1:43:03 > top of Java-index,Desktop,Core GUI APIs...
# 4
> I like the example above but I noticed that it is not possible to paste a text from the clipboard.Sure it is. You just use Ctrl+V while focus is on one ot the text fields.
camickra at 2007-7-13 1:43:03 > top of Java-index,Desktop,Core GUI APIs...