Swing/AWT/SWT :: How To Change Font For JOptionPane

Apr 21, 2014

I am quite familiar with using JOptionPane and its various displayXDialog() methods and reasonably familiar with changing fonts.

I have a JOptionPane.displayMessageDialog() that is working fine but I decided to make the font larger.

I found an example from which I coded:

Font font = UIManager.getFont("OptionPane.font");
UIManager.put("OptionPane.font", new Font(font.getName(), font.getStyle(), 24));
font = UIManager.getFont("OptionPane.font");
JOptionPane.showMessageDialog(this, "Welcome to Mover", "About Mover", -1); // no icon

After the UIManager.getFont() call after the UIManager.put() call, font shows the new font size of 24, but the showMessageDialog() dialog still has the default font.

And yes I understand that, when this works, it will affect every JOptionPane in my program.

I also tried:

Font font = UIManager.getFont("OptionPane.font");
JOptionPane message = new JOptionPane("Welcome to Mover", JOptionPane.INFORMATION_MESSAGE);
JDialog dlg = message.createDialog("About Mover");

[Code] ....

This gave me a dialog with the default font and an unwanted icon.

So I tried

// both
Font font = UIManager.getFont("Dialog.font");
// and
Font font = UIManager.getFont("JDialog.font");

and planned to use that font in my setFont() call but font was null.

View Replies


ADVERTISEMENT

How To Change Fonts And Font Size In Swing

Feb 10, 2014

So, I have a game. I would like to make a game where you press "start" and THEN it starts. Also, I want to have collision with triangles, not just squares. The way I handle collision right now is with if statements, if the object is within the other, game over.How would I do collision with triangles? Lastly, how do I set a high score? how to change fonts and font size in swing?

View Replies View Related

Change Font / Orientation For JTextArea Print

Jul 5, 2014

I wish to print the content of a JTextArea. I know I can do this with textarea.print(). However, I wish to print in a different font, font size and orientation from that of the JTextArea itself. I have been able to change the orientation by setting print attributes

PrintRequestAttributeSet printAttributes =
new javax.print.attribute.HashPrintRequestAttributeSet ();
printAttributes.add(javax.print.attribute.standard .OrientationRequested.LANDSCAPE);

And then using the textarea.print() method that allows me to set attributes. However, I haven't found any way to set the font and font size.

View Replies View Related

JRadio Buttons To Change Font Color In Code

Mar 9, 2014

I am having problem with the JRadio Buttons to change the font color in my code. What needs to be done? Also if I were to connect this GUI to another GUI and save font colors, how would I go about that?

package SystemandDesign.RISK;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JFrame;
import javax.swing.ButtonGroup;

[code]....

View Replies View Related

Swing/AWT/SWT :: Label Font Not Changing?

Feb 19, 2015

It's very simple, I've added an AWT component/control (specifically a Choice object to a Frame. It's a pop-up menu by any other name.

Above the pop-up, there's a label. I'm trying to change its font to no success.

* I create Label object called label1: Label label1 = new Label("This is a pop-up")
* I create a Font object called f: Font f = new Font("Times New Roman, Font.BOLD, 18)
* I apply the new font to the label: (in AFrame's constructor) label1,setFont(f)

When displayed the label's font seems to be stuck on Arialor something similar. Changing the point size however does have an effect.

import java.awt.Choice;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* Defines a 'pop-up' AWT control that will be added to AFrame.
* It extends Choice - I may need extra functionality later.
*/

public class APopUp extends Choice implements ItemListener {
// instance variables
int noi; // no of items
String selected; // item selected from choice

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Application Text Font Type Has Been Changed Automatically

Mar 9, 2015

I'm working on Java-GUI implementation in Ubuntu. Used font-type in the application throughout is "Arial". At earlier stage of application it was the same font-type("Arial"). As the implementation grew the font-type has been changed automatically to another font type. It seems Serif-font type.

Now I could not able to figure out the problem; why it is so.

Note- I used HTML code also for setting font style of Dialog box messages and buttons. This is the only point which I figured out. Can it is ?

View Replies View Related

Swing/AWT/SWT :: Looping Back To JOptionPane

Apr 28, 2014

how to have an application restart if the user inputs an incorrect integer in a JOptionPane question? I know how to do it with the Scanner class but nothing I do seems to work. This is the beginning of my code:

import javax.swing.JOptionPane;
public class Pay {
public static void main(String[] args) {
String level = JOptionPane.showInputDialog("Please select your skill level: 1, 2, or 3");
int levelPick = Integer.parseInt(level);

[code]...

View Replies View Related

Swing/AWT/SWT :: Why Does ItemStateChanged Only Change Just Once

Mar 5, 2015

I have a strange problems. Perhaps some of you already have had this problem before.

I have method which is suppose to check if the itemstate has changed. It ONLY works ONCE?

Thereafter, it does not matter how many times I changed the selection of the ComboBox.

Basically I have two Comboboxes.

1. If Combobox 1 is selected (e.g. Dogs, Cats)
2. Then get information from what ever the item from ComboBox 1 is selected, and display on ComboBox 2. (Dog Name, Cat Name etc)

E.g.

So If I selected Dogs on Combobox 1
Then display the Dog Names on Combobox 2.
If I then change and select Cats on Combobox 1,
then display Cat Names on ComboBox 2.

View Replies View Related

Swing/AWT/SWT :: For Loop Did Not Change Value

Dec 11, 2014

I like to list all pdf files of the mentioned directory, but I only get all time the first pdf file...Where is my error? I really don't get it...

new Thread() {
@Override
public void run() {
String directory;
directory = "C:UsersTommyDesktoppdf";
File inputFiles = new File(directory);
CopyOfSettingsGui.this.running = true;

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Change Size Of Entire GUI?

Feb 4, 2015

I built a GUI and after testing it on various platforms I think I would like to make it bigger by a factor of 2.2 or so.

Is there an easy way to just enter the factor 2.2 and have the GUI change by that factor?

I have over 50 components in the GUI. Ideally each one would just enlarge by the factor including the fonts.

This was my first (and only so far) java program. I didn't know anything about layout managers. I used netbeans and it generated all the code.

View Replies View Related

Swing/AWT/SWT :: How To Change JFrame Size

Jan 14, 2015

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

[Code].....

View Replies View Related

Swing/AWT/SWT :: Change The Blue Color?

Apr 6, 2014

When I click a JButton, it will become blue momentarily. Is it possible to change the blue color? If yes, how?

View Replies View Related

Swing/AWT/SWT :: How To Change Jbutton Color While It Is In Focus

Jan 27, 2013

refer to this code~

import java.awt.GridLayout;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.Color;
import javax.swing.JButton;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: How To Change CheckBoxTree From FileSystemView To File

Mar 5, 2015

I am trying to use a CheckBoxTree that has been already created here: [URL] .... The problem which this JTree is that is uses FileSystemView for the root directory and as far as I know it does not set any root directory.

So I want to have the ability to give it a root directory. for example: new File("C:Temp") So when the tree appears , it lists files and folders in the provided address, and not the entire system.

The code is available in the provided GitHub. I tried to replace all FileSystemView fileSystemView in constrictors and bodies with File file to make it working. It worked but ended up with errors such as not showing the file icons.

How to modify it correctly or if there is any better way to convert FileSystemView to File?

View Replies View Related

Swing/AWT/SWT :: How To Change Background Color Of Panel

May 3, 2014

Program is not working. I want to use buttonPanel object in ColorAction class and the process is unknown to me .

package button;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ButtonFrame extends JFrame
{
public JPanel buttonPanel;

[Code]...

View Replies View Related

Swing/AWT/SWT :: Cannot Get ActionListener To Change JLabel Text

Apr 24, 2014

I am trying to write an application where if you click and hold down on 1 button and move the mouse to another button and release the text on the 2 buttons should be switched around.I have a print line so I can se the text are supposed to get switched around but it is just not happening in the GUI.

I attached all my code in case the flaw was to find somewhere else in the code, but the functionality I am working on is the lines 76 to 121.

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

[code]....

View Replies View Related

Swing/AWT/SWT :: How To Change Action After 1st JButton Click

Aug 3, 2014

I am relatively new to java. . I cannot...(actually do not know) how to change the actionlistener (actionPerformed) after the second click in an array of JButtons. This is how the program performs right now.

On the 1st click on the grid, the border of the button clicked will change to 'blue' and another button will change its boarder to 'red'. on the next click the same action is performed.

What I need is to change action when the 'red' bordered button is clicked, lets say change the color of the buttons from the 'red' to the 'blue' buttons.(x 3 buttons).

The logic about how to perform the final result I think I can do on my own but my problem is how to change the action when the red bordered button is clicked.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;

[Code] .....

View Replies View Related

Adding Imports - Change To Swing Format

Apr 20, 2014

I made a game but i didn't add imports, i have been told i need to have imports and it needs to be in a normal swing format or it will not pass . How to change my code to swing format?

My code is

public class TextTwist extends javax.swing.JFrame
implements java.awt.event.ActionListener

// hard code, should be picked from a Problem class
private String[] letters = {"F","O","C","I","E","F"};
// hard code, should be picked from a Problem class
private String[] solutions = {"ICE","OFF","FOE","FOCI","OFFICE"};
 
[Code] ....

How do i get the program to move on to the next one String?

View Replies View Related

Swing/AWT/SWT :: Event To Detect Jframe Change

Aug 13, 2014

I would like to detect when the user change de JFrame. I make:

public class UI implements ActionListener, ComponentListener, DocumentListener, MouseListener{

private JFrame ventana;
private JTable table;
private JPanel panel;
private JScrollPane tableScrollPane;

[Code] ....

I put componentResized but when I change JFrame I cant see the string that I put in the method.

View Replies View Related

Swing/AWT/SWT :: Getting Icons To Change Size With Window Resize

Jan 19, 2014

I'm using a jpanel with an 8 by 8 grid layout of jlabels to which I'm adding images to represent a chess board. At first, I was using the ImageIcon class to initialize my icons, but as soon as I added these icons to the labels, the labels no longer changed size with the window (which I want to happen). URL...

So I copied in the class, and initialized a different set of icons using the stretch icon class (specifically, the method that allows you to initialize a stretch icon from a filename), however, when I use these stretch icons, the result is the same. Is something wrong with the class, or with my implimentation of it, and how would I fix this?

View Replies View Related

Swing/AWT/SWT :: Change Location Of Component Using Grid Bag Layout

Jun 13, 2014

How to change the location of a grid bag positioned component after it's already been added to the layout earlier?

Example is if I want component 1 to change from row 1 to row 2.

View Replies View Related

Swing/AWT/SWT :: How To Change JLable Text By Pressing JButton

Feb 25, 2015

i just started java and I'm trying to change the JLabel text by clicking on the JButton however it isn't working,

import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
public class BorderLayoutJFrame extends JFrame
{
public static final int WIDTH = 400;
public static final int HEIGHT = 400;

[Code]...

View Replies View Related

Swing/AWT/SWT :: Change Content Pane Color Of JFilechooser

Mar 25, 2015

I'm dealing with, change the content pane color of jFilechooser. Color has been changed but the problem is when I open the subdirectory leads errors; Note : It also trigger error when I set default directory; like chooser.setCurrentDirectory(file);

The following error is the result:

Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at javax.swing.plaf.metal.MetalFileChooserUI$IndentIcon.getIconWidth(MetalFileChooserUI.java:912)
at javax.swing.SwingUtilities.layoutCompoundLabelImpl(SwingUtilities.java:961)
at javax.swing.SwingUtilities.layoutCompoundLabel(SwingUtilities.java:888)
at javax.swing.plaf.basic.BasicLabelUI.layoutCL(BasicLabelUI.java:94)
at javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(BasicLabelUI.java:239)

[Code]...

Following is the code base

import javax.swing.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;

[Code]...

View Replies View Related

Swing/AWT/SWT :: Getting Icons To Change Size With Window Resize?

Jan 16, 2014

I'm using a jpanel with an 8 by 8 grid layout of jlabels to which I'm adding images to represent a chess board. At first, I was using the ImageIcon class to initialize my icons, but as soon as I added these icons to the labels, the labels no longer changed size with the window (which I want to happen). Someone suggested to me to use this custom stretch icon class, found here:

[URL] ....

So I copied in the class, and initialized a different set of icons using the stretch icon class (specifically, the method that allows you to initialize a stretch icon from a filename), however, when I use these stretch icons, the result is the same. Is something wrong with the class, or with my implementation of it, and how would I fix this?

View Replies View Related

Swing/AWT/SWT :: How To Change Button Text And Actions In Input Dialog Box

Oct 20, 2014

I'd like to change the text on the two buttons which I have in my Dialog Box, how should I do this?

Also, when I click the X Button in the top right of the Dialog Box, nothing happens, and the program only stops when I end it in jGrasp. How do I make this button close the program when clicked on?

import javax.swing.*;
import java.util.Random;
public class SwingInputExample {
public static void main(String args[]) {

[Code] .....

View Replies View Related

Swing/AWT/SWT :: How To Make JLabel Hyperlink Change Depending On JTextField

Jul 30, 2014

This is a part of my program. When the user enters "Exam Schedule" in the JtextField and clicks the add button I want the link to change to a link that opens a local pdf file. And if the user enters "Academic Calendar" the Jlabel will be set to another link. So far this works fine but the problem is that if you erase the textfield and enter another value the link of the previous value will still be there.

public void actionPerformed (ActionEvent e){
if (e.getSource ==add) {
if (text.getText().equalsIgnoreCase("Exam Schedule")){
link1.setText(text.getText());
link1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

[Code] .....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved