Majestics 84 Posting Pro

Swing is the primary Java GUI widget toolkit. It is part of Oracle's Java Foundation Classes (JFC) — an API for providing a graphical user interface (GUI) for Java programs.

Swing was developed to provide a more sophisticated set of GUI components than the earlier Abstract Window Toolkit (AWT). Swing provides a native look and feel that emulates the look and feel of several platforms, and also supports a pluggable look and feel that allows applications to have a look and feel unrelated to the underlying platform. It has more powerful and flexible components than AWT. In addition to familiar components such as buttons, check boxes and labels, Swing provides several advanced components such as tabbed panel, scroll panes, trees, tables and lists.

Unlike AWT components, Swing components are not implemented by platform-specific code. Instead they are written entirely in Java and therefore are platform-independent. The term "lightweight" is used to describe such an element.

http://en.wikipedia.org/wiki/Swing_%28Java%29

More Links
http://cs.nyu.edu/~yap/classes/visual/03s/lect/l7/
http://www.javabeginner.com/java-swing/java-swing-tutorial

engrjawad commented: Nice Info +0
Majestics 84 Posting Pro

You have to change your key listener from Released to Pressed. Reason is on release it check so your characters go out of range. Hope this help.

 public void keyPressed(KeyEvent key)
Majestics 84 Posting Pro

for checking strings use equal function. == sign doesnt work properly while checking strings.

E.g String a  = "hello";
    a.equal("hello"); // ---- true ----------------
Majestics 84 Posting Pro

Better check the documentations for these warnings.
http://docs.oracle.com/javase/7/docs/api/javax/swing/JFrame.html

This error is because of serializable class. You have two ways to eliminate this

1) Give it a ID
private static final long serialVersionUID = any_Id;

2) If you using eclipse then use
@SuppressWarnings("serial") // this anotation will disable the warning because of serial.

vinnitro commented: thnx for helping it worked +2
Majestics 84 Posting Pro

If you are using JDK 1.7.0 then you have to use generic type as stated in its documentation
http://docs.oracle.com/javase/7/docs/api/javax/swing/JComboBox.html

You wont find that problem in 1.6.

Majestics 84 Posting Pro

there is no need for OR operator.... use this

while(name.toUpper().equals("anything".toUpper()))
{
    //-------- use to upper function to make it in one case and equal to compare them.
    // Above is java syntax i hope there will be same in c#
} 
Majestics 84 Posting Pro

echo your $name, also paste your url address here, seems like you are not passing correctly the name parameter.

Majestics 84 Posting Pro

There is no way u can do this.... You can create ur own title bar by overiding the original title bar. All you have to do is setUndecorated(true). This will remove title bar and you can place your custom title bar.

JakeA commented: thanks... how can i create a titlebar with the same look and feel as windows? +0
Majestics 84 Posting Pro

I think you are confused in passing a class as a paramater,
You can pass class as a paramater...

Lets Take an example

//----------- Class a -----------------
class a
{
    private int i;
    a(int j)
    {
        i = j;
    }

    public void print()
    {
    System.out.println(i);
    }
}


//----------------- Class b
class b
    {
        b(a A)
        {
            A.print();
        }
    }


//---------------- Main Class which is controlling the other classes    
public class c
{
    public static void main(String args[])
        {
            b B1  = new b(new a(10));
            b B2  = new b(new a(10));
        }
}       

Here i have taken two class a and b, while c is only for central controlling the two. b class constructor takes a class parameter and print it in the constructor.

Majestics 84 Posting Pro
DavidKroukamp commented: docs solve them all :) +8
Majestics 84 Posting Pro

First of all you dont have Card Class, thats why it is giving cant find symbol error.
Second you cant call non-static objects from static functions because static has more life then non static thats why compiler stops you from doing this.

Majestics 84 Posting Pro

Thats what is pointed in this link... You need a manifest file.
1) Create a text file name manifest
2) write -> Main Class: your mainclass name where your main function resides
3)goto cmd and write jar -cvfm manifest.txt yourjarname.jar yourclasses.class

I atleast earn a point for this... :)

Majestics 84 Posting Pro

http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html
this page explains every thing you require.

Majestics 84 Posting Pro

I have given you a hint to reach your goal. I cant solve all of your problem by pasting code. Its against the rule of this forum. In the above code i provided you a way to do some task over that strings which dont have p. So you simply need a method which counts string letter.

Majestics 84 Posting Pro
String s = "i am a p";
if(s.indexOf("p") == -1) //Index of method checks wether the character is present or not
    methodForCountingAllAlphabet(s); // count if p is not present
else
    continue(); // leave the string if p is present. This all the logic u require.
Majestics 84 Posting Pro

Your Problem : Scope of variable "i" is only to loop.
Try to declare a variable before for loop and use it inside for statement.

int i;
for(i=0;i<size;i++)
Majestics 84 Posting Pro

Do you have idea of creating manifest file?

Majestics 84 Posting Pro
 Your problem:new ImageIcon [] = getClass().getResource(name[0])
 What are u doing here...
 Solution: new ImageIcon(getClass().getResource(name[0]))
 Image Icon takes a parameter and that the image location.
 Hope this Help..
Majestics 84 Posting Pro

Grid Layout set the layout in the form of Rows and columns , there are no options for setting the content size... Better move to Grid Bag Layout, it is the most flexiable one with size and placement options.

Majestics 84 Posting Pro

are u using two different pc's?

Majestics 84 Posting Pro

I think you want to get the current salary of the user when u change the combo box value, try read this article
http://docs.oracle.com/javase/tutorial/uiswing/events/itemlistener.html
Make a method which on change or selected values in combo box search the file for the specified value and place it on the textfield.

Hope this helps....

Majestics 84 Posting Pro

Is there any way to extend gaps between jmenuitem?

Majestics 84 Posting Pro

Seems like u want to abort a thread cleanly if it fails to complete in a desired time. I think "interrupt" is one of the possible way's, u need a exception handler in which u can print a message or empty as u desire....

Majestics 84 Posting Pro

Reduce the number of column from 50 to 30....

incoming = new JTextArea(15, 30);

Your Text is appearing but isnt adjusting over frame correctly...

Majestics 84 Posting Pro

So where is the code............... Its a easy assignement
check:
scanner class for input through console mode
JOptionPane input dialogue box for input through GUI
code after creating a bit logic and submit here... We will help you further...

mKorbel commented: right +9
Majestics 84 Posting Pro

You have written a wrong function

public String toString(){//to string summerizing all the inputs on output.
return ("The date you have enterd is : " + this.month +", " + this.day+", " + this.year);
}

1) as this.month function prints the integer value
2) you must use setMonth(month) function to print the month....
3) Also i think you have to modify your function of setMonth(month) because its not efficient, because when you are using switch then you can use default statement, there is no need to use if statement here.

Majestics 84 Posting Pro

Well according to my opnion better practice will be making a textfield and a small beautiful button with it. Disable text field. When the user press the button the message box display and ask for data and display it in textfield...
And i think you need confirmation box , not the messagebox.

Majestics 84 Posting Pro
try
{
//------------- Write your code here
}
catch(Exceptiontype object)
{
//--------- What will happen when error generate.
}

Generally u can use "Exception" to handle all kinds of exception but its not a proper way because you cant understand different type of exception then... Search down exception type in documentation and implement them.

Majestics 84 Posting Pro

there is no need to mention auto increment explicitly , it will increment automatically when ever you insert a new row

further more the query must be like this

insert into Confirm(columnname) values(columnvalue)

Hope this Help......

nagatron commented: nice job. . I never thought my problem would be that easy. .hehe thank you +3
Majestics 84 Posting Pro

I think u made new id after getting banned onlineshade... Still i dont have any concernd with it...
If you want to run this application then u must have java ee configured or with java se u have to download api regarding to javax.mail from oracle website and provide the application at buildpath...

Majestics 84 Posting Pro
Majestics 84 Posting Pro

Line 21

ArrayList <StudentArrayList> record = new record <StudentArrayList>();

What is this record? .......................... :)

It must be ArrayList

Majestics 84 Posting Pro

http://download.oracle.com/javase/1,5.0/docs/api/java/util/Scanner.html

You can use Scanner Class for console inputs

http://www.java2s.com/Code/JavaAPI/javax.swing/JOptionPaneshowInputDialogObjectmessage.htm

You can use JOPTIONPANE INPUT DIALOG FOR GUI... Also u can use text fields, area many more things but for starter its easy.

Majestics 84 Posting Pro

Check this out... Its perfect Example

import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.*;
import javax.swing.text.*;

/* This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication, visit
 * http://creativecommons.org/licenses/publicdomain/
 */
public class AutoCompletion extends PlainDocument {
    JComboBox comboBox;
    ComboBoxModel model;
    JTextComponent editor;
    // flag to indicate if setSelectedItem has been called
    // subsequent calls to remove/insertString should be ignored
    boolean selecting=false;
    boolean hidePopupOnFocusLoss;
    boolean hitBackspace=false;
    boolean hitBackspaceOnSelection;
    
    KeyListener editorKeyListener;
    FocusListener editorFocusListener;
    
    public AutoCompletion(final JComboBox comboBox) {
        this.comboBox = comboBox;
        model = comboBox.getModel();
        comboBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (!selecting) highlightCompletedText(0);
            }
        });
        comboBox.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
                if (e.getPropertyName().equals("editor")) configureEditor((ComboBoxEditor) e.getNewValue());
                if (e.getPropertyName().equals("model")) model = (ComboBoxModel) e.getNewValue();
            }
        });
        editorKeyListener = new KeyAdapter() {
            public void keyPressed(KeyEvent e) {
                if (comboBox.isDisplayable()) comboBox.setPopupVisible(true);
                hitBackspace=false;
                switch (e.getKeyCode()) {
                    // determine if the pressed key is backspace (needed by the remove method)
                    case KeyEvent.VK_BACK_SPACE : hitBackspace=true;
                    hitBackspaceOnSelection=editor.getSelectionStart()!=editor.getSelectionEnd();
                    break;
                    // ignore delete key
                    case KeyEvent.VK_DELETE : e.consume();
                    comboBox.getToolkit().beep();
                    break;
                }
            }
        };
        // Bug 5100422 on Java 1.5: Editable JComboBox won't hide popup when tabbing out
        hidePopupOnFocusLoss=System.getProperty("java.version").startsWith("1.5");
        // Highlight whole text when gaining focus
        editorFocusListener = new FocusAdapter() {
            public void focusGained(FocusEvent e) {
                highlightCompletedText(0);
            }
            public void focusLost(FocusEvent e) {
                // Workaround for Bug 5100422 - Hide Popup on focus loss
                if (hidePopupOnFocusLoss) comboBox.setPopupVisible(false);
            }
        };
        configureEditor(comboBox.getEditor());
        // Handle initially selected object
        Object selected = comboBox.getSelectedItem();
        if (selected!=null) setText(selected.toString());
        highlightCompletedText(0);
    }
    
    public static void …
peter_budo commented: Thanx for sharing +16
Majestics 84 Posting Pro

Check setPreferredSize function.

Majestics 84 Posting Pro

u must use os.equals("");

Its a method for string.

Majestics 84 Posting Pro
Add them in a panel
public mypanel extends JPanel
{
Set Layout...
add combobox
add list
setBorder
}

Simple and easy Algorithem.

Majestics 84 Posting Pro
CASE 3:
CASE 5: fucntion();

This is the method for multiple choice in switch.

Majestics 84 Posting Pro

Let Me share this before closing this thread
http://www.japura.org/collapsiblepanel.html
Final Solution without work :)

peter_budo commented: Nice, thanx for sharing +16
mKorbel commented: note wrap that into invokeLater +9
Majestics 84 Posting Pro

http://letshare.it/blog/saving-file-to-computer.html Cross Posted.
I think you are choosing a directory.

Majestics 84 Posting Pro
JOptionPane.showMessageDialog(null,"Yahoo\nHotmail\nGmail");

:) , Also urs one is correct.

Majestics 84 Posting Pro

// Use this constructor
FileWriter("PATH",boolean append)

i mean to enable append use
FileWriter("PATH",true);

Majestics 84 Posting Pro

Follow this link
http://stackoverflow.com/questions/2596641/simulate-backspace-key-with-java-awt-robot

robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_SHIFT);
Majestics 84 Posting Pro

how to move a jframe which has no taskbar?

frame.addmousemotionlistener(this);

public void mousedragged(MouseEvent e)
{
   // What to write here
}

I tried setBounds of jframe but it flicker when we try to move the frame.

mKorbel commented: good question +1 +9
Majestics 84 Posting Pro

An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.

http://download.oracle.com/javase/tutorial/java/IandI/abstract.html

Majestics 84 Posting Pro

yes indeed its easy to create such things in java. You can also use vb.net and vc#.net.
Search the basics from the internet and try posting code.... We cant help without code nor we can make your project.

For Accomplisment check
1) JTable
2) Listener
3) JButton
4) JPanel
5) JFrame

and important of all make a diagram on paper of what you are going to create......

Majestics 84 Posting Pro
Majestics 84 Posting Pro

i havnt used jlist yet, but you can grab the idea from this website
http://download.oracle.com/javase/tutorial/uiswing/components/list.html

Majestics 84 Posting Pro

Read this http://www.roseindia.net/java/beginners/arrayexamples/SelectionSort.shtml

Grab Points from here and start working...

Majestics 84 Posting Pro

1) Use Code Tags [code] Code here [/code]

2) for(int i = 1; i < n; i++)
{
SortNow(int[] w, int n); 
} 
// dont u know how to pass paramter to function

3) Have u imported java.util.ArrayList; for Array List

4) We all make blunder's when we try new things, it isnt stupidity, that what call learning , but before starting try to read books so you can fully use your brain cells at time of coding.