Hi all,
FYI im really new in Java.last time my project was in C but suddenly my supervisor changed to Java.i got the code from him (see below).wanna ask u guys how to learn Java and these means?
Lastly, how to create dropdown menu?

import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.Border;
import java.awt.*;
import java.io.*;
import java.util.*;

public class JScrollPanes extends JApplet
{
  //--------------------------------------------------
  // variable declarations for pairwise generation
    static int t_value=2;
    static int no_of_parameter = 0;
    String binary_setting;
    static int data[];
    static ArrayList<String> binary_cmd_list = new ArrayList<String>();
    static ArrayList<String> test_suite_list = new ArrayList<String>();
  // -----------------------------------------------

  private JButton generate_btn = new JButton("Generate Pairwise Data Sets");
  private Label label = new Label ("Enter Parameter Values");

  private JTextArea t1 = new JTextArea("", 1, 20), t2 = new JTextArea("",
      6, 20), t3 = new JTextArea("",13, 30);

  private JScrollPane sp3 = new JScrollPane(t3,
      JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
      JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

i guess import is like include in c.header file isnt it?
but, i dont know how to get the library for button like in this code import javax.swing.JButton;

Really need help!!!
Thanks for advance

Recommended Answers

All 2 Replies

Hey,
I'm not too sure exactly what your question is, but yeah an import statement in java is essentially the same as an include statement in C. I know a little about C, but I'm not sure if it is an object oriented language. Java is, so you would have to import any classes that aren't included in the java.lang package. Here is a link to the Java API, which is an extensive documentation of all the packages and classes in java. It's pretty easy to navigate, and I think the answer to your question might be found there.

http://java.sun.com/javase/7/docs/api/

The first thing you do is to make a

JMenuBar //  create a menu bar on top of the window that you are creating
JMenu // to create a file menu
JMenuItem // creates an item for your file menu
    eg. open, close, and save // to be under the file menu

you then add the JMenuItem to your JMenu

then you are going to stick your JMenu to your JMenuBar

I made a little program for you as an example but i m not sure if you can use this one for your project.

Good Luck!

import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class MyProgram extends JFrame
{
    private JMenuBar bar = new JMenuBar();
    private JMenu menu = new JMenu("file");
    private JMenuItem open = new JMenuItem ("Open");
    private JMenuItem close = new JMenuItem("Close");
    private JMenuItem copy = new JMenuItem("Copy");
    private JTextField textField = new JTextField();
    private JTextArea textArea = new JTextArea();
    private JFileChooser fileChooser = new JFileChooser();

    public static void main(String[] args)
    {
        MyProgram noName = new MyProgram();
        noName.setLocation(300, 200);
        noName.setSize(400, 400);
      noName.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      noName.setVisible(true);
    }

    public MyProgram()
    {
        super("My Program --- by Your Name"); // or you can leave it blank
        setLayout(new BorderLayout());

        menu.add(open);
        menu.add(copy);
        menu.add(close);
        bar.add(menu);
        setJMenuBar(bar);
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.