Add support for changing font size application-wide. Also make Look and Feel changes immediately visible and added jar output format support for payloads.
git-svn-id: file:///home/svn/framework3/trunk@12332 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
a0cbbdfab0
commit
8e60901ebf
Binary file not shown.
|
@ -186,7 +186,7 @@ public class InteractWindow extends MsfFrame implements ClipboardOwner {
|
|||
|
||||
if(type.equals("meterpreter"))
|
||||
inputField.setText("help");
|
||||
outputArea.setFont(new Font("Monospaced", outputArea.getFont().getStyle(), 12));
|
||||
outputArea.setFont(new Font("Monospaced", outputArea.getFont().getStyle(), outputArea.getFont().getSize()));
|
||||
checkPrompt(session);
|
||||
((DraggableTabbedPane)tabbedPane).setTabFocusListener(0, new FocusListener() {
|
||||
public void focusGained(FocusEvent e) {
|
||||
|
|
|
@ -48,7 +48,7 @@ public class MainFrame extends FrameView {
|
|||
|
||||
public MainFrame(SingleFrameApplication app) {
|
||||
super(app);
|
||||
setLnF();
|
||||
MsfFrame.setLnF();
|
||||
initComponents();
|
||||
sessionsTableModel = null;
|
||||
sessionWindowMap = new HashMap();
|
||||
|
@ -132,6 +132,7 @@ public class MainFrame extends FrameView {
|
|||
Map props = MsfguiApp.getPropertiesNode();
|
||||
if(!props.containsKey("tabWindowPreference"))
|
||||
props.put("tabWindowPreference", "tab");
|
||||
MsfFrame.updateSizes(getFrame());
|
||||
}
|
||||
/** Before exit, check whether the daemon should be stopped or just the session terminated */
|
||||
private boolean confirmStop() {
|
||||
|
@ -1301,6 +1302,7 @@ nameloop: for (int i = 0; i < names.length; i++) {
|
|||
if(!mex.getMessage().equals("database not loaded"))
|
||||
mex.printStackTrace();
|
||||
}
|
||||
MsfFrame.updateSizes(getFrame());
|
||||
}
|
||||
|
||||
private void refreshItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshItemActionPerformed
|
||||
|
@ -1933,35 +1935,6 @@ nameloop: for (int i = 0; i < names.length; i++) {
|
|||
private int busyIconIndex = 0;
|
||||
private JDialog aboutBox;
|
||||
|
||||
/** Sets look and feel to preset or default */
|
||||
private void setLnF(){
|
||||
setLnF(""+MsfguiApp.getPropertiesNode().get("LnF"));
|
||||
}
|
||||
/** Sets look and feel of UI */
|
||||
private void setLnF(String classname) {
|
||||
Map info = MsfguiApp.getPropertiesNode();
|
||||
try {
|
||||
boolean system = !"Metal".equals(info.get("LnF"));
|
||||
try{
|
||||
UIManager.setLookAndFeel(classname);
|
||||
info.put("LnF", classname);
|
||||
}catch(Exception ulafex){
|
||||
String newLnF = UIManager.getSystemLookAndFeelClassName();
|
||||
//Prefer nimbus
|
||||
for(LookAndFeelInfo lookAndFeel : UIManager.getInstalledLookAndFeels())
|
||||
if(lookAndFeel.getClassName().equals("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"))
|
||||
newLnF = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
|
||||
UIManager.setLookAndFeel(newLnF);
|
||||
info.put("LnF", newLnF);
|
||||
}
|
||||
SwingUtilities.updateComponentTreeUI(this.getFrame());
|
||||
this.getFrame().pack();
|
||||
} catch (Exception e) {
|
||||
JOptionPane.showMessageDialog(getFrame(), e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/** Clear a table's contents, reenabling the tab, and replace with contents of data returned from a db call */
|
||||
private void reAddQuery(JTable table, String call, String[] cols) {
|
||||
try {
|
||||
|
|
|
@ -94,6 +94,7 @@ public abstract class ModuleInfoWindow extends MsfFrame {
|
|||
for (int i = 1; i < authors.size(); i++)
|
||||
authorLine.append(", ").append(authors.get(i));
|
||||
authorsLabel.setText("<html><b>Authors:</b> "+ authorLine.toString()+"</html>");
|
||||
updateSizes(this);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -194,6 +195,7 @@ public abstract class ModuleInfoWindow extends MsfFrame {
|
|||
} catch (MsfException ex) {
|
||||
JOptionPane.showMessageDialog(rootPane, ex);
|
||||
}
|
||||
updateSizes(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -156,7 +156,8 @@ public class ModulePopup extends ModuleInfoWindow implements TreeSelectionListen
|
|||
} catch (MsfException ex) {
|
||||
JOptionPane.showMessageDialog(rootPane, ex);
|
||||
}
|
||||
reGroup();
|
||||
reGroup();
|
||||
updateSizes(mainPanel);
|
||||
}
|
||||
|
||||
/** Creates payload menu. */
|
||||
|
|
|
@ -1,17 +1,85 @@
|
|||
package msfgui;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.HeadlessException;
|
||||
import java.util.Map;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UIManager.LookAndFeelInfo;
|
||||
|
||||
/**
|
||||
* Basic frame; shows default icon and saves dimensions on resize
|
||||
* Basic frame; shows default icon and saves dimensions on resize.
|
||||
* Also handles UI functions across windows
|
||||
*
|
||||
* @author scriptjunkie
|
||||
*/
|
||||
public class MsfFrame extends javax.swing.JFrame{
|
||||
private Map props;
|
||||
private static Map props = null;
|
||||
private String frameClass = null;
|
||||
|
||||
/** Sets look and feel to preset or default */
|
||||
public static void setLnF(){
|
||||
String classname=""+MsfguiApp.getPropertiesNode().get("LnF");
|
||||
Map info = MsfguiApp.getPropertiesNode();
|
||||
try {
|
||||
boolean system = !"Metal".equals(info.get("LnF"));
|
||||
try{
|
||||
UIManager.setLookAndFeel(classname);
|
||||
info.put("LnF", classname);
|
||||
}catch(Exception ulafex){
|
||||
String newLnF = UIManager.getSystemLookAndFeelClassName();
|
||||
//Prefer nimbus
|
||||
for(LookAndFeelInfo lookAndFeel : UIManager.getInstalledLookAndFeels())
|
||||
if(lookAndFeel.getClassName().equals("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"))
|
||||
newLnF = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
|
||||
UIManager.setLookAndFeel(newLnF);
|
||||
info.put("LnF", newLnF);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
JOptionPane.showMessageDialog(null, e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies any UI changes to all frames.
|
||||
*/
|
||||
public static void updateUIs(){
|
||||
setLnF();
|
||||
for(java.awt.Frame fram : java.awt.Frame.getFrames()){
|
||||
updateSizes(fram);
|
||||
javax.swing.SwingUtilities.updateComponentTreeUI(fram);
|
||||
fram.pack();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively iterates through a container, updating the size
|
||||
*
|
||||
* @param c Container or component to be resized
|
||||
*/
|
||||
public static void updateSizes(java.awt.Component com) {
|
||||
//Make sure props is initialized
|
||||
if(props == null)
|
||||
props = MsfguiApp.getPropertiesNode();
|
||||
|
||||
//Reset size
|
||||
if(com instanceof JComponent && props.containsKey("jComponentSizeVariant"))
|
||||
((JComponent)com).putClientProperty("JComponent.sizeVariant", props.get("jComponentSizeVariant"));
|
||||
java.awt.Font fnt = com.getFont();
|
||||
if(fnt != null && props.containsKey("defaultTextSize"))
|
||||
com.setFont(fnt.deriveFont(new Float(props.get("defaultTextSize").toString()).floatValue()));
|
||||
|
||||
//Loop through containers
|
||||
if(com instanceof javax.swing.JMenu)
|
||||
for(Component cc : ((javax.swing.JMenu)com).getMenuComponents())
|
||||
updateSizes(cc);
|
||||
else if(com instanceof java.awt.Container)
|
||||
for(Component cc : ((java.awt.Container)com).getComponents())
|
||||
updateSizes(cc);
|
||||
}
|
||||
|
||||
public MsfFrame(String title) throws HeadlessException {
|
||||
super(title);
|
||||
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(
|
||||
|
@ -24,6 +92,7 @@ public class MsfFrame extends javax.swing.JFrame{
|
|||
*/
|
||||
public void loadSavedSize(){
|
||||
props = MsfguiApp.getPropertiesNode();
|
||||
updateSizes(this);
|
||||
//Do inital setup if needed
|
||||
if(frameClass == null){
|
||||
frameClass = getClass().getName();
|
||||
|
|
|
@ -188,25 +188,25 @@
|
|||
<Component class="javax.swing.JComboBox" name="outputCombo">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="15">
|
||||
<StringArray count="16">
|
||||
<StringItem index="0" value="c"/>
|
||||
<StringItem index="1" value="elf"/>
|
||||
<StringItem index="2" value="exe"/>
|
||||
<StringItem index="3" value="java"/>
|
||||
<StringItem index="4" value="js_le"/>
|
||||
<StringItem index="5" value="js_be"/>
|
||||
<StringItem index="6" value="perl"/>
|
||||
<StringItem index="7" value="raw"/>
|
||||
<StringItem index="8" value="ruby"/>
|
||||
<StringItem index="9" value="vba"/>
|
||||
<StringItem index="10" value="vbs"/>
|
||||
<StringItem index="11" value="loop-vbs"/>
|
||||
<StringItem index="12" value="asp"/>
|
||||
<StringItem index="13" value="war"/>
|
||||
<StringItem index="14" value="macho"/>
|
||||
<StringItem index="3" value="jar"/>
|
||||
<StringItem index="4" value="java"/>
|
||||
<StringItem index="5" value="js_le"/>
|
||||
<StringItem index="6" value="js_be"/>
|
||||
<StringItem index="7" value="perl"/>
|
||||
<StringItem index="8" value="raw"/>
|
||||
<StringItem index="9" value="ruby"/>
|
||||
<StringItem index="10" value="vba"/>
|
||||
<StringItem index="11" value="vbs"/>
|
||||
<StringItem index="12" value="loop-vbs"/>
|
||||
<StringItem index="13" value="asp"/>
|
||||
<StringItem index="14" value="war"/>
|
||||
<StringItem index="15" value="macho"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
<Property name="selectedIndex" type="int" value="2"/>
|
||||
<Property name="name" type="java.lang.String" value="outputCombo" noResource="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
|
|
|
@ -257,8 +257,7 @@ public class PayloadPopup extends ModuleInfoWindow {
|
|||
encoderCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
||||
encoderCombo.setName("encoderCombo"); // NOI18N
|
||||
|
||||
outputCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "c", "elf", "exe", "java", "js_le", "js_be", "perl", "raw", "ruby", "vba", "vbs", "loop-vbs", "asp", "war", "macho" }));
|
||||
outputCombo.setSelectedIndex(2);
|
||||
outputCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "c", "elf", "exe", "jar", "java", "js_le", "js_be", "perl", "raw", "ruby", "vba", "vbs", "loop-vbs", "asp", "war", "macho" }));
|
||||
outputCombo.setName("outputCombo"); // NOI18N
|
||||
|
||||
templateButton.setText(resourceMap.getString("templateButton.text")); // NOI18N
|
||||
|
@ -475,6 +474,8 @@ public class PayloadPopup extends ModuleInfoWindow {
|
|||
private void generateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateButtonActionPerformed
|
||||
try {
|
||||
HashMap hash = getOptions(mainPanel);
|
||||
if(outputCombo.getSelectedItem().toString().equals("jar"))
|
||||
hash.put("Format", "jar");
|
||||
Map data = (Map) rpcConn.execute("module.execute", "payload", fullName,hash);
|
||||
//Basic info
|
||||
if(!data.get("result").equals("success"))
|
||||
|
@ -496,10 +497,13 @@ public class PayloadPopup extends ModuleInfoWindow {
|
|||
if(templateWorkingCheck.isSelected())
|
||||
hash.put("inject", true);
|
||||
}
|
||||
Map encoded = (Map) rpcConn.execute("module.encode", Base64.encode(buffer),
|
||||
encoderCombo.getSelectedItem().toString(),hash);
|
||||
if(!outputCombo.getSelectedItem().toString().equals("jar")){ //jars don't get encoded
|
||||
Map encoded = (Map) rpcConn.execute("module.encode", Base64.encode(buffer),
|
||||
encoderCombo.getSelectedItem().toString(),hash);
|
||||
buffer = Base64.decode(encoded.get("encoded").toString());
|
||||
}
|
||||
FileOutputStream fout = new FileOutputStream(outputPathField.getText());
|
||||
fout.write(Base64.decode(encoded.get("encoded").toString()));
|
||||
fout.write(buffer);
|
||||
fout.close();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="headerLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="setLnFBox" pref="286" max="32767" attributes="0"/>
|
||||
<Component id="setLnFBox" pref="397" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
|
@ -39,19 +39,29 @@
|
|||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="tableLineBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="238" max="32767" attributes="0"/>
|
||||
<Component id="fontSizeSlider" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="tableExpandBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="76" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="restartLabel" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="okButton" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="tableLineBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="331" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="tableExpandBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="169" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="restartLabel" pref="389" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="okButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
|
@ -70,7 +80,12 @@
|
|||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="tabWindowBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel2" pref="62" max="32767" attributes="1"/>
|
||||
<Component id="fontSizeSlider" alignment="0" min="-2" max="-2" attributes="1"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="tableLineBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="tableExpandBox" min="-2" max="-2" attributes="0"/>
|
||||
|
@ -80,7 +95,7 @@
|
|||
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
@ -141,6 +156,9 @@
|
|||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="setLnFBox" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="setLnFBoxActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
|
@ -148,5 +166,25 @@
|
|||
<Property name="name" type="java.lang.String" value="jLabel1" noResource="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSlider" name="fontSizeSlider">
|
||||
<Properties>
|
||||
<Property name="maximum" type="int" value="20"/>
|
||||
<Property name="minimum" type="int" value="4"/>
|
||||
<Property name="paintLabels" type="boolean" value="true"/>
|
||||
<Property name="paintTicks" type="boolean" value="true"/>
|
||||
<Property name="snapToTicks" type="boolean" value="true"/>
|
||||
<Property name="value" type="int" value="10"/>
|
||||
<Property name="name" type="java.lang.String" value="fontSizeSlider" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="fontSizeSliderStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" resourceKey="jLabel2.text"/>
|
||||
<Property name="name" type="java.lang.String" value="jLabel2" noResource="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
|
|
@ -20,11 +20,14 @@ public class PreferencesFrame extends MsfFrame {
|
|||
for(int i = 0; i < infoArray.length; i++)
|
||||
lookNFeels[i] = infoArray[i].getClassName();
|
||||
initComponents();
|
||||
updateSizes(this);
|
||||
prefs = MsfguiApp.getPropertiesNode();
|
||||
setLnFBox.setSelectedItem(prefs.get("LnF"));
|
||||
tabWindowBox.setSelected(!"window".equals(prefs.get("tabWindowPreference")));
|
||||
tableLineBox.setSelected(Boolean.TRUE.equals(prefs.get("tableShowLines")));
|
||||
tableExpandBox.setSelected(!"off".equals(prefs.get("tableResize")));
|
||||
if(prefs.containsKey("defaultTextSize"))
|
||||
fontSizeSlider.setValue(new Integer(prefs.get("defaultTextSize").toString()));
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
@ -45,6 +48,8 @@ public class PreferencesFrame extends MsfFrame {
|
|||
restartLabel = new javax.swing.JLabel();
|
||||
setLnFBox = new javax.swing.JComboBox();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
fontSizeSlider = new javax.swing.JSlider();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setName("Form"); // NOI18N
|
||||
|
@ -83,10 +88,31 @@ public class PreferencesFrame extends MsfFrame {
|
|||
|
||||
setLnFBox.setModel(new javax.swing.DefaultComboBoxModel(lookNFeels));
|
||||
setLnFBox.setName("setLnFBox"); // NOI18N
|
||||
setLnFBox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
setLnFBoxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
|
||||
jLabel1.setName("jLabel1"); // NOI18N
|
||||
|
||||
fontSizeSlider.setMaximum(20);
|
||||
fontSizeSlider.setMinimum(4);
|
||||
fontSizeSlider.setPaintLabels(true);
|
||||
fontSizeSlider.setPaintTicks(true);
|
||||
fontSizeSlider.setSnapToTicks(true);
|
||||
fontSizeSlider.setValue(10);
|
||||
fontSizeSlider.setName("fontSizeSlider"); // NOI18N
|
||||
fontSizeSlider.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||
fontSizeSliderStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
|
||||
jLabel2.setName("jLabel2"); // NOI18N
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
|
@ -98,23 +124,30 @@ public class PreferencesFrame extends MsfFrame {
|
|||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(headerLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(setLnFBox, 0, 286, Short.MAX_VALUE)
|
||||
.addComponent(setLnFBox, 0, 397, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel1))
|
||||
.addComponent(tabWindowBox))
|
||||
.addContainerGap())
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(tableLineBox)
|
||||
.addContainerGap(238, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(tableExpandBox)
|
||||
.addContainerGap(76, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(restartLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(fontSizeSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cancelButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(okButton)
|
||||
.addComponent(jLabel2)
|
||||
.addContainerGap())
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(tableLineBox)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 331, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(tableExpandBox)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 169, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(restartLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cancelButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(okButton)))
|
||||
.addGap(18, 18, 18))))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
|
@ -128,7 +161,11 @@ public class PreferencesFrame extends MsfFrame {
|
|||
.addComponent(jLabel1))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(tabWindowBox)
|
||||
.addGap(18, 18, 18)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)
|
||||
.addComponent(fontSizeSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(tableLineBox)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(tableExpandBox)
|
||||
|
@ -137,13 +174,17 @@ public class PreferencesFrame extends MsfFrame {
|
|||
.addComponent(restartLabel)
|
||||
.addComponent(cancelButton)
|
||||
.addComponent(okButton))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
|
||||
try{
|
||||
UIManager.setLookAndFeel(prefs.get("LnF").toString());
|
||||
}catch(Exception ex){
|
||||
}
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}//GEN-LAST:event_cancelButtonActionPerformed
|
||||
|
@ -153,14 +194,50 @@ public class PreferencesFrame extends MsfFrame {
|
|||
prefs.put("tabWindowPreference", tabWindowBox.isSelected() ? "tab" : "window");
|
||||
prefs.put("tableShowLines", tableLineBox.isSelected());
|
||||
prefs.put("tableResize", tableExpandBox.isSelected() ? "on" : "off");
|
||||
prefs.put("defaultTextSize", new Integer(fontSizeSlider.getValue()).toString());
|
||||
if(fontSizeSlider.getValue() >= 12)
|
||||
prefs.put("jComponentSizeVariant", "large");
|
||||
else if(fontSizeSlider.getValue() >= 10)
|
||||
prefs.put("jComponentSizeVariant", "regular");
|
||||
else if(fontSizeSlider.getValue() >= 8)
|
||||
prefs.put("jComponentSizeVariant", "small");
|
||||
else
|
||||
prefs.put("jComponentSizeVariant", "mini");
|
||||
setVisible(false);
|
||||
dispose();
|
||||
updateUIs();
|
||||
}//GEN-LAST:event_okButtonActionPerformed
|
||||
|
||||
/**
|
||||
* Recursively iterates through a container, updating the size to this local font slider size
|
||||
* @param c Container to be resized
|
||||
*/
|
||||
public void updateSize(java.awt.Container c) {
|
||||
for(java.awt.Component com : c.getComponents()) {
|
||||
com.setFont(com.getFont().deriveFont((float)fontSizeSlider.getValue()));
|
||||
if (com instanceof java.awt.Container)
|
||||
updateSize((java.awt.Container) com);
|
||||
}
|
||||
}
|
||||
private void fontSizeSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_fontSizeSliderStateChanged
|
||||
updateSize(this);
|
||||
}//GEN-LAST:event_fontSizeSliderStateChanged
|
||||
|
||||
private void setLnFBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setLnFBoxActionPerformed
|
||||
try{
|
||||
UIManager.setLookAndFeel(setLnFBox.getSelectedItem().toString());
|
||||
javax.swing.SwingUtilities.updateComponentTreeUI(this);
|
||||
pack();
|
||||
}catch(Exception ex){
|
||||
}
|
||||
}//GEN-LAST:event_setLnFBoxActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton cancelButton;
|
||||
private javax.swing.JSlider fontSizeSlider;
|
||||
private javax.swing.JLabel headerLabel;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JButton okButton;
|
||||
private javax.swing.JLabel restartLabel;
|
||||
private javax.swing.JComboBox setLnFBox;
|
||||
|
|
|
@ -4,5 +4,6 @@ tableExpandBox.text=Expand tables to fit data instead of window
|
|||
okButton.text=OK
|
||||
cancelButton.text=Cancel
|
||||
headerLabel.text=<html><h1>View Preferences</h1></html>
|
||||
restartLabel.text=Note: restart required to apply changes
|
||||
restartLabel.text=Note: may need to restart msfgui to apply changes
|
||||
jLabel1.text=Look and Feel
|
||||
jLabel2.text=Default text size
|
||||
|
|
Loading…
Reference in New Issue