Trang 18 / 24 FirstFirst ... 131516171819202123 ... LastLast
Hiển thị kết quả từ 171 đến 180 / 238
  1. #171
    Tham gia
    10-11-2007
    Bài viết
    6
    Like
    0
    Thanked 0 Times in 0 Posts

    Buồn quá đi ! Fram nha (có ai biết fram ko ) (T_T) hu hu

    Frame không phụ thuộc vào applet và trình duyệt. Frame có thể hoạt động như một vật chứa hay như một thành phần (component). Bạn có thể sử dụng
    một trong những constructor sau để tạo một frame:

    Frame(): Tạo một frame nhưng không hiển thị (invisible)
    Frame(String title): Tạo một frame không hiển thị, có tiêu đề.

    minh hoạ cách tạo một Frame.



    import java.awt.*;
    class FrameDemo extends Frame
    {
    public FrameDemo(String title)
    {
    super(title);
    }
    public static void main(String args[])
    {
    FrameDemo f=new FrameDemo(“I have been Frameed!!!”);
    f.setSize(300,200);
    f.setVisible(true);
    }
    }

    Lớp được định nghĩa Framedemo là một lớp con của lớp Frame. Lớp FrameDemo này có một phương thức khởi tạo, trong phương thức khởi tạo này ta cho gọi phương thức super(). Nó sẽ gọi phương thức khởi tạo của lớp cha (trong trường hợp này là Frame). Mục đích của super() là gọi phương thức khởi tạo của lớp cha. Nó sẽ tạo một đối tượng của lớp con, lớp con này sẽ tạo Frame. Tuy nhiên, Frame vẫn không nhìn thấy được và không có kích thước. Để làm được điều này, ta sử dụng hai phương thức nằm trong phương thức main: setSize() và setVisible().

  2. #172
    Tham gia
    10-11-2007
    Bài viết
    6
    Like
    0
    Thanked 0 Times in 0 Posts

    đặt tên panel

    Panel được sử dụng để nhóm một số các thành phần lại với nhau. Cách đơn giản nhất để tạo một panel là sử dụng phương thức khởi tạo của nó, hàm Panel().
    code :
    import java.awt.*;
    class Paneltest extends Panel
    {
    public static void main(String args[])
    {
    Paneltest p=new Paneltest();
    Frame f=new Frame(“Testing a Panel”);
    f.add(p);
    f.setSize(300,200);
    f.setVisible(true);
    }
    public Paneltest()
    {
    }
    }



    Panel không thể được nhìn thấy trực tiếp. Do đó, chúng ta cần thêm panel đến một frame. Vì vậy ta cần tạo một frame mới và thêm Panel mới được tạo này vào đó. Tuy nhiên, frame sẽ không nhìn thấy được, và không có kích thước. Chúng ta sử dụng hai phương thức trong phương thức main – setSize() và setVisible() để thiết lập kích thước và hiển thị frame.

  3. #173
    Tham gia
    10-11-2007
    Bài viết
    6
    Like
    0
    Thanked 0 Times in 0 Posts
    các bạn có muốn biết phãi chuột trên frame làm thế nào ? các bạn sư phụ thì ko nói rồi...còn các newbaby thì tham khảo nha ....(^_^)

  4. #174
    Tham gia
    10-11-2007
    Bài viết
    6
    Like
    0
    Thanked 0 Times in 0 Posts
    Ngôn ngữ Java có một tập hợp các lớp đối tượng để tạo các menu. Có hai loại menu – pull down và pop-up. Menu làm cho ứng dụng ta xây dựng dễ sử dụng hơn. Ta chỉ có đặt duy nhất một thanh menubar trong một frame. Menubar là một thanh nằm ngang được đặt tại đỉnh của frame. Nó liệt kê các mục chọn khác nhau hay còn gọi là menu. Một menu độc lập có thể chứa các mục chọn con, các mục con này được gọi là Menu Item. Java cung cấp các Checkbox MenuItem, chúng có thể được bật hay mở, phụ thuộc vào trạng thái. Hình 5.14 minh họa cách sử dụng của menubar, menu, menuItem, và CheckboxMenuItem.

    code :
    import java.awt.*;
    import java.awt.event.*;
    class MyFrame extends Frame implements ActionListener, MouseListener
    {
    MenuItem exitItem;
    PopupMenu optionsMenu;
    Frame frame;
    public MyFrame()
    {
    setTitle("Menu Example");
    setSize(300,200);

    MenuBar mbar=new MenuBar();
    setMenuBar(mbar);

    Menu fileMenu=new Menu("File");
    mbar.add(fileMenu);
    fileMenu.addActionListener(this);
    MenuItem newItem=new MenuItem("New");
    fileMenu.add(newItem);
    MenuItem openItem=new MenuItem("Open");
    fileMenu.add(openItem);
    fileMenu.addSeparator();
    MenuItem saveItem=new MenuItem("Save");
    fileMenu.add(saveItem);
    MenuItem saveAsItem=new MenuItem("Save As");
    fileMenu.add(saveAsItem);
    fileMenu.addSeparator();
    exitItem=new MenuItem("Exit");
    fileMenu.add(exitItem);
    saveAsItem.addActionListener(this);

    Menu editMenu=new Menu("Edit");
    mbar.add(editMenu);
    editMenu.addActionListener(this);
    MenuItem cutItem=new MenuItem("Cut");
    editMenu.add(cutItem);
    MenuItem copyItem=new MenuItem("Copy");
    editMenu.add(copyItem);
    MenuItem pasteItem=new MenuItem("Paste");
    editMenu.add(pasteItem);
    editMenu.addSeparator();

    Menu helpMenu=new Menu("Help");
    mbar.add(helpMenu);
    helpMenu.addActionListener(this);
    MenuItem contentItem=new MenuItem("Content");
    helpMenu.add(contentItem);
    MenuItem indexItem=new MenuItem("Index");
    helpMenu.add(indexItem);
    Menu findMenu=new Menu("Find");
    helpMenu.add(findMenu);
    addMouseListener(this);
    MenuItem nameItem=new MenuItem("Search by Name");
    findMenu.add(nameItem);
    MenuItem cacheItem=new MenuItem("Search from cache");
    findMenu.add(cacheItem);
    optionsMenu=new PopupMenu("Options");
    editMenu.add(optionsMenu);
    optionsMenu.addActionListener(this);
    MenuItem readItem=new MenuItem("Read Only");
    optionsMenu.add(readItem);
    optionsMenu.addSeparator();
    Menu formatMenu=new Menu("Format text");
    optionsMenu.add(formatMenu);
    this.add(optionsMenu);
    formatMenu.addActionListener(this);
    CheckboxMenuItem insertItem=new CheckboxMenuItem("Insert",true);
    formatMenu.add(insertItem);
    CheckboxMenuItem overtypeItem=new CheckboxMenuItem("Overtype",false);
    formatMenu.add(overtypeItem);
    }
    public void actionPerformed(ActionEvent ae)
    {
    if (ae.getActionCommand().equals("Exit"))
    {
    System.exit(0);
    }
    }
    public void mouseEntered(MouseEvent m){}
    public void mouseExited(MouseEvent m){}
    public void mouseClicked(MouseEvent m)
    {
    optionsMenu.show(this,m.getX(),m.getY());
    }
    public void mouseReleased(MouseEvent m){}
    public void mousePressed(MouseEvent m){}
    public static void main(String[] args)
    {
    MyFrame frame=new MyFrame();
    frame.show();
    }
    }

    xong code này : khi bạn chạy chương trình sẽ thấy panel phải chuột ....pannel trong panel...hi hi chúc bạn thành công nhớ tham khảo trước khi sử dụng nha.....hi hi

  5. #175
    Tham gia
    25-06-2006
    Bài viết
    97
    Like
    0
    Thanked 4 Times in 3 Posts
    Cho tớ tham gia với, có rất nhiều cái kẹt mà ko biết hỏi đâu và những bí tát8 khi làm toán tử

    - Họ tên : Hung
    - Email: pvhung1885@yahoo.com
    - YM: pvhung
    - Nghê nghiệp: sinh vien ( đã tùng7 học Java bên Aptech Hoàng văn thụ 3 tháng)
    - Trình độ Java: tự đánh giá thì em đi tiểu học
    - Mục đích gia nhập :xin nhờ anh em giúp đỡ giải vây những mắc kẹt trong lúc làm bài
    - Các mặt mạnh : ti hí như hạt
    - Các mặt còn yếu : dày cui như tòa thành

    Chào các anh , em đang thực tập 1 bài practice test để chuẩn bị bài exam thật sự vào tháng 11 này , nó tổ chức trong lớp như trừong Aptech.

    Em tạo ra 1 số code cho user Interface nhung7 mà cái editor của em ko bật lên kết quả interface đc. Em đang xài 2 loại : BlueJ và JCreator pro 4.0. Em nghĩ là code cuả em có vấn để dò hoài ko ra nên vác lên đây nhờ các sư huynh giúp dùm:

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

    public class ticketmachine extends JFrame
    {
    Container container ;
    JTextField t1, t2, t3 ;
    JButton b1, b2, b3, b4 ;
    JLabel company, destination, type, number, departDate, returnDate ;

    public ticketmachine ()
    {
    super ("Ticket Machine");

    container = new Container();
    container = getContentPane();
    container.setLayout(new FlowLayout());
    container .add(company);
    container .add(destination);
    container .add(t2);
    container .add(type);
    container .add(t3);
    container .add(number);
    container .add(t1);

    company= new JLabel (" PVH Railway Company");
    destination= new JLabel ("Destination");
    type= new JLabel ("Class");
    number= new JLabel ("Number of Passenger");

    departDate= new JLabel (" Departure Date" );
    returnDate= new JLabel (" Return Date ");

    t1= new JTextField (10);
    t2= new JTextField (10);
    t3= new JTextField (10);

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

    }
    }


    Nhân tiện, em xin up lên đây bài Practice Test mà em đang làm, có sư huuynh nào thong thạo java thì giúp em giải cái này với. Em tạo đc User Interface nhưng tới phần toán tử thì bí lù.

    Requirements

    The requirements are to produce an interface that will:
    1. permit the ticket clerk to sell tickets
    a. to any of 5 named destinations - you decide the train company and the names and prices of the five destinations
    b. that are first or second class where first class is 2.6 times the second class fare
    c. that are single or return, where a standard return is 1.9 times the single fare and an economy return specifies the dates of
    travel and costs 0.8 times of the price of a standard return
    2. print the ticket to the standard output
    3. provide a summary of the transactions comprising:
    a. total money taken
    b. a printout of all the tickets issued
    4. handle erroneous input with suitable error messages.

    Note that the system is only used for journeys starting from the railway station where it is installed so only the destination station needs to be entered.

    Design suggestions

    There could be a class TicketMachine that generates the user interface.
    There could also be a class Ticket with fields (together with accessor and mutator methods) for the price, class of travel (first or second) and destination, as well as another field called details to hold all of these details in the form of a string for printing.
    A subclass of Ticket called ReturnTicket could calculate the price of a Return ticket as being 1.9 times that of a Ticket and make reference to the fact that it is a Return Ticket in the field details.
    A subclass of ReturnTicket called EconomyReturnTicket could have extra fields to hold the dates of departure and return and make reference in the field details to the fact that it is an Economy Return Ticket that is only valid on certain dates.
    TicketMachine could create a new Ticket or appropriate subclass each time a ticket is issued and store the tickets in an array list.

    Remember to test your solution fully . You should implement and test the following:
    • All input, output and error message boxes display correctly
    • Strings are entered for the departure and return dates
    o Error message is displayed if either string is empty for an Economy Return
    o Error message is displayed if either string is not empty for a Single Ticket or Standard Return
    • Any positive number is accepted in the number of passengers box
    o Error message is displayed for negative or zero entries
    o Error message is displayed for a string that is not an integer
    o Error message is displayed for an empty string
    o Re-entry is requested if there is an error
    • All information is displayed correctly on each travel ticket
    o Destination matches entry
    o Travel type matches entry
    o Fares are correctly calculated and match destination
     First Class calculations are correct
     Return fare calculations are correct
     Economy Return fare calculations are correct
    o Total number of passengers is correct
    o Total ticket cost is correct
    • All information is calculated and displayed correctly on the Summary output box
    o List of all tickets issued
    o Correct total money collected


    Nếu ai có lời giải hoặc có idea gì về bài này thì xin cứu em , gửi cho em wa email hay nick yahoo đều đc :
    pvhung1885@yahoo.com

    Em cầu mong các sư huynh giang rộng tay cưu giúp dùm em. Nếu em có thể hoàn tất bài test thực tập này em có khả năng làm tốt bài exam sau này. Hiên nay em đang mất ăn mất ngủ vì bài này.

  6. #176
    Tham gia
    21-07-2007
    Bài viết
    15
    Like
    0
    Thanked 0 Times in 0 Posts
    vương quang tú
    Yahoo : vuong_the_ngoc
    cho tui tha m gia với
    add nick của tui vào nhé

  7. #177
    Tham gia
    15-05-2006
    Bài viết
    53
    Like
    0
    Thanked 0 Times in 0 Posts
    -Họ Tên : Khuong Chau
    -Email : cndkhuong@yahoo.com
    -Nghề Nghiệp : Programer Analyst
    -Trình độ JAVA: Trung Bình
    -Mục đích gia nhập:tìm nhiều bạn bè cùng sở thích về Java
    -Những đóng góp: Hết mình trong khả năng
    -Yêu cầu trợ giúp: design pattern, J2ME, ....
    -Các mặt mạnh: tìm hiểu new tech, đam mê
    -Các mặt yếu: code còn yếu, lười mãn tính

  8. #178
    Tham gia
    04-06-2007
    Bài viết
    37
    Like
    0
    Thanked 2 Times in 2 Posts
    họ và tên : Vũ Văn Hùng
    Dịa chỉ : Hà Nội
    Nghề Nghiệp : sinh Viên
    Email : ursa_majoi@yahoo.com
    Nick : ursa_majoi
    Trình Độ : beginer
    Mục đích là học học nữa học mãi
    Đóng góp : chả lời tất cả những gì minh biết
    Yêu cầu chợ giúp :.. cười
    Các mặt mạnh là ....
    Các mặt yếu ..!!!

  9. #179
    Tham gia
    22-12-2007
    Bài viết
    19
    Like
    0
    Thanked 0 Times in 0 Posts
    - Họ tên: Bùi Đình Phong
    - Địa chỉ HN
    - Email cho2cafenau_ave@yahoo.com
    - YM: cho2cafenau_ave
    - Nghê nghiệp sinhvien it
    - Trình độ Java no biết
    - Mục đích gia nhập :muốn hoc thêm java
    - Những đóng góp : giúp được ai là giúp liền
    - Yêu cầu trợ giúp :
    - Các mặt mạnh :no thing
    - Các mặt còn yếu :every thing

  10. #180
    Tham gia
    26-09-2007
    Location
    Sydney
    Bài viết
    26
    Like
    0
    Thanked 0 Times in 0 Posts
    Số lượng người tham gia ngày càng đông, nhưng vẫn chưa thấy chương trình hành động gì của hội hết.

Trang 18 / 24 FirstFirst ... 131516171819202123 ... LastLast

Tags for this Thread

Bookmarks

Quy định

  • Bạn không thể tạo chủ đề mới
  • Bạn không thể trả lời bài viết
  • Bạn không thể gửi file đính kèm
  • Bạn không thể sửa bài viết của mình
  •