Changing Fonts on a running process

Hi All,
I have designed a UI which chiefly uses the "Dialog" font alias for all of its components (mostly because this is the default). One of our customers has asked us whether we can provide a way for him to change the font (I guess that they want to be able to increase/decrease the font size for certain displays, or change it to something else for themeability, etc).
So, I'm wondering -- is there a way to change the font and/or background colors of components in a global fashion?
I don't want to give my customer instructions on how to modify a font.properties file, I would rather have a UI which allowed the user his/her choice of any system font, and then applied the chosen font to the entire UI (and probably persisted this choice somehow)..
If anyone has written something similar, please let me know. I'd be curious to know how to achieve this. The only solution I can come up with is to mess with all of the values inside the UIDefaults classes, but this is really messy and awkward, and subject to change from JDK version to JDK version.
Any help is appreciated.

Look at UiManager.put(key, value);
For keys, look in BasicLookAndFeel and do a search for font.
For example: "Button.font"
So:
UiManager.put("Button.font", new Font(...));

Similar Messages

  • HT2486 change font size to run Avery labels

    Trying to run labels using Contacts, my MacAir (10.7), and Avery 5630 template.
    Formats correctly, but cuts off a couple of letters on both the right and the left.  Anybody got a fix for that?  Or know how to just reduce the size of the font?

    Mark,
    I am using Arial. I was able to set size 0 by script i.e.
    this.font.size = "0pt";
    But still it is not working since there is one more constraint. We are using ADS ver 1.5.
    I read somewhere in this forum that size 0 change works only with ADS ver 1.6 i.e if we set to size 0 then the font size changes depending upon the text length.
    Do you have any idea how can the same thing be achieved with ver 1.5?
    Thanks,
    Vimukta

  • How to chang the environment of running process in C?

    Hi All,
    I have a application written in C ( OS Solaris 10 ) actually this application runs under some pre defined and standardised environment (specific to my project ).
    Now I have requirement to access API of a library( already existing code ) in my application to perform some operations. I need to enhance my C code.
    This API ( or library ) is not compatible with the standardised environment set for my application.(standardised environment (specific to my project ))
    Can anybody please suggest me how can I set the environment (compatible to the library)while using that API (or library ) and reset to my project specific environment after the result is obtained from the new API (library ).
    To be more specific during execution of my C-Application ( Environment variable LD_PRELOAD=/usr/lib/secure/libmtmalloc.so ). I am enhancing my application to use PAM Modules ( Pluggable Authentication Modules ) PAM APIs exposed performs internally some operation and return some values to me.But inside the PAM my application is crashing during malloc operation.
    I have written a test application when it uses PAM APIs and perform the same operation under normal enviroment (uses libc for memory related function) it works fine.
    So please tell me how can I set this environment variable LD_PRELOAD to libc only during execution of this API and revert this environment variable LD_PRELOAD back to libmtmalloc after it performs this operation is done.
    Please dont tell me about the bug with libmtmalloc.so instead please provide me with some programming solution to achieve this.
    Thanks alot in advance.
    Regards,
    Rahul.

    rahulsingh wrote:
    *What do you mean "linked"? libC is dynamic (run-time) object. So your
    library will be linked with the necessary items at runtime. If mtmalloc
    is preloaded, then it may well use the mtmalloc routines.*
    By linked I mean if I that library(libraryA) during compilations process it is linked to libC ( -lC). No, that doesn't normally happen at compile time. It might check the library to see what functions are in it, but it doesn't actually take sections of libC and place them in the library.
    Instead, the run-time linker places both your library and libC (and the app, and other dynamic libraries) in memory when the app is run. LD_LIBRARY_PATH and LD_PRELOAD both affect the run-time linker in where and how it will look for libraries to load. You can see where it resolves by using 'ldd' on the app.
    This will show dynamic libraries that were required at compilation time. It is also possible for an application to explicitly grab a library via 'dlopen'. Any such files will not appear in 'ldd' output.
    Darren

  • URGENT: running processes fail because BPM change

    Hi,
    We've got some running processes on our CE 7.30 instance.
    I've done a change in the corresponding BPM (added one parameter to the WSDL of a sub-process).
    Now we're facing the following problem:
    When the running process instances are further processed, they run into error status 'failed' with the following error message:
    com.sap.glx.core.kernel.api.CancelTransitionException: java.lang.IllegalStateException: Container '$Approver' unavailable
    com.sap.glx.mapping.execution.api.exception.TExecutionException
    at Approver( StandardChild )
    at ( DeepExpression )
    at xxx.com/approvalproduct/pr/pm/Inform_requester/Inform_requester:Approver( TerminalPart:expression )
    at ( BroadMapping )
    com.sap.glx.core.internaladapter.ExceptionAdapter.raiseException(ExceptionAdapter.java:647)
    com.sap.glx.core.internaladapter.ExceptionAdapter.raiseException(ExceptionAdapter.java:617)
    com.sap.glx.core.internaladapter.Transformer$ExceptionProvider.createTransitionException(Transformer.java:616)
    com.sap.glx.core.internaladapter.Transformer$TransformerTemplateAccessor$MapperTemplate$ImplementedInvocationHandler.invoke(Transformer.java:3075)
    com.sap.glx.core.internaladapter.Transformer$TransformerInvocationHandler.invoke(Transformer.java:3356)
    com.sap.glx.core.dock.impl.DockObjectImpl.invokeMethod(DockObjectImpl.java:543)
    com.sap.glx.core.kernel.trigger.config.Script$MethodInvocation.execute(Script.java:248)
    com.sap.glx.core.kernel.trigger.config.Script.execute(Script.java:798)
    com.sap.glx.core.kernel.execution.transition.ScriptTransition.execute(ScriptTransition.java:67)
    com.sap.glx.core.kernel.execution.transition.Transition.commence(Transition.java:138)
    com.sap.glx.core.kernel.mmtx.DirectNestedTransaction.inPrepare(DirectNestedTransaction.java:67)
    ... (15 more)
    This seems to be caused due a missing container in the sub-process.
    It's not possible to resume those processes.
    My question: Is there a way to rescue those process instances?
    I wasn't aware that - if we deploy a new BPM - all the existing process instances can fail...
    Thanks in advance,
    Eddie.

    Thanks for your answer...
    One way to solve this issue is to put 0..1 as Multiplicity in the WSDL of the sub-process.
    Afterwards the sub-process can be resumed.

  • Is it possible to change theme and font size at run time?

    I want to create a project where user can change the theme and font size at run time? Is there any facility to do so in captivate 7?

    Not as far as I am aware.  A lot of the text objects (such as captions) in Captivate are actually converted to images at publish time.  So they're not able to be changed via stylesheets or variables.
    You can use Advanced Actions to hide or show images or captions with different sized text.  But not change the size of the text that is already in the caption.
    Even if you make all of the on screen text dynamic so that it's coming from some variable value, you still cannot change the font size at runtime.

  • Attribute change run process doesn't run in the chain

    Hello everyone,
    I have implemented a process chain with multiple parallel processes (12, like the batch processes in the application server) and I have put for each stream a loading of master data followed by the attribute change run process. When I run my chain then I find that one o two Attribute change run process doesn't run (the InfoObject chosen seem to be random!). The chain remain in yellow color. Can you help me anyone about this question?
    Regards,
    Francesco

    Couple of thing you should keep in mind while loading master data.
    if two loads are targeted to the same infoobject they will collide and as a result the later load will fail.
    it is a good practice to use only one Attribute change run in the end before you load master data. but if there are dependecies you can use several in series
    Also when you set up Attribute change run make sure that Attribute change run will pickup only the particualr infoobject not all the objects in the Attribute change run list.

  • Attribute Change Run Process chain

    Hi,
    We have a attribute change run step in Process chain with "selective infoobjects".
    But when it executes it runs attribute change run for all infoobjects apart from what i have mentioned in the variant.
    Proof:
    I had a snapshot of infoobject list in RSA1->Tools->Attribute change Run before executing process chain in which i saw info objects other than what i had in the variant.
    I ran the process chain.
    Again I saw the infoobject list RSA1->Tools->Attribute change Run and it was empty!!
    Even though I mention some infoobject in process "Attribute change Run" It runs for all info objects irrespective of what I maintain in the variant.
    This causes problem and creacting lock. If anyone ever observed this problem and resolved please let me know!!
    Thanks
    VJ

    well here is the POC ,I have nw204s SP-12 .
    Steps followed -
    Monitor of change run - 3 infoobjects currently waiting for CR.
    Built PC with Process type "Attribute  Change"  only ..no other process types barring "Start" which is imperative.
    Included only 2 Infoobjects from the 3 aforementioned.
    Scheduled as immediate and it executed CR for the 2 only,so my CR monitor shows now 1 pending for CR to be run,which is as expected.
    So as per Proof of Concept sp-12 works with process type "Attribute  Change"
    You may wish to check your process chain again and in worst case raise an OSS to SAP.
    Hope it Helps
    Chetan
    @CP..

  • Attribute Change Run" process cannot precede process "Execute InfoPackage

    hi all,
    i have changed process chain, after changing the chain i have click the check button and activated. then iam getting this error
    A type "Attribute Change Run" process cannot precede process "Execute InfoPackage" var. ZPAK_C0BVLUDKPEPXGXFMHQ67RFI9L in the chain.
    please help me out
    thanks advance
    sudheer.

    Hi,
    Your process chain shud have the following sequence:
    Start Process> Loading of master data> AND process (if u have multiple master loads)-->Attribute Change Run
    And all the linkages between the processes shud only be "SUCCESSFUL". Create new variants for all processes you enter in your process chain.
    Check you chain before you activate. If it gives you exlamatory sign, the also u can go ahead with activation as it is giving u just the warnings.....
    Hope it'll help u.......
    Preet

  • Attribute change run process type failed with short dump

    Hi all,
    In the process chain Attribute change run process type failed with short dump. I checked the locks in SM12 but there are no locks associated. I checked in the attribute change run screen through RSA1 -> infoobject list but there are no infoobjects there. I think the ACR was completed successfully, still the process type in the PC was in red colour. What to do and let me know what happened here.
    Thanks,
    Jack

    1. This kind of scenario is extremely rare but it happens sometimes. It might be the case that 2 attribute change runs are running at the same time.
    2. Same IO is being used in Differnet PC and getting activated.
    I think if this frequently occurs you need to check at the time of locking all running jobs and see whether anywhere else or simultaneously 2 ACR are running.
    Please do close the thread if that answers your questions. Please help us keep the forums clean and open useful information only.
    For more information search on help.sap.com and you will get lots of material.
    Regards.
    Den

  • "Attribute Change Run" process has to follow process "Execute InfoPack

    Hi All,
             i created process chain for M.D SD area. here i created start varient, then execute info package process created and when i am checking that it showing some warning message like ....
    A type "Attribute Change Run" process has to follow process "Execute InfoPackage" var.ZPAK_4B9B5FH2BTQJOBTBAWHVM5ZY2 in the chain.
    Here i can't understand what i have to do....
    Any inputs for this...........
    Thanx in Advance
    Subbu.

    hi,
    Check master data objects in both process types "Excute info package" after start varianet and in attribut echange run process type.
    Both should match or system will throw error message.
    The concept is like Attribute change run has to run when ever new data is loaded to master data attributes.
    Regards,
    Arun Thangaraj

  • Run time change font style

    Hi All,
    I want to put some validation on particular field and on the basis of it i want to change font style or colour.
    Can anyone tell me hoe it is possible?
    Thanks,
    joy

    I am giving you a sample code you can modify it according to your requirement.
    I have created a CSS in ProcessRequest Method of Controller.
    import oracle.cabo.style.CSSStyle;
    CSSStyle oraaniltext = new CSSStyle();
    oraaniltext.setProperty("color", "#F6358A");
    oraaniltext.setProperty("background-color", "#000000");
    OAMessageTextInputBean comCode = (OAMessageTextInputBean)webBean.findChildRecursive("InvoiceIdTI");
    comCode.setInlineStyle(oraaniltext);
    Here i have set the CSS of a item of Type MessageTextInput and set its Foreground Color and Background color.
    I hope this will give you some clue.
    Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How do I change fonts in a Text field ??

    Okay I've tried to implement a JComboBox that allows the user to change fonts in the text field. So far I've tried different methods to do it but to no avail. Could somebodoy here read the programs source code for me and tell me where I went wrong?
    /* * My GUI Client */
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;
    import javax.swing.event.*;
    //for HTML Headers
    import javax.swing.text.StyledEditorKit.*;
    import javax.swing.text.html.HTMLEditorKit.*;
    import javax.swing.text.html.*;
    import javax.swing.event.HyperlinkListener;
    import javax.swing.event.HyperlinkEvent;
    import javax.swing.event.HyperlinkEvent.EventType;
    import javax.swing.text.html.HTMLFrameHyperlinkEvent;
    //for layout managers
    import java.awt.event.*;
    //for action and window events
    import java.io.*;
    import java.net.*;
    import java.awt.GraphicsEnvironment;
    //for font settings
    import java.lang.Integer;
    import java.util.Vector;
    import java.awt.font.*;
    import java.awt.geom.*;
    public class guiClient extends JFrame implements ActionListener {
    protected static final String textFieldString = "JTextField";
    protected static final String loadgraphicString = "LoadGraphic";
    protected static final String connectString = "Connect";
    static JEditorPane editorPane;
    static JPanel layoutPanel = new JPanel(new BorderLayout());
    static JPanel controlPanel = new JPanel(new BorderLayout());
    static JPanel buttonPanel = new JPanel(new BorderLayout());
    static JPanel fontPanel = new JPanel(new BorderLayout());
    static PrintStream out;
    static DrawPanel dPanel;
    static DrawPanel dPButton;
    static DrawPanel dFonts;
    static DrawControls dControls;
    static DrawButtons dButtons;
    static String userString;
    static String currentFont;
    String fontchoice;
    String fontlist;
    static JTextField userName = new JTextField();
    public static JMenuBar menuBar;
    private static JButton connectbutton = new JButton("Connect");
    static boolean CONNECTFLAG = false;
    //create the gui interface
    public guiClient() {
         super("My Client");
    // Create a ComboBox
    GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String envfonts[] = gEnv.getAvailableFontFamilyNames();
    Vector vector = new Vector();
    for ( int i = 1; i < envfonts.length; i++ ) {
    vector.addElement(envfonts);
    JComboBox fontlist = new JComboBox (envfonts);
         fontlist.setSelectedIndex(0);
         fontlist.setEditable(true);
         fontlist.addActionListener(this);
         fontchoice = envfonts[0];     
    //Create a regular text field.
         JTextField textField = new JTextField(10);
         textField.setActionCommand(textFieldString);
         textField.addActionListener(this);          
    //Create an editor pane.
    editorPane = new JEditorPane();
         editorPane.setContentType("text");
         editorPane.setEditable(false);
    //set up HTML editor kit
         HTMLDocument m_doc = new HTMLDocument();
         editorPane.setDocument(m_doc);
         HTMLEditorKit hkit = new HTMLEditorKit();
         editorPane.setEditorKit( hkit );
         editorPane.addHyperlinkListener( new HyperListener());
    //Create whiteboard
    dPanel = new DrawPanel();
    dPButton = new DrawPanel();
    dFonts = new DrawPanel();
    dControls = new DrawControls(dPanel);
    dButtons = new DrawButtons(dPButton);
         //JLable fontLab = new JLabel(fontLable);
    //fontLab.setText("Fonts");
    //Font newFont = getFont().deriveFont(1);
    //fontLab.setFont(newFont);
    //fontLab.setHorizontalAlignment(JLabel.CENTER);
    JPanel whiteboard = new JPanel();
    whiteboard.setLayout(new BorderLayout());
    whiteboard.setPreferredSize(new Dimension(300,300));
    whiteboard.add("Center",dPanel);
    whiteboard.add("South",dControls);
    whiteboard.add("North",dButtons);
         JScrollPane editorScrollPane = new JScrollPane(editorPane);
         editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
         editorScrollPane.setPreferredSize(new Dimension(250, 145));
         editorScrollPane.setMinimumSize(new Dimension(50, 50));
    //put everything in a panel
         JPanel contentPane = new JPanel();
         JPanel fontPane = new JPanel();
         contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    //add whiteboard
         contentPane.add(whiteboard);
    //add editor box
         contentPane.add(editorScrollPane);
    //add spacer
         contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    //add textfield
         contentPane.add(textField);
    //set up layout pane
         //layoutPanel.add(GridLayout(2,1),fontLab);
         layoutPanel.add( BorderLayout.NORTH, fontlist);     
         layoutPanel.add(BorderLayout.WEST,new Label("Name: ")); //add a label
         layoutPanel.add(BorderLayout.CENTER, userName ); //add textfield for user names
         layoutPanel.add(BorderLayout.SOUTH, connectbutton);//add dropdown box for fonts
         //fontPane.add(BorderLayout.NORTH,fontlist);
         contentPane.add(layoutPanel);
         contentPane.add(controlPanel);
         contentPane.add(buttonPanel);
    //Create the menu bar.
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    //Build the first menu.
         JMenu menu = new JMenu("File");
         menu.setMnemonic(KeyEvent.VK_F);
         menuBar.add(menu);
    //a group of JMenuItems
         JMenuItem menuItem = new JMenuItem("Load Graphic", KeyEvent.VK_L);
         menu.add(menuItem);
    menuItem.setActionCommand(loadgraphicString);
         menuItem.addActionListener(this);
    connectbutton.setActionCommand(connectString);
    connectbutton.addActionListener(this);
         setContentPane(contentPane);
    static private void insertTheHTML(JEditorPane editor, String html, int location) throws IOException {
         HTMLEditorKit kit = (HTMLEditorKit) editor.getEditorKit();
         Document doc = editor.getDocument();
         StringReader reader = new StringReader(html);
         try {
              kit.read(reader, doc, location);
         } catch (BadLocationException e) {}
    //listen for actions being performed and process them
    public void actionPerformed(ActionEvent e) {
    //if the action is from the textfield (e.g. user hits enter)
         if (e.getActionCommand().equals(textFieldString)) {
              JTextField fromUser = (JTextField)e.getSource();
         if (fromUser != null){
    //place user text in editor pane
    //send message to server
                   if (userName.getText() != null) {
                        userString = userName.getText().trim();
                   out.println(userString + ": " + fromUser.getText());
              fromUser.setText("");
         } else if(e.getActionCommand().equals(connectString)) {
              CONNECTFLAG = true;
    } else if (e.getActionCommand().equals(loadgraphicString) ) {
              final JFileChooser fc = new JFileChooser();
              int returnVal = fc.showOpenDialog(this);
              if (returnVal == JFileChooser.APPROVE_OPTION) {
                   File file = fc.getSelectedFile();
                   dPanel.loadImage(file.getAbsolutePath());
                   sendImage(file);
         else if (e.getActionCommand().equals(fontlist)){
         JComboBox cb = (JComboBox)e.getSource();
    String newSelection = (String)cb.getSelectedItem();
    currentFont = newSelection;
         userString = currentFont;
    return;
    /*public void itemStateChanged (ItemEvent e) {
    if ( e.getStateChange() != ItemEvent.SELECTED ) {
    return;
    if ( list == fontlist ) {
    fontchoice = (String)fontlist.getSelectedItem();
         userString.changeFont(fontchoice);
    //append text to the editor pane and put it at the bottom
    public static void appendText(String text) {
         if (text.startsWith("ID ") ) {
              userString = text.substring(3);
         } else if (text.startsWith("DRAW ") ) {
              if (text.regionMatches(5,"LINE",0,4)) {
    dPanel.processLine(text);
         }else if (text.regionMatches(5,"POINTS",0,5)) {
         dPanel.processPoint(text);
         } else if (text.startsWith("IMAGE ") ) {
    int len = (new Integer( text.substring(6, text.indexOf(",")))).intValue();
    //get x and y coordinates
         byte[] data = new byte[ (int)len ];
         int read = 0;
    try {
         while (read < len) {
         data = text.getBytes( text.substring(0, len) );
    } catch (Exception e) {}
         Image theImage = null;
         theImage = dPanel.getToolkit().createImage(data);
         dPanel.getToolkit().prepareImage(theImage, -1, -1, dPanel);
         while ((dPanel.getToolkit().checkImage(theImage, -1, -1, dPanel) & dPanel.ALLBITS) == 0) {}
              dPanel.drawPicture(0, 0, theImage);
    } else {
    //set current position in editorPane to the end
              editorPane.setCaretPosition(editorPane.getDocument().getLength());
    //put text into the editorPane
              try {
                   insertTheHTML(editorPane, text, editorPane.getDocument().getLength());
              } catch (IOException e) {}
    } //end of appendText(String)
    public void sendImage(File file) {
    //find length of file
         long len = file.length();
    //read file into byte array
         byte[] byteArray = new byte[(int)len];
         try {
              FileInputStream fstream = new FileInputStream(file);
              if (fstream.read(byteArray) < len) {
    //error could not load file
              } else {
              out.println("IMAGE " + len + ",");
                   out.write(byteArray, 0, (int)len); //write file to stream
         } catch(Exception e){}
    //run the client
    public static void main(String[] args) {
         String ipAddr=null, portNr=null;
              if (args.length != 2) {
                   System.out.println("USAGE: java guiClient IP_Address port_number");
                   System.exit(0);
              } else {
         ipAddr = args[0];
              portNr = args[1];
              JFrame frame = new guiClient();
              frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) { System.exit(0); }
              frame.pack();
              frame.setVisible(true);
              while(CONNECTFLAG == false){}
    //sames as previous client,
    //set up connection and then listen for messages from the Server
              String socketIP = ipAddr;
              int port = Integer.parseInt(portNr);
    //the IP address of the machine where the server is running
              Socket theSocket = null;
    //communication line to the server
              out = null;
    //for message sending
              BufferedReader in = null;
    //for message receiving
              try {
              theSocket = new Socket(socketIP, port );
    //try to connect
              out = new PrintStream(theSocket.getOutputStream());
                   dPanel.out = out;
    //for client to send messages
              in = new BufferedReader(new InputStreamReader(theSocket.getInputStream()));
                   BufferedReader userIn = new BufferedReader(new InputStreamReader(System.in));
                   String fromServer;
                   while ((fromServer = in.readLine()) != null) {
                   appendText(fromServer);
                   if (fromServer.equals("BYE")) {
                        appendText("Connection Closed");
                        break;
              out.close();
    //close all streams
              in.close();
              theSocket.close();
    //close the socket
         } catch (UnknownHostException e) {
    //if the socket cannot be openned
              System.err.println("Cannot find " + socketIP);
              System.exit(1);
              } catch (IOException e) { //if the socket cannot be read or written
              System.err.println("Could not make I/O connection with " + socketIP);
              System.exit(1);
    class HyperListener implements HyperlinkListener {
    public JEditorPane sourcePane;
    public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    sourcePane = (JEditorPane) e.getSource();
                   if (e instanceof HTMLFrameHyperlinkEvent) {
    HTMLFrameHyperlinkEvent event = (HTMLFrameHyperlinkEvent) e;
                        System.out.println(event.getTarget());
                        HTMLDocument doc = (HTMLDocument) sourcePane.getDocument();
                        doc.processHTMLFrameHyperlinkEvent(event);
    else {
    try {}
    catch (Exception ev){
         ev.printStackTrace();
    Well sorry the source code takes up the whole forum but I need a good feedback from this.

    All right...
    public class guiClient extends JFrame implements ActionListener {
    static String userString;
    static String currentFont;
    String fontchoice;
    String fontlist;
    static JTextField userName = new JTextField();
    public guiClient() {
         super("My Client");
    public guiClient() {
         super("My Client");
    // Create a ComboBox
    GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String envfonts[] = gEnv.getAvailableFontFamilyNames();
    Vector vector = new Vector();
    for ( int i = 1; i < envfonts.length; i++ ) {
    vector.addElement(envfonts);
    JComboBox fontlist = new JComboBox (envfonts);
         fontlist.setSelectedIndex(0);
         fontlist.setEditable(true);
         fontlist.addActionListener(this);
         fontchoice = envfonts[0];     
    //Create a regular text field.
         JTextField textField = new JTextField(10);
         textField.setActionCommand(textFieldString);
         textField.addActionListener(this);
    public void actionPerformed(ActionEvent e) {
    //if the action is from the textfield (e.g. user hits enter)
         if (e.getActionCommand().equals(textFieldString)) {
              JTextField fromUser = (JTextField)e.getSource();
         if (fromUser != null){
    //place user text in editor pane
    //send message to server
                   if (userName.getText() != null) {
                        userString = userName.getText().trim();
                   out.println(userString + ": " + fromUser.getText());
              fromUser.setText("");
         else if (e.getActionCommand().equals(fontlist)){
         JComboBox cb = (JComboBox)e.getSource();
    String newSelection = (String)cb.getSelectedItem();
    currentFont = newSelection;
         userString = currentFont;
    return;

  • How to change font/ font color etc in a graphic object using JCombobox?

    Hello
    My program im writing recently is a small tiny application which can change fonts, font sizes, font colors and background color of the graphics object containing some strings. Im planning to use Jcomboboxes for all those 4 ideas in implementing those functions. Somehow it doesnt work! Any help would be grateful.
    So currently what ive done so far is that: Im using two classes to implement the whole program. One class is the main class which contains the GUI with its components (Jcomboboxes etc..) and the other class is a class extending JPanel which does all the drawing. Therefore it contains a graphics object in that class which draws the string. However what i want it to do is using jcombobox which should contain alit of all fonts available/ font sizes/ colors etc. When i scroll through the lists and click the one item i want - the graphics object properties (font sizes/ color etc) should change as a result.
    What ive gt so far is implemented the jcomboboxes in place. Problem is i cant get the font to change once selecting an item form it.
    Another problem is that to set the color of font - i need to use it with a graphics object in the paintcomponent method. In this case i dnt want to create several diff paint.. method with different property settings (font/ size/ color)
    Below is my code; perhaps you'll understand more looking at code.
    public class main...
    Color[] Colors = {Color.BLUE, Color.RED, Color.GREEN};
            ColorList = new JComboBox(Colors);
    ColorList.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ev) {
                     JComboBox cb = (JComboBox)ev.getSource();
                    Color colorType = (Color)cb.getSelectedItem();
                    drawingBoard.setBackground(colorType);
              });;1) providing the GUI is correctly implemented with components
    2) Combobox stores the colors in an array
    3) ActionListener should do following job: (but cant get it right - that is where my problem is)
    - once selected the item (color/ font size etc... as i would have similar methods for each) i want, it should pass the item into the drawingboard class (JPanel) and then this class should do the job.
    public class DrawingBoard extends JPanel {
           private String message;
           public DrawingBoard() {
                  setBackground(Color.white);
                  Font font = new Font("Serif", Font.PLAIN, fontSize);
                  setFont(font);
                  message = "";
           public void setMessage(String m) {
                message = m;
                repaint();
           public void paintComponent(Graphics g) {
                  super.paintComponent(g);
                  //setBackground(Color.RED);
                  Graphics2D g2 = (Graphics2D) g;
                  g2.setRenderingHint             
                  g2.drawString(message, 50, 50);
           public void settingFont(String font) {
                //not sure how to implement this?                          //Jcombobox should pass an item to this
                                   //it should match against all known fonts in system then set that font to the graphics
          private void settingFontSize(Graphics g, int f) {
                         //same probelm with above..              
          public void setBackgroundColor(Color c) {
               setBackground(c);
               repaint(); // still not sure if this done corretly.
          public void setFontColor(Color c) {
                    //not sure how to do this part aswell.
                   //i know a method " g.setColor(c)" exist but i need to use a graphics object - and to do that i need to pass it in (then it will cause some confusion in the main class (previous code)
           My problems have been highlighted in the comments of code above.
    Any help will be much appreciated thanks!!!

    It is the completely correct code
    I hope that's what you need
    Just put DrawingBoard into JFrame and run
    Good luck!
    public class DrawingBoard extends JPanel implements ActionListener{
         private String message = "message";
         private Font font = new Font("Serif", Font.PLAIN, 10);
         private Color color = Color.RED;
         private Color bg = Color.WHITE;
         private int size = 10;
         public DrawingBoard(){
              JComboBox cbFont = new JComboBox(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
              cbFont.setActionCommand("font");
              JComboBox cbSize = new JComboBox(new Integer[]{new Integer(14), new Integer(13)});
              cbSize.setActionCommand("size");
              JComboBox cbColor = new JComboBox(new Color[]{Color.BLUE, Color.RED, Color.GREEN});
              cbColor.setActionCommand("color");
              JComboBox cbBG = new JComboBox(new Color[]{Color.BLUE, Color.RED, Color.GREEN});
              cbBG.setActionCommand("bg");
              add(cbFont);
              cbFont.addActionListener(this);
              add(cbSize);
              cbSize.addActionListener(this);
              add(cbColor);
              cbColor.addActionListener(this);
              add(cbBG);
              cbBG.addActionListener(this);
         public void setMessage(String m){
              message = m;
              repaint();
         protected void paintComponent(Graphics g){
              super.paintComponent(g);
              Graphics2D g2 = (Graphics2D)g;
              g2.setColor(bg);//set background color
              g2.fillRect(0,0, getWidth(), getHeight());          
              g2.setColor(color);//set text color
              FontRenderContext frc = g2.getFontRenderContext();
              TextLayout tl = new TextLayout(message,font,frc);//set font and message
              AffineTransform at = new AffineTransform();
              at.setToTranslation(getWidth()/2-tl.getBounds().getWidth()/2,
                        getWidth()/2 + tl.getBounds().getHeight()/2);//set text at center of panel
              g2.fill(tl.getOutline(at));
         public void actionPerformed(ActionEvent e){
              JComboBox cb = (JComboBox)e.getSource();
              if (e.getActionCommand().equals("font")){
                   font = new Font(cb.getSelectedItem().toString(), Font.PLAIN, size);
              }else if (e.getActionCommand().equals("size")){
                   size = ((Integer)cb.getSelectedItem()).intValue();
              }else if (e.getActionCommand().equals("color")){
                   color = (Color)cb.getSelectedItem();
              }else if (e.getActionCommand().equals("bg")){
                   bg = (Color)cb.getSelectedItem();
              repaint();
    }

  • Schedule line date changes after each MRP run

    Dear Experts,
    Clarification needed on how the system plans the MM schedule lines.
    Setting: Start in the past not allowed.
                  3 days for processing of order
    The issue is after each MRP run the system is moving the schedule line to the current date + 3 days for processing + the planned delivery time.
    If the schedule line is not firmed, after each MRP run ( which happens everyday) the system is moving the schedule line and then giving an alert saying the " order has to be rescheduled to the previous day"
    on the second day after the mrp run the system moves the schedule line again by one more day and gives the rescheduling date as " -2 days from today"
    this change is happening every day after the planning run. - because of this there are really no backorders ( schedule line in the past ) in the system. we were not able to know if the vendor is actually delayed in this case.
    can you kindly suggest what went wrong here ??
    we are using strategy 10 for the planning of procured parts. Let me know if more info is needed.
    Note: we are also using stock transfer process for some procured parts. there too the PR date gets changed after each MRP run. There there is no lead time in this case. the order is placed on the same day as the requirement as both plants are nearby. There the PR date is changing everyday to the current date.
    your advice would be of great help
    thanks
    Nagendra Kumar

    Hi Caetano,
    thanks for your suggestion
    Yes, we use firm zone for few of the vendors. there the system don't change the schedule lines.
    Also for the stock transfer PR's there is no firm zone and the lead time is one day. in this case it changes everyday after the MRP run.
    the stock transfer PR's leads to the creation of Schedule lines from the source plant. Since this PR gets changed everyday. the alerts coming out of MD07 gets changed and we really did not know if this order is delayed or not.  In the source plant we use the firm zone to avoid moving the schedule line. But then the alerts are always not correct.
    is there any setting which helps in not moving the PR everyday without using " start in the past"
    thanks
    Nagendra Kumar

  • How to change Font on Apple Cloud calendar

    I'm using a Lenovo Laptop T61.I am running Windows 7 Ultimate.
    I have just installed Apple iCloud on it to sync my contact & calender with my iPhone 5 and my iPad Air. I'm working on other problems with them (like duplicating my calender appts 4-5 times for all years. However, this problem is what I need answers on now.
    How do I change Font on Apple Cloud calendar. It went from a larger font to a smaller one somehow. I can not find how to make it larger on Apple Support FAQ.
    The font is almost unreadable.
    Thanks,
    The Pool Commish

    Do you mean how do you change the display size?
    System preferences - displays - and select the appropriate display size

Maybe you are looking for

  • HP Officejet Pro L7590 Stopped scanning to removeable devices..ie. USB Flash Drive

    Printer Just stopped scanning to a removeable Flash Drives on the printer itself. The unit is shared by multiple people in the office. The document will scan, but is says " SCAN Failure.. Memory Device Failure". The issue is that we have tried other

  • EDID checksum is invalid

    I have this message at each boot:  [drm:drm_edid_block_valid] *ERROR* EDID checksum is invalid, remainder is 128 [ 1.765502] Raw EDID: [ 1.765530] ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff [ 1.765559] ff ff ff ff ff ff ff ff ff ff ff ff ff ff f

  • Web Service Consumption + SM59 ( HTTPS)

    Hello ABAP Gurus, I have issue to consume web service. I am trying to consume web service form external plm server. it has https protocol. For this i tried to create rfc type G for external server but I am wondering that what i need to know to create

  • Activity Cost

    Hi All,          I have create a production order.In this order i have maintain activity type in routing. But The problem is when I go to cost itemization in the order activity cost show in 1/2 price. WHY?          In KP26 i have maintain fixed price

  • Certfied product & CAP

    JCOP specification says: For the certified product it is required that all CAP files are generated with the NXP JCOP Tools. Why that is necessary? Does it mean that it is not necessary toi make the build script which will do all the relevant tasks fr