Ugly swing fonts under ratpoison - java

I am writing a small application in swing. I am using Ratpoison as my window manager (with wmname LG3D) and Netbeans as IDE. My application fonts when started from KDE or directly from Netbeans look ok. Started from ratpoison they looks like this:
Screenshot http://img195.imageshack.us/img195/8079/swingfontsratpoison.png
Click for full size

KDE is probably adding more fonts to the system when starting up.
Execute this on the KDE and in the ratpoison:
fc-list -v | grep "file:\|fullname:\|^$"
and compare the font list to see what is missing.
If some directory is missing, add it to the /etc/fonts/fonts.conf, in to a new entry.
If just missing some fonts, you can copy then to the ~/.fonts (assuming that you have this dir configures in fonts.conf)
if all fonts are the same, try to move all configs in /etc/fonts/conf.d to a temporary directory and run
fc-cache -f
and test.
if looks better, start adding back one more config, run the fc-cache -f again , restart again the java app and test.
repeat until you found the config that breaks the java fonts. In the end you should have all configs minus the one that breaks the java.
Usually its some config that sets a font as preferred, that java will blindly use, over better fonts.

Actually, you can use any system font in Swing.
Easily, just by adding one sentence: yourComponent.setFont(new Font("Tahoma", Font.BOLD|Font.ITALIC, 16));
Or you can change the overall settings: UIManager.put("label.font", new Font("Tahoma", Font.BOLD, 16));
The "keys" of the put method are usually strings indicating what you want to change like:
label.font, button.font, label.color, textfield.font, etc. All in small cases.
And don't forget to import java.awt.Font AND/OR javax.swing.UIManager at the beginning!

Related

Can I set up a keybind/hot key/macro to paste a line into Eclipse?

I know Eclipse has default keybindings (copy, paste, etc), and you can set keybinds for commands they've already decided on (Generate Setter/Getter, etc) but is it possible to set up a custom command?
For example, I can press Shift+F5 and it'll automatically type or paste "System.out.println();" for me.
In Eclipse Preferences, go to Java->Editor->Templates
Click on "new" to create a new template.
In your template, write in the "pattern" textarea the command you want to be pasted.
For example :
throw new IllegalArgumentException("");
And in the "name" textbox, write the word that matches to that command.
Then, in Eclipse, in your Java Editor, write that word + auto-completion. Eclipse will propose you,among others may be, your template.
The sysout command name is that template :
System.out.println(${word_selection}${});${cursor}

R Shiny DesktopDeployR Stop Logging Error

I am trying to deploy R Shiny App as an Windows Desktop App. So far I have used the framework described at http://blog.analytixware.com/2014/03/packaging-your-shiny-app-as-windows.html and managed to make it work with the help of stackoverflow users (question name "R Shiny as Windows Desktop App Creates Text File With Warning").
An update to this framework has been developed and it has several advantages over the previous one, such as not relying on Google Chrome browser etc. and it is described here: http://oddhypothesis.blogspot.com/2016/04/desktop-deployr.html
All files can be found in the GitHub account of framework creator (link is presented in the description)
I have adjusted the following:
app.R
require(shinyjs,quietly = TRUE,warn.conflicts=FALSE)
require(markdown,quietly = TRUE,warn.conflicts=FALSE)
require(scales,quietly = TRUE,warn.conflicts=FALSE)
require(DT,quietly = TRUE,warn.conflicts=FALSE)
runApp("./app/shiny/", launch.browser=TRUE,quiet=TRUE)
packages.txt
Added the names of the packages I am using
# Primary package dependencies for the application that are loaded during
# startup.
#
# If not available, they will be installed into app/library. Custom source
# packages need to be installed manually.
# bare miniminum: configurations are stored in json format
jsonlite
# if deploying shiny based applications:
shiny
shinyjs
markdown
scales
DT
App does launch, it works. However a new folder is created called log with file error.log, which includes the following:
library paths:
... C:/Users/VoronecI/Desktop/New folder (2)/app/library
... C:/Users/VoronecI/Desktop/New folder (2)/dist/R-Portable/App/R-Portable/library
working path:
... C:/Users/VoronecI/Desktop/New folder (2)
Loading required package: methods
ensuring packages: jsonlite, shiny, shinyjs, markdown, scales, DT
Attaching package: 'shiny'
The following object is masked from 'package:jsonlite':
validate
Attaching package: 'shinyjs'
The following object is masked from 'package:shiny':
runExample
The following objects are masked from 'package:methods':
removeClass, show
Attaching package: 'DT'
The following objects are masked from 'package:shiny':
dataTableOutput, renderDataTable
Is there a way to prevent this logging of the unmeaningful error?
The reason why I want to get rid of it is because I further use Inno Setup Compiler to create .exe and this is not working when I have a log file updating each time I run the app.
As you can see in this file (line 66) https://github.com/wleepang/DesktopDeployR/blob/7c81e72c5beb29bf84ca65fd1d5bb5486caec51a/dist/script/wsf/js/run.js
The command is run as
var strCommand = [Rexe, Ropts, RScriptFile, "1>", Outfile, "2>&1"].join(" ");
which redirects command line outputs (that normally directly print to the screen) to the Outfile. You can change this line to
var strCommand = [Rexe, Ropts, RScriptFile].join(" ");
which will disable the logging. This might have other implications though (you might see a command window for example, I am not too sure but test it out).
Alternatively, you might be able to change this file https://github.com/wleepang/DesktopDeployR/blob/7c81e72c5beb29bf84ca65fd1d5bb5486caec51a/app/config.cfg (line 27) and set
- use_userprofile: true
(you need to uncomment this line, it is currently inside a block comment). This will make sure the log file goes into the user profile folder, and that might also solve your problem.
Ivona, I just finished developing the RInno package which also uses Inno Setup and the DesktopDeployR project to install local Shiny apps, and it will log errors without a problem.
To get started:
install.packages("RInno")
require(RInno)
RInno::install_inno()
Then you just need to call two functions to create an installation framework:
create_app(app_name = "myapp", app_dir = "path/to/myapp")
compile_iss()
If you are interested in other features, check out FI Labs - RInno. I'd be interested to know if turning off the error logging feature is something you would like to add ;)

How to change font size for JMeter?

I am using JMeter with 2.13 version.
I want to increase font size for JMeter.
I have tried following question jmeter test plan navigation pane font size. However for 2.13 version doesn't have src folder.
Here is a picture, how it looks now:
How to change font size for JMeter test plan section.
Since JMeter 3.2, use Menu:
Options > Zoom In
Options > Zoom Out
See this:
https://bz.apache.org/bugzilla/show_bug.cgi?id=59995
JMeter 3.0 (released 2 weeks ago) has improved regarding the icons and tables but does not yet support full HiDPI mode:
See this particular bug:
https://bz.apache.org/bugzilla/show_bug.cgi?id=58426
https://bz.apache.org/bugzilla/show_bug.cgi?id=59168
To set properties, see:
https://jmeter.apache.org/usermanual/hints_and_tips.html#hidpi
Now for fonts, you can use Swing mechanism. To do that, add to jmeter.sh or jmeter.bat the JVM System property:
-Dswing.plaf.metal.controlFont=Dialog-20
And ensure you use the Cross Platform LAF
JMeter 4.0 update :
Before any update of Jmeter setting
After the update of Jmeter setting
JMeter 4.0 update using Windows 10 :
1. Go here : C:\apache-jmeter-4.0\bin
2. Open to edit this : jmeter.properties
3. Over here you need to update all required fields for you
This is what I changed and it looks good to me :
jmeter.loggerpanel.display=true
jmeter.loggerpanel.enable_when_closed=true
jmeter.loggerpanel.maxlength=1000
jmeter.gui.refresh_period=500
jmeter.hidpi.mode=true
jmeter.hidpi.scale.factor=2.0
jmeter.toolbar.icons=org/apache/jmeter/images/toolbar/icons-toolbar.properties
jmeter.toolbar=new,open,close,save,save_as_testplan,|,cut,copy,paste,|,expand,collapse,toggle,|,test_start,test_stop,test_shutdown,|,test_start_remote_all,test_stop_remote_all,test_shutdown_remote_all,|,test_clear,test_clear_all,|,search,search_reset,|,function_helper,help
jmeter.toolbar.icons.size=48x48
jmeter.icons=org/apache/jmeter/images/icon_1.properties
jmeter.tree.icons.size=48x48
save_automatically_before_run=true
onload.expandtree=true
jsyntaxtextarea.wrapstyleword=true
jsyntaxtextarea.linewrap=true
jsyntaxtextarea.codefolding=true
jsyntaxtextarea.maxundos=50
jsyntaxtextarea.font.family=Hack
jsyntaxtextarea.font.size=28
loggerpanel.usejsyntaxtext=true
view.results.tree.max_size=10485760
please refer : https://jmeter.apache.org/usermanual/hints_and_tips.html
In order to get src folder you need to download JMeter source code separately, i.e. from here. Unpack the folder and make required changes
You will need Apache Ant to build JMeter. Install it and make sure that %ANT_HOME%/bin folder is added to your system PATH variable
Build JMeter using next 2 commands:
ant download_jars
ant package
Now your should be able to run JMeter with increased font from apache-jmeter-2.13/bin folder like:
jmeter -Djmeter.dialog.font=20 .....
or ir you want to make font size change permanent add the next line to system.properties file (located in JMeter's "bin" folder)
jmeter.dialog.font=20
JMeter restart will be required to pick the property up. See Apache JMeter Properties Customization Guide for more information regarding JMeter properties usage.
If you trust me and Bitbucket hosting you can take the risk and get compiled binary with aforementioned change from
https://bitbucket.org/glinius/jmeter-font-increase/downloads/ApacheJMeter_core.jar
and dropping it to /lib/ext folder of your JMeter installation, however downloading binaries of unknown origin is not recommended (your PC can become a member of a botnet or someone's bitcoin mining farm) so it's better to take above 4 steps.
Using Jmeter 3.2
Options > Zoom In
Zoomed some panes but not others.
However modifying apache-jmeter-3.2\bin\jmeter.properties works. Tested with Win 10.
#jmeter.hidpi.mode=false
# To enable pseudo-hidpi mode change to true
jmeter.hidpi.mode=true
# HiDPI scale factor
#jmeter.hidpi.scale.factor=1.0
# Suggested value for HiDPI
jmeter.hidpi.scale.factor=2.0
In Jmeter 3.1 and 3.2, uncomment below lines in jmeter.properties file, and restart the Jmeter. It worked and the font size increased for all the icons and components
jmeter.hidpi.mode=true
jmeter.hidpi.scale.factor=2.0
After setting the following properties in bin\jmeter.properties it looks better
jmeter.hidpi.mode=true
jmeter.hidpi.scale.factor=2.0
jmeter.toolbar.icons.size=32x32
jmeter.tree.icons.size=24x24
jsyntaxtextarea.font.family=Hack
jsyntaxtextarea.font.size=28
ref: https://jmeter.apache.org/usermanual/hints_and_tips.html

Run executable from JFrame (linux) (eclipse)

I am trying to run a linux based executable called src2srcml in my JFrame GUI that takes a source file (C, C++, Java) and converts it to an XML file to be used later. My GUI successfully uses the JFileChooser to locate and select the source file.
I'm currently trying to use the Runtime.getRuntime().exec() function to run the executable but so far nothing is happening. I can run it from the command line using the commands "bash-4.1$ ./src2srcml --position sum_avg.c -o hooray.c.xml", which takes the source file sum_avg.c, converts it to XML in a new file hooray.c.xml but when I try the exact same commands in Runtime.getRuntime().exec() nothing happens. I'm not particularly familiar with the Runtime.getRuntime().exec() or ProcessBuilder classes. Do I need to navigate to where the executable is first? I also tried including the path in the first parameter, the call to the executable its self but that didn't work either.
//--- 'Run Source Code' Button---//
JButton btnRunSourceCode = new JButton("Run Source Code");
btnRunSourceCode.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(filePath == null){
textArea.setText("Please Load a source file (C, C++, Java)");
}
try{
textArea.setText("Converting Source Code to XML");
String[] commands = {"./src2srcml", "--position ", selectedFile.getName(), " -o targetFile.xml"};
Process src2XML = Runtime.getRuntime().exec(commands);
src2XML.waitFor();
}
catch(Exception exc){/*src2srcml Fail*/}
}
});
btnRunSourceCode.setBounds(612, 39, 156, 25);
contentPane.add(btnRunSourceCode);
Currently the executable is in the workspace of my project (Eclipse). when I get everything working I would like to compile the whole program into a single executable so that the src2srcml is embedded into my executable and isn't required separately. Is this possible?
Thanks in advance for any ideas!
I am not familiar with Unix, but, don't you need to call this through the unix shell, perhaps by calling bash or other shell commands with your command array? For example the answers here
Other problems
Threading: you are currently asking your process to run on the Swing event thread, which if successful will cause your GUI to completely freeze and be non-usable until the process ends. You should make all calls like this background to the GUI thread such as can be achieved by using a SwingWorker object.
GUI mistakes: You're calling setBounds on your JButton and adding to a container that probably uses a null layout, which marks this as code from a Swing newbie, since this means that you're making inflexible GUI's that are very difficult to upgrade or enhance. Use the layout managers to place your components. The Swing layout manager will help show you how to fix this.
Regarding
when I get everything working I would like to compile the whole program into a single executable so that the src2srcml is embedded into my executable and isn't required separately.
No, this is likely not possible, unless you include the file in your jar as well as code to de-zip it.

Prompt text for JFormattedTextField is not working

I wanted to add a text prompt for my JFormattedTextField and I searched it on google on how I could do this. I got a lot of hits for the following code below but when I put it into my code in eclipse it doesn't recognize any of it. Can someone tell me why?
Here are two possible ways to add a text prompt:
PromptSupport.setPrompt("prompt", textComponent);
TextPrompt p = new TextPrompt("text", textComponent);
I got it from the following link:
How to display a default message in JTextField java
the most probable reasons why eclipse doesn't recognize any of these classes are because they are not a part of the JDK.
PromptSupport is a part of the XSwingX library. If you want to use this library for setting PromptText, you will have to download the jar and add it to the build path of the project.
I am not sure whether TextPrompt is the class XSwingX as well.

Categories

Resources