Showing posts with label size. Show all posts
Showing posts with label size. Show all posts

Set JRadioButton text size

Source code below will show you, how to set JRadioButton text size.

*****************************************************************
COMPLETE SOURCE CODE FOR : SetJRadioButtonTextSize.java
*****************************************************************


import javax.swing.JRadioButton;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJRadioButtonTextSize
{
public static void main(String[]args)
{
//Create radio button using JRadioButton with text ( I am a radio button )
JRadioButton radioButton=new JRadioButton("I am a radio button");

//Create font.
//Font Name : Default radio button font
//Font Style : Default radio button font style
//Font Size : 22
Font newRadioButtonFont=new Font(radioButton.getFont().getName(),radioButton.getFont().getStyle(),22);

//Set JRadioButton font using new created font
radioButton.setFont(newRadioButtonFont);

//Create a window using JFrame with title ( Set JRadioButton text size )
JFrame frame=new JFrame("Set JRadioButton text size");

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created radio button into JFrame
frame.add(radioButton);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


*****************************************************************
JUST COMPILE AND EXECUTE IT
*****************************************************************

Set JCheckBox text size

Source code below will show you, how to set JCheckBox text size.

***************************************************************************
COMPLETE SOURCE CODE FOR : SetJCheckBoxTextSize.java
***************************************************************************


import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJCheckBoxTextSize
{
public static void main(String[]args)
{
//Create check box using JCheckBox with text ( I am a check box )
JCheckBox checkBox=new JCheckBox("I am a check box");

//Create font.
//Font Name : Default check box font
//Font Style : Default check box font style
//Font Size : 22
Font newCheckBoxFont=new Font(checkBox.getFont().getName(),checkBox.getFont().getStyle(),22);

//Set JCheckBox font using new created font
checkBox.setFont(newCheckBoxFont);

//Create a window using JFrame with title ( Set JCheckBox text size )
JFrame frame=new JFrame("Set JCheckBox text size");

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created check box into JFrame
frame.add(checkBox);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


***************************************************************************
JUST COMPILE AND EXECUTE IT
***************************************************************************

Set JLabel text size

Source code below will show you, how to set JLabel text size.

************************************************************************
COMPLETE SOURCE CODE FOR : SetJLabelTextSize.java
************************************************************************


import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJLabelTextSize
{
public static void main(String[]args)
{
//Create label using JLabel with text ( HI EVERYONE !! I love you all )
JLabel label=new JLabel("HI EVERYONE !! I love you all",SwingConstants.CENTER);

//Create font.
//Font Name : Default label font
//Font Style : Default label font style
//Font Size : 22
Font newLabelFont=new Font(label.getFont().getName(),label.getFont().getStyle(),22);

//Set JLabel font using new created font
label.setFont(newLabelFont);

//Create a window using JFrame with title ( Set JLabel text size )
JFrame frame=new JFrame("Set JLabel text size");

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created label into JFrame
frame.add(label);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


************************************************************************
JUST COMPILE AND EXECUTE IT
************************************************************************

Set JTextArea text size

Source code below will show you, how to set JTextArea text size.

***********************************************************************
COMPLETE SOURCE CODE FOR : SetJTextAreaTextSize.java
***********************************************************************


import javax.swing.JTextArea;
import javax.swing.JFrame;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJTextAreaTextSize
{
public static void main(String[]args)
{
//Create text area using JTextArea
JTextArea textArea=new JTextArea();

//Set line wrap to true
textArea.setLineWrap(true);

//Create font.
//Font Name : Default text area font
//Font Style : Default text area font style
//Font Size : 22
Font newTextAreaFont=new Font(textArea.getFont().getName(),textArea.getFont().getStyle(),22);

//Set JTextArea font using new created font
textArea.setFont(newTextAreaFont);

//Create a window using JFrame with title ( Set JTextArea text size )
JFrame frame=new JFrame("Set JTextArea text size");

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created text area into JFrame
frame.add(textArea);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,500);

//Make JFrame visible
frame.setVisible(true);
}
}


***********************************************************************
JUST COMPILE AND EXECUTE IT
***********************************************************************

Set JTextField text size

Source code below will show you, how to set JTextField text size.

***********************************************************************
COMPLETE SOURCE CODE FOR : SetJTextFieldTextSize.java
***********************************************************************


import javax.swing.JTextField;
import javax.swing.JFrame;

import java.awt.FlowLayout;
import java.awt.Font;

public class SetJTextFieldTextSize
{
public static void main(String[]args)
{
//Create text field using JTextField
JTextField textField=new JTextField(20);

//Create font.
//Font Name : Default text field font
//Font Style : Default text field font style
//Font Size : 16
Font newTextFieldFont=new Font(textField.getFont().getName(),textField.getFont().getStyle(),16);

//Set JTextField font using new created font
textField.setFont(newTextFieldFont);

//Create a window using JFrame with title ( Set JTextField text size )
JFrame frame=new JFrame("Set JTextField text size");

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created text field into JFrame
frame.add(textField);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,100);

//Make JFrame visible
frame.setVisible(true);
}
}


***********************************************************************
JUST COMPILE AND EXECUTE IT
***********************************************************************

Set JButton text size

Source code below will show you, how to set JButton text size.

******************************************************************
COMPLETE SOURCE CODE FOR : SetJButtonTextSize.java
******************************************************************


import javax.swing.JButton;
import javax.swing.JFrame;

import java.awt.FlowLayout;
import java.awt.Font;

public class SetJButtonTextSize
{
public static void main(String[]args)
{
//Create button with text ( MY BUTTON )
JButton button=new JButton("MY BUTTON");

//Create font.
//Font Name : Default button font
//Font Style : Default button font style
//Font Size : 16
Font newButtonFont=new Font(button.getFont().getName(),button.getFont().getStyle(),16);

//Set JButton font using new created font
button.setFont(newButtonFont);

//Create a window using JFrame with title ( Set JButton text size )
JFrame frame=new JFrame("Set JButton text size");

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created button into JFrame
frame.add(button);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,100);

//Make JFrame visible
frame.setVisible(true);
}
}


******************************************************************
JUST COMPILE AND EXECUTE IT
******************************************************************

Get JFrame size

Source code below will create a JFrame with a button in it. You can know current JFrame size by click the button. You also can try resize the JFrame first, and after that click the button.

*****************************************************************************
COMPLETE SOURCE CODE FOR : GetJFrameSize.java
*****************************************************************************


import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

import java.awt.FlowLayout;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class GetJFrameSize extends JFrame
{
//Create ActionListener for listen when someone click button
ActionListener al=new ActionListener()
{
//Overwrite abstract method ( actionPerformed ) in ActionListener class
public void actionPerformed(ActionEvent event)
{
//Show message box that contain information about current JFrame width and height in pixels
JOptionPane.showMessageDialog(null,"JFrame size in pixels is : \n"+"WIDTH : "+getSize().width+"\n"+"HEIGHT : "+getSize().height);
}
};

public GetJFrameSize()
{
//Create JFrame title ( Resize me and click button )
super("Resize me and click button");

//Set JFrame layout to FlowLayout
setLayout(new FlowLayout());

//Create a button with text ( Click me to see current JFrame size )
JButton button=new JButton("Click me to see current JFrame size");

//Add ActionListener to the button
button.addActionListener(al);

//Add the button into created JFrame
add(button);

//Set default close operation for JFrame
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set initial JFrame size to :
//WIDTH = 500 pixels
//HEIGHT = 500 pixels
setSize(500,500);

//Make JFrame visible
setVisible(true);
}

public static void main(String[]args)
{
GetJFrameSize gjfs=new GetJFrameSize();
}
}


*****************************************************************************
JUST COMPILE AND EXECUTE IT
*****************************************************************************

Set JFrame size

Source code below will show you, how to set JFrame size

*********************************************************************
COMPLETE SOURCE CODE FOR : SetSizeForJFrame.java
*********************************************************************


import javax.swing.JOptionPane;
import javax.swing.JFrame;

public class SetSizeForJFrame
{
public static void main(String[]args)
{
//Receive user input for JFrame width
String jframeWidth=JOptionPane.showInputDialog(null,"Put JFrame width in pixels here");

//Receive user input for JFrame height
String jframeHeight=JOptionPane.showInputDialog(null,"Put JFrame height in pixels here");

//Create a JFrame
JFrame frame=new JFrame("Set JFrame size");

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size base on user input
frame.setSize(Integer.parseInt(jframeWidth),Integer.parseInt(jframeHeight));

//Make JFrame visible. So we can see it
frame.setVisible(true);
}
}


*********************************************************************
JUST COMPILE AND EXECUTE IT
*********************************************************************

Get screen size


********************************************************************
COMPLETE SOURCE CODE FOR : GetScreenSize.java
********************************************************************


import java.awt.Toolkit;
import java.awt.Dimension;

public class GetScreenSize
{
public static void main(String[]args)
{
Dimension dim=Toolkit.getDefaultToolkit().getScreenSize();
System.out.println("YOUR SCREEN WIDTH : "+dim.width+" PIXELS");
System.out.println("YOUR SCREEN HEIGHT : "+dim.height+" PIXELS");
}
}


********************************************************************
JUST COMPILE AND EXECUTE IT
********************************************************************

Set jframe size and it's location when click on maximize button


***********************************************************
COMPLETE SOURCE CODE FOR : SettingBound.java
***********************************************************


/**
*THIS TUTORIAL WILL SHOW YOU HOW TO SET THE MAXIMUM SIZE OF YOUR FRAME
*AND IT'S LOCATION WHEN YOU CLICK
*MAXIMIZE BUTTON BESIDE JFRAME CLOSE BUTTON
**/

import java.awt.Rectangle;
import javax.swing.JFrame;

public class SettingBound
{
public static void main(String[]args)
{
//first value, 400=x coordinate on your screen
//second value, 400=y coordinate on your screen
//third value, 800=JFrame width
//fourth value, 200=JFrame height
Rectangle rec=new Rectangle(400,400,800,200);

JFrame frame1=new JFrame("Setting Bound");

frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame1.setMaximizedBounds(rec);//set maximize setting for your JFrame
frame1.setVisible(true);
}
}


***********************************************************
JUST COMPILE AND EXECUTE IT
***********************************************************

RELAXING NATURE VIDEO