CrazyEngineers
  • Neha
    Neha

    MemberJul 31, 2006

    JAVA related problems

    Hi everyone,
    I am learning JAVA these daz...My teacher is teaching me Applets these daz..Its quite interesting.
    As I said I found Applets interesting,I was trying to create a web page but I don't know how to increase the font size of a Label...Can anyone help me out??
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • sravik

    MemberAug 1, 2006

    hi dere !

    i saw ur problem, i can help u out..dont worry bout tat.

    ok to increase ur font size u need to use a method named setFont().

    setFont() method takes Font class object as argument. think little bit confusing rite..dont worry i will let u know by an example..

    consider

    Label l = new Label("Neha");

    Font f = new Font("verdana", Font.BOLD, 40);

    l.setFont(f);
    add(l);


    now dis will help u 2 hav a label of size 40, bold with verdana font.

    ok tats it. i think now it will b clear 4 u..hey as soon as xceute it let me know ok..anyways dis is ravi(sravik) presently in toronto, canada doing my MS.
    Are you sure? This action cannot be undone.
    Cancel
  • Neha

    MemberAug 1, 2006

    thanx a ton...who needs a tutor wen CE is there!!😉
    Are you sure? This action cannot be undone.
    Cancel
  • Kaustubh Katdare

    AdministratorAug 3, 2006

    Way to go CEans! [​IMG]

    The Big CE-Dream is coming into reality.

    -The Big K-
    Are you sure? This action cannot be undone.
    Cancel
  • Neha

    MemberAug 4, 2006

    Can you tell me,how to set the font color of Label...wud COLor.red work??
    Are you sure? This action cannot be undone.
    Cancel
  • Neha

    MemberAug 10, 2006

    I have got the answer to my question..the font color can be set by using setForeground(Color.red)
    Are you sure? This action cannot be undone.
    Cancel
  • Neha

    MemberAug 14, 2006

    using class object in Label

    How can we use the object of class in label?

    To make my question more clear, I have defined a class "time" which contains the time counter for 30minutes and I want to use its object in label.
    Are you sure? This action cannot be undone.
    Cancel
  • Neha

    MemberAug 19, 2006

    JTable...

    I wanna enter data in JTable in a specific row and column.

    Any help??
    Are you sure? This action cannot be undone.
    Cancel
  • sravik

    MemberAug 20, 2006

    inserting data at specific rows and columns

    hi dere !

    here is an example for your query. just have a look at this sample code.

    JTable t = new JTable(5,5); // creates table with 5 rows and 5 columns

    t.setValueAt(10,2,2); // set value 10 at 2nd row and 2nd column.

    do remember that the table is like two dimensional array. i mean 2 say that the rows and columns start at 0,0 and ends at m-1, n-1.

    setValueAt(Object, rows, columns).. hav a look at the parameters.
    hope you can implement it now.
    Are you sure? This action cannot be undone.
    Cancel
  • Neha

    MemberAug 21, 2006

    Thanx!!

    Can u tell me how can I color a specific cell i.e. 3*3 table in a 9*9 table and how can we resize an image?


    Thanx in advance😉
    Are you sure? This action cannot be undone.
    Cancel
  • sravik

    MemberAug 22, 2006

    about table 😀

    hi dere !

    ur class should extend DefaultTableCellRenderer and use the method

    public Component getDefaultTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean focus, int row, int col) method.

    here is an example. dis example takes the the table , the vavle, the row, column and checks whether the row is 3 and column is 3. if this condition is true the cell background color is set to red. the concept of CellRenderer is very very important.

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

    public class CustomTableCellRenderer extends DefaultTableCellRenderer
    {
    public Component getTableCellRendererComponent
    (JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int column)
    {
    Component cell = super.getTableCellRendererComponent
    (table, value, isSelected, hasFocus, row, column);

    if( row==3 && column==3)
    cell.setBackground(Color.red);
    return cell;

    }
    }
    Are you sure? This action cannot be undone.
    Cancel
  • sravik

    MemberAug 23, 2006

    resizing image 😀

    hi dere !

    this is regarding resizing the image.

    ok, you can use getScaledInstance method present the java.awt.Image .

    the syntax is

    public Image getScaledInstance(itn width, int height, int hints);

    this method creates a scaled version of the your image into new Image object.

    hope now you can use this method for resizing.

    Happy Programming
    Are you sure? This action cannot be undone.
    Cancel
  • Neha

    MemberAug 24, 2006

    Thanx Sravik.

    I'll try it out.
    Are you sure? This action cannot be undone.
    Cancel
  • Neha

    MemberNov 10, 2006

    Re: about table 😀

    sravik
    hi dere !

    ur class should extend DefaultTableCellRenderer and use the method

    public Component getDefaultTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean focus, int row, int col) method.

    here is an example. dis example takes the the table , the vavle, the row, column and checks whether the row is 3 and column is 3. if this condition is true the cell background color is set to red. the concept of CellRenderer is very very important.

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

    public class CustomTableCellRenderer extends DefaultTableCellRenderer
    {
    public Component getTableCellRendererComponent
    (JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int column)
    {
    Component cell = super.getTableCellRendererComponent
    (table, value, isSelected, hasFocus, row, column);

    if( row==3 && column==3)
    cell.setBackground(Color.red);
    return cell;

    }
    }
    My class already extends JFrame, how can I make it to extend DefaultCellRenderer as one class can iextend a single class only?

    Reply as soon as possible..
    Are you sure? This action cannot be undone.
    Cancel
  • jatin

    MemberNov 13, 2006

    hi neha
    u know web designing
    i know a bit except java can u pls help me to understand java.
    i want to start java frm vry basic
    pls help
    Are you sure? This action cannot be undone.
    Cancel
  • Varsha0802

    MemberSep 26, 2010

    hi...........i have a doubt. i want to take an array of integer values as input using command line arguments. how can i do it?
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberSep 26, 2010

    Hi varsha
    Please ask you question in separate thread in computer science section
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register